Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mei: make mei_class a static const structure

Now that the driver core allows for struct class to be in read-only
memory, move the mei_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230811213052.85044-1-ivan.orlov0322@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ivan Orlov and committed by
Greg Kroah-Hartman
df8e2c3e 979ca1ca

+12 -13
+12 -13
drivers/misc/mei/main.c
··· 27 27 #include "mei_dev.h" 28 28 #include "client.h" 29 29 30 - static struct class *mei_class; 30 + static const struct class mei_class = { 31 + .name = "mei", 32 + }; 33 + 31 34 static dev_t mei_devt; 32 35 #define MEI_MAX_DEVS MINORMASK 33 36 static DEFINE_MUTEX(mei_minor_lock); ··· 1118 1115 1119 1116 dev->dev_state = state; 1120 1117 1121 - clsdev = class_find_device_by_devt(mei_class, dev->cdev.dev); 1118 + clsdev = class_find_device_by_devt(&mei_class, dev->cdev.dev); 1122 1119 if (clsdev) { 1123 1120 sysfs_notify(&clsdev->kobj, NULL, "dev_state"); 1124 1121 put_device(clsdev); ··· 1235 1232 goto err_dev_add; 1236 1233 } 1237 1234 1238 - clsdev = device_create_with_groups(mei_class, parent, devno, 1235 + clsdev = device_create_with_groups(&mei_class, parent, devno, 1239 1236 dev, mei_groups, 1240 1237 "mei%d", dev->minor); 1241 1238 ··· 1267 1264 1268 1265 mei_dbgfs_deregister(dev); 1269 1266 1270 - device_destroy(mei_class, devno); 1267 + device_destroy(&mei_class, devno); 1271 1268 1272 1269 mei_minor_free(dev); 1273 1270 } ··· 1277 1274 { 1278 1275 int ret; 1279 1276 1280 - mei_class = class_create("mei"); 1281 - if (IS_ERR(mei_class)) { 1282 - pr_err("couldn't create class\n"); 1283 - ret = PTR_ERR(mei_class); 1284 - goto err; 1285 - } 1277 + ret = class_register(&mei_class); 1278 + if (ret) 1279 + return ret; 1286 1280 1287 1281 ret = alloc_chrdev_region(&mei_devt, 0, MEI_MAX_DEVS, "mei"); 1288 1282 if (ret < 0) { ··· 1298 1298 err_chrdev: 1299 1299 unregister_chrdev_region(mei_devt, MEI_MAX_DEVS); 1300 1300 err_class: 1301 - class_destroy(mei_class); 1302 - err: 1301 + class_unregister(&mei_class); 1303 1302 return ret; 1304 1303 } 1305 1304 1306 1305 static void __exit mei_exit(void) 1307 1306 { 1308 1307 unregister_chrdev_region(mei_devt, MEI_MAX_DEVS); 1309 - class_destroy(mei_class); 1308 + class_unregister(&mei_class); 1310 1309 mei_cl_bus_exit(); 1311 1310 } 1312 1311