scsi: core: Constify the struct device_type usage
authorRicardo B. Marliere <ricardo@marliere.net>
Mon, 19 Feb 2024 11:45:53 +0000 (08:45 -0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 27 Feb 2024 02:22:26 +0000 (21:22 -0500)
Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
scsi_host_type, scsi_target_type and scsi_dev_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>
Link: https://lore.kernel.org/r/20240219-device_cleanup-scsi-v1-1-c5edf2afe178@marliere.net
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hosts.c
drivers/scsi/scsi_scan.c
drivers/scsi/scsi_sysfs.c

index d7f51b84f3c788f0175648655673ca97b4c3b896..4f495a41ec4aaed4c52d01ee84fc274c30236a09 100644 (file)
@@ -371,7 +371,7 @@ static void scsi_host_dev_release(struct device *dev)
        kfree(shost);
 }
 
-static struct device_type scsi_host_type = {
+static const struct device_type scsi_host_type = {
        .name =         "scsi_host",
        .release =      scsi_host_dev_release,
 };
index 70c0319be34cdb148c4989d97a9abada67fb286b..44c1956b17204017a4e84004b201fdc322497c8a 100644 (file)
@@ -412,7 +412,7 @@ static void scsi_target_dev_release(struct device *dev)
        put_device(parent);
 }
 
-static struct device_type scsi_target_type = {
+static const struct device_type scsi_target_type = {
        .name =         "scsi_target",
        .release =      scsi_target_dev_release,
 };
index 14d0be0da0c6871cbe0ca2a6fd091c7eaed550b7..49dd34426d5e06a20d454aa5ca39c3a05b7b6fa3 100644 (file)
@@ -27,7 +27,7 @@
 #include "scsi_priv.h"
 #include "scsi_logging.h"
 
-static struct device_type scsi_dev_type;
+static const struct device_type scsi_dev_type;
 
 static const struct {
        enum scsi_device_state  value;
@@ -1626,7 +1626,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost)
        return 0;
 }
 
-static struct device_type scsi_dev_type = {
+static const struct device_type scsi_dev_type = {
        .name =         "scsi_device",
        .release =      scsi_device_dev_release,
        .groups =       scsi_sdev_attr_groups,