Skip to contentSkip to conversation

xen/mcelog: mark g_physinfo, ncpus and xen_mce_chrdev_device as __ro_after_init

PATCH In review Len Bao 2 participants 2 messages May 23 Xen hypervisor interface

lore
Share & tools
lore

Len Bao

author
#0 lore raw

PATCH 1/1 xen/mcelog: mark g_physinfo, ncpus and xen_mce_chrdev_device as __ro_after_init

The 'g_physinfo' and 'ncpus' variables are initialized only during the init phase in the 'bind_virq_for_mce' function and never changed. So, mark them as __ro_after_init.

The 'xen_mce_chrdev_device' variable is initialized only in the declaration and never changed. So, this variable could be 'const', but using the 'misc_register' and 'misc_deregister' functions discards the 'const' qualifier. Therefore, as an alternative, mark it as __ro_after_init.

---
 drivers/xen/mcelog.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/xen/mcelog.c +3 -3
index 53a8720f5..32ab419bb 100644
@@ -54,8 +54,8 @@
 #include <asm/xen/hypervisor.h>
 
 static struct mc_info g_mi;
-static struct mcinfo_logical_cpu *g_physinfo;
-static uint32_t ncpus;
+static struct mcinfo_logical_cpu *g_physinfo __ro_after_init;
+static uint32_t ncpus __ro_after_init;
 
 static DEFINE_MUTEX(mcelog_lock);
 
@@ -182,7 +182,7 @@ static const struct file_operations xen_mce_chrdev_ops = {
 	.unlocked_ioctl		= xen_mce_chrdev_ioctl,
 };
 
-static struct miscdevice xen_mce_chrdev_device = {
+static struct miscdevice xen_mce_chrdev_device __ro_after_init = {
 	MISC_MCELOG_MINOR,
 	"mcelog",
 	&xen_mce_chrdev_ops,
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Len Bao

The 'g_physinfo' and 'ncpus' variables are initialized only during the init phase in the 'bind_virq_for_mce' function and never changed. So, mark them as __ro_after_init.

The 'xen_mce_chrdev_device' variable is initialized only in the declaration and never changed. So, this variable could be 'const', but using the 'misc_register' and 'misc_deregister' functions discards the 'const' qualifier. Therefore, as an alternative, mark it as __ro_after_init.

Juergen