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
This commit is contained in:
Mark Johnston 2025-08-19 14:06:02 +00:00
parent 3d4d778262
commit d5f55356a2
10 changed files with 13 additions and 13 deletions

View file

@ -79,7 +79,7 @@ static struct pciid {
{ 0x15df1022, "AMD CCP-5a" },
};
static struct random_source random_ccp = {
static const struct random_source random_ccp = {
.rs_ident = "AMD CCP TRNG",
.rs_source = RANDOM_PURE_CCP,
.rs_read = random_ccp_read,

View file

@ -58,7 +58,7 @@ static device_attach_t trng_attach;
static unsigned trng_read(void *, unsigned);
static struct random_source random_trng = {
static const struct random_source random_trng = {
.rs_ident = "Arm SMCCC TRNG",
.rs_source = RANDOM_PURE_ARM_TRNG,
.rs_read = trng_read,

View file

@ -63,7 +63,7 @@ static int qcom_rnd_detach(device_t);
static int qcom_rnd_harvest(struct qcom_rnd_softc *, void *, size_t *);
static unsigned qcom_rnd_read(void *, unsigned);
static struct random_source random_qcom_rnd = {
static const struct random_source random_qcom_rnd = {
.rs_ident = "Qualcomm Entropy Adapter",
.rs_source = RANDOM_PURE_QUALCOMM,
.rs_read = qcom_rnd_read,

View file

@ -44,7 +44,7 @@
static u_int random_rndr_read(void *, u_int);
static bool has_rndr;
static struct random_source random_armv8_rndr = {
static const struct random_source random_armv8_rndr = {
.rs_ident = "Armv8 rndr RNG",
.rs_source = RANDOM_PURE_ARMV8,
.rs_read = random_rndr_read,

View file

@ -56,7 +56,7 @@
static u_int random_darn_read(void *, u_int);
static struct random_source random_darn = {
static const struct random_source random_darn = {
.rs_ident = "PowerISA DARN random number generator",
.rs_source = RANDOM_PURE_DARN,
.rs_read = random_darn_read

View file

@ -51,7 +51,7 @@
static bool has_rdrand, has_rdseed;
static u_int random_ivy_read(void *, u_int);
static struct random_source random_ivy = {
static const struct random_source random_ivy = {
.rs_ident = "Intel Secure Key RNG",
.rs_source = RANDOM_PURE_RDRAND,
.rs_read = random_ivy_read

View file

@ -44,7 +44,7 @@
static u_int random_nehemiah_read(void *, u_int);
static struct random_source random_nehemiah = {
static const struct random_source random_nehemiah = {
.rs_ident = "VIA Nehemiah Padlock RNG",
.rs_source = RANDOM_PURE_NEHEMIAH,
.rs_read = random_nehemiah_read

View file

@ -110,7 +110,7 @@ __read_frequently u_int hc_source_mask;
struct random_sources {
CK_LIST_ENTRY(random_sources) rrs_entries;
struct random_source *rrs_source;
const struct random_source *rrs_source;
};
static CK_LIST_HEAD(sources_head, random_sources) source_list =
@ -849,7 +849,7 @@ random_harvest_deregister_source(enum random_entropy_source source)
}
void
random_source_register(struct random_source *rsource)
random_source_register(const struct random_source *rsource)
{
struct random_sources *rrs;
@ -868,7 +868,7 @@ random_source_register(struct random_source *rsource)
}
void
random_source_deregister(struct random_source *rsource)
random_source_deregister(const struct random_source *rsource)
{
struct random_sources *rrs = NULL;

View file

@ -103,8 +103,8 @@ struct random_source {
random_source_read_t *rs_read;
};
void random_source_register(struct random_source *);
void random_source_deregister(struct random_source *);
void random_source_register(const struct random_source *);
void random_source_deregister(const struct random_source *);
#endif /* _KERNEL */

View file

@ -77,7 +77,7 @@ static struct virtio_feature_desc vtrnd_feature_desc[] = {
{ 0, NULL }
};
static struct random_source random_vtrnd = {
static const struct random_source random_vtrnd = {
.rs_ident = "VirtIO Entropy Adapter",
.rs_source = RANDOM_PURE_VIRTIO,
.rs_read = vtrnd_read,