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.

virt: coco: change tsm_class to a const struct

The class_create() call has been deprecated in favor of class_register()
as the driver core now allows for a struct class to be in read-only
memory. Change tsm_class to be a const struct class and drop the
class_create() call. Compile tested only.

Link: https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/

Changes with v1:
- Removed redundant int err variable.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://patch.msgid.link/20260306183325.245254-1-jkoolstra@xs4all.nl
Signed-off-by: Dan Williams <djbw@kernel.org>

authored by

Jori Koolstra and committed by
Dan Williams
3177779a f338e773

+9 -10
+9 -10
drivers/virt/coco/tsm-core.c
··· 9 9 #include <linux/cleanup.h> 10 10 #include <linux/pci-tsm.h> 11 11 12 - static struct class *tsm_class; 12 + static void tsm_release(struct device *); 13 + static const struct class tsm_class = { 14 + .name = "tsm", 15 + .dev_release = tsm_release 16 + }; 13 17 static DEFINE_IDA(tsm_ida); 14 18 15 19 static int match_id(struct device *dev, const void *data) ··· 26 22 27 23 struct tsm_dev *find_tsm_dev(int id) 28 24 { 29 - struct device *dev = class_find_device(tsm_class, NULL, &id, match_id); 25 + struct device *dev = class_find_device(&tsm_class, NULL, &id, match_id); 30 26 31 27 if (!dev) 32 28 return NULL; ··· 50 46 tsm_dev->id = id; 51 47 dev = &tsm_dev->dev; 52 48 dev->parent = parent; 53 - dev->class = tsm_class; 49 + dev->class = &tsm_class; 54 50 device_initialize(dev); 55 51 56 52 return no_free_ptr(tsm_dev); ··· 118 114 119 115 static int __init tsm_init(void) 120 116 { 121 - tsm_class = class_create("tsm"); 122 - if (IS_ERR(tsm_class)) 123 - return PTR_ERR(tsm_class); 124 - 125 - tsm_class->dev_release = tsm_release; 126 - return 0; 117 + return class_register(&tsm_class); 127 118 } 128 119 module_init(tsm_init) 129 120 130 121 static void __exit tsm_exit(void) 131 122 { 132 - class_destroy(tsm_class); 123 + class_unregister(&tsm_class); 133 124 } 134 125 module_exit(tsm_exit) 135 126