Skip to content

Commit 517bcc2

Browse files
rbmarlieremartinkpetersen
authored andcommitted
scsi: core: Constify the struct device_type usage
Since commit aed65af ("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>
1 parent 3e24118 commit 517bcc2

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

drivers/scsi/hosts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static void scsi_host_dev_release(struct device *dev)
371371
kfree(shost);
372372
}
373373

374-
static struct device_type scsi_host_type = {
374+
static const struct device_type scsi_host_type = {
375375
.name = "scsi_host",
376376
.release = scsi_host_dev_release,
377377
};

drivers/scsi/scsi_scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static void scsi_target_dev_release(struct device *dev)
412412
put_device(parent);
413413
}
414414

415-
static struct device_type scsi_target_type = {
415+
static const struct device_type scsi_target_type = {
416416
.name = "scsi_target",
417417
.release = scsi_target_dev_release,
418418
};

drivers/scsi/scsi_sysfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "scsi_priv.h"
2828
#include "scsi_logging.h"
2929

30-
static struct device_type scsi_dev_type;
30+
static const struct device_type scsi_dev_type;
3131

3232
static const struct {
3333
enum scsi_device_state value;
@@ -1626,7 +1626,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost)
16261626
return 0;
16271627
}
16281628

1629-
static struct device_type scsi_dev_type = {
1629+
static const struct device_type scsi_dev_type = {
16301630
.name = "scsi_device",
16311631
.release = scsi_device_dev_release,
16321632
.groups = scsi_sdev_attr_groups,

0 commit comments

Comments
 (0)