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

peci: constify the struct device_type usage

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
peci_controller_type and peci_device_type variables to be constant
structures as well, placing it into read-only memory which can not be
modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: "Ricardo B. Marliere" <ricardo@marliere.net>
Reviewed-by: Iwona Winiarska <iwona.winiarska@intel.com>
Link: https://lore.kernel.org/r/20240219-device_cleanup-peci-v1-1-0727662616f7@marliere.net
Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com>

authored by

Ricardo B. Marliere and committed by
Iwona Winiarska
e6faf2b7 ed8c2dad

+4 -4
+1 -1
drivers/peci/core.c
··· 25 25 kfree(controller); 26 26 } 27 27 28 - struct device_type peci_controller_type = { 28 + const struct device_type peci_controller_type = { 29 29 .release = peci_controller_dev_release, 30 30 }; 31 31
+1 -1
drivers/peci/device.c
··· 246 246 kfree(device); 247 247 } 248 248 249 - struct device_type peci_device_type = { 249 + const struct device_type peci_device_type = { 250 250 .groups = peci_device_groups, 251 251 .release = peci_device_release, 252 252 };
+2 -2
drivers/peci/internal.h
··· 75 75 u8 model; 76 76 }; 77 77 78 - extern struct device_type peci_device_type; 78 + extern const struct device_type peci_device_type; 79 79 extern const struct attribute_group *peci_device_groups[]; 80 80 81 81 int peci_device_create(struct peci_controller *controller, u8 addr); ··· 129 129 #define module_peci_driver(__peci_driver) \ 130 130 module_driver(__peci_driver, peci_driver_register, peci_driver_unregister) 131 131 132 - extern struct device_type peci_controller_type; 132 + extern const struct device_type peci_controller_type; 133 133 134 134 int peci_controller_scan_devices(struct peci_controller *controller); 135 135