Skip to content

Commit d5f5535

Browse files
committed
random: Make random_source definitions const
We can do so trivially, so make these tables read-only. No functional change intended. Reviewed by: cem, emaste MFC after: 2 weeks Sponsored by: Stormshield Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D52003
1 parent 3d4d778 commit d5f5535

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

sys/crypto/ccp/ccp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static struct pciid {
7979
{ 0x15df1022, "AMD CCP-5a" },
8080
};
8181

82-
static struct random_source random_ccp = {
82+
static const struct random_source random_ccp = {
8383
.rs_ident = "AMD CCP TRNG",
8484
.rs_source = RANDOM_PURE_CCP,
8585
.rs_read = random_ccp_read,

sys/dev/psci/smccc_trng.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static device_attach_t trng_attach;
5858

5959
static unsigned trng_read(void *, unsigned);
6060

61-
static struct random_source random_trng = {
61+
static const struct random_source random_trng = {
6262
.rs_ident = "Arm SMCCC TRNG",
6363
.rs_source = RANDOM_PURE_ARM_TRNG,
6464
.rs_read = trng_read,

sys/dev/qcom_rnd/qcom_rnd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static int qcom_rnd_detach(device_t);
6363
static int qcom_rnd_harvest(struct qcom_rnd_softc *, void *, size_t *);
6464
static unsigned qcom_rnd_read(void *, unsigned);
6565

66-
static struct random_source random_qcom_rnd = {
66+
static const struct random_source random_qcom_rnd = {
6767
.rs_ident = "Qualcomm Entropy Adapter",
6868
.rs_source = RANDOM_PURE_QUALCOMM,
6969
.rs_read = qcom_rnd_read,

sys/dev/random/armv8rng.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
static u_int random_rndr_read(void *, u_int);
4545

4646
static bool has_rndr;
47-
static struct random_source random_armv8_rndr = {
47+
static const struct random_source random_armv8_rndr = {
4848
.rs_ident = "Armv8 rndr RNG",
4949
.rs_source = RANDOM_PURE_ARMV8,
5050
.rs_read = random_rndr_read,

sys/dev/random/darn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
static u_int random_darn_read(void *, u_int);
5858

59-
static struct random_source random_darn = {
59+
static const struct random_source random_darn = {
6060
.rs_ident = "PowerISA DARN random number generator",
6161
.rs_source = RANDOM_PURE_DARN,
6262
.rs_read = random_darn_read

sys/dev/random/ivy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
static bool has_rdrand, has_rdseed;
5252
static u_int random_ivy_read(void *, u_int);
5353

54-
static struct random_source random_ivy = {
54+
static const struct random_source random_ivy = {
5555
.rs_ident = "Intel Secure Key RNG",
5656
.rs_source = RANDOM_PURE_RDRAND,
5757
.rs_read = random_ivy_read

sys/dev/random/nehemiah.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
static u_int random_nehemiah_read(void *, u_int);
4646

47-
static struct random_source random_nehemiah = {
47+
static const struct random_source random_nehemiah = {
4848
.rs_ident = "VIA Nehemiah Padlock RNG",
4949
.rs_source = RANDOM_PURE_NEHEMIAH,
5050
.rs_read = random_nehemiah_read

sys/dev/random/random_harvestq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ __read_frequently u_int hc_source_mask;
110110

111111
struct random_sources {
112112
CK_LIST_ENTRY(random_sources) rrs_entries;
113-
struct random_source *rrs_source;
113+
const struct random_source *rrs_source;
114114
};
115115

116116
static CK_LIST_HEAD(sources_head, random_sources) source_list =
@@ -849,7 +849,7 @@ random_harvest_deregister_source(enum random_entropy_source source)
849849
}
850850

851851
void
852-
random_source_register(struct random_source *rsource)
852+
random_source_register(const struct random_source *rsource)
853853
{
854854
struct random_sources *rrs;
855855

@@ -868,7 +868,7 @@ random_source_register(struct random_source *rsource)
868868
}
869869

870870
void
871-
random_source_deregister(struct random_source *rsource)
871+
random_source_deregister(const struct random_source *rsource)
872872
{
873873
struct random_sources *rrs = NULL;
874874

sys/dev/random/randomdev.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ struct random_source {
103103
random_source_read_t *rs_read;
104104
};
105105

106-
void random_source_register(struct random_source *);
107-
void random_source_deregister(struct random_source *);
106+
void random_source_register(const struct random_source *);
107+
void random_source_deregister(const struct random_source *);
108108

109109
#endif /* _KERNEL */
110110

sys/dev/virtio/random/virtio_random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static struct virtio_feature_desc vtrnd_feature_desc[] = {
7777
{ 0, NULL }
7878
};
7979

80-
static struct random_source random_vtrnd = {
80+
static const struct random_source random_vtrnd = {
8181
.rs_ident = "VirtIO Entropy Adapter",
8282
.rs_source = RANDOM_PURE_VIRTIO,
8383
.rs_read = vtrnd_read,

0 commit comments

Comments
 (0)