scsi: core: Make scsi_bus_type const
authorRicardo B. Marliere <ricardo@marliere.net>
Mon, 12 Feb 2024 18:38:37 +0000 (15:38 -0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 13 Feb 2024 01:47:23 +0000 (20:47 -0500)
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 scsi_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: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240212-bus_cleanup-scsi2-v2-1-65004493ff09@marliere.net
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_priv.h
drivers/scsi/scsi_sysfs.c

index 3f0dfb97db6bd1b88755db1fb50dd6e968e385c6..92e966a2b48a5119ec13fd9cdfd0a666efb7c998 100644 (file)
@@ -156,7 +156,7 @@ extern void scsi_sysfs_device_initialize(struct scsi_device *);
 extern struct scsi_transport_template blank_transport_template;
 extern void __scsi_remove_device(struct scsi_device *);
 
-extern struct bus_type scsi_bus_type;
+extern const struct bus_type scsi_bus_type;
 extern const struct attribute_group *scsi_shost_groups[];
 
 /* scsi_netlink.c */
index 24f6eefb68030d39869934e6fbefc9fce11d640b..14d0be0da0c6871cbe0ca2a6fd091c7eaed550b7 100644 (file)
@@ -549,7 +549,7 @@ static int scsi_bus_uevent(const struct device *dev, struct kobj_uevent_env *env
        return 0;
 }
 
-struct bus_type scsi_bus_type = {
+const struct bus_type scsi_bus_type = {
         .name          = "scsi",
         .match         = scsi_bus_match,
        .uevent         = scsi_bus_uevent,