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

USB: mark all struct bus_type as const

Now that the driver core can properly handle constant struct bus_type,
move all of the USB subsystem struct bus_type structures as const,
placing them into read-only memory which can not be modified at runtime.

Cc: Johan Hovold <johan@kernel.org>
Cc: Evan Green <evgreen@chromium.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20230313182918.1312597-36-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+9 -9
+1 -1
drivers/usb/common/ulpi.c
··· 90 90 drv->remove(to_ulpi_dev(dev)); 91 91 } 92 92 93 - static struct bus_type ulpi_bus = { 93 + static const struct bus_type ulpi_bus = { 94 94 .name = "ulpi", 95 95 .match = ulpi_match, 96 96 .uevent = ulpi_uevent,
+1 -1
drivers/usb/core/driver.c
··· 2025 2025 2026 2026 #endif /* CONFIG_PM */ 2027 2027 2028 - struct bus_type usb_bus_type = { 2028 + const struct bus_type usb_bus_type = { 2029 2029 .name = "usb", 2030 2030 .match = usb_device_match, 2031 2031 .uevent = usb_uevent,
+1 -1
drivers/usb/core/usb.h
··· 140 140 141 141 #endif 142 142 143 - extern struct bus_type usb_bus_type; 143 + extern const struct bus_type usb_bus_type; 144 144 extern struct mutex usb_port_peer_mutex; 145 145 extern struct device_type usb_device_type; 146 146 extern struct device_type usb_if_device_type;
+2 -2
drivers/usb/gadget/udc/core.c
··· 26 26 27 27 static DEFINE_IDA(gadget_id_numbers); 28 28 29 - static struct bus_type gadget_bus_type; 29 + static const struct bus_type gadget_bus_type; 30 30 31 31 /** 32 32 * struct usb_udc - describes one usb device controller ··· 1747 1747 return 0; 1748 1748 } 1749 1749 1750 - static struct bus_type gadget_bus_type = { 1750 + static const struct bus_type gadget_bus_type = { 1751 1751 .name = "gadget", 1752 1752 .probe = gadget_bind_driver, 1753 1753 .remove = gadget_unbind_driver,
+1 -1
drivers/usb/serial/bus.c
··· 144 144 spin_unlock(&drv->dynids.lock); 145 145 } 146 146 147 - struct bus_type usb_serial_bus_type = { 147 + const struct bus_type usb_serial_bus_type = { 148 148 .name = "usb-serial", 149 149 .match = usb_serial_device_match, 150 150 .probe = usb_serial_device_probe,
+1 -1
drivers/usb/typec/bus.c
··· 431 431 adev->ops = NULL; 432 432 } 433 433 434 - struct bus_type typec_bus = { 434 + const struct bus_type typec_bus = { 435 435 .name = "typec", 436 436 .dev_groups = typec_groups, 437 437 .match = typec_match,
+1 -1
drivers/usb/typec/bus.h
··· 28 28 29 29 #define to_altmode(d) container_of(d, struct altmode, adev) 30 30 31 - extern struct bus_type typec_bus; 31 + extern const struct bus_type typec_bus; 32 32 extern const struct device_type typec_altmode_dev_type; 33 33 34 34 #define is_typec_altmode(_dev_) (_dev_->type == &typec_altmode_dev_type)
+1 -1
include/linux/usb/serial.h
··· 378 378 int usb_serial_bus_register(struct usb_serial_driver *device); 379 379 void usb_serial_bus_deregister(struct usb_serial_driver *device); 380 380 381 - extern struct bus_type usb_serial_bus_type; 381 + extern const struct bus_type usb_serial_bus_type; 382 382 extern struct tty_driver *usb_serial_tty_driver; 383 383 384 384 static inline void usb_serial_debug_data(struct device *dev,