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

platform: Make platform_bus_type constant

Since commit d492cc2573a0 ("driver core: device.h: make struct
bus_type a const *"), the driver core can properly handle constant
struct bus_type, move the platform_bus_type variable to be a constant
structure as well, placing it into read-only memory which can not be
modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Link: https://lore.kernel.org/r/20240823075544.144426-1-kunwu.chan@linux.dev
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Kunwu Chan and committed by
Greg Kroah-Hartman
24e041e1 a169a663

+2 -2
+1 -1
drivers/base/platform.c
··· 1474 1474 USE_PLATFORM_PM_SLEEP_OPS 1475 1475 }; 1476 1476 1477 - struct bus_type platform_bus_type = { 1477 + const struct bus_type platform_bus_type = { 1478 1478 .name = "platform", 1479 1479 .dev_groups = platform_dev_groups, 1480 1480 .match = platform_match,
+1 -1
include/linux/platform_device.h
··· 52 52 extern int platform_device_register(struct platform_device *); 53 53 extern void platform_device_unregister(struct platform_device *); 54 54 55 - extern struct bus_type platform_bus_type; 55 + extern const struct bus_type platform_bus_type; 56 56 extern struct device platform_bus; 57 57 58 58 extern struct resource *platform_get_resource(struct platform_device *,