2024-02-12 18:38:17

by Ricardo B. Marliere

[permalink] [raw]
Subject: [PATCH v2] scsi: Make scsi_bus_type const

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 <[email protected]>
Suggested-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Ricardo B. Marliere <[email protected]>
---
Changes in v2:
- Improved changelog to remove the word "Now".
- Removed unrelated whitespace cleanup.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
drivers/scsi/scsi_priv.h | 2 +-
drivers/scsi/scsi_sysfs.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 1fbfe1b52c9f..9fc397a9ce7a 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -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 */
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 24f6eefb6803..14d0be0da0c6 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -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,

---
base-commit: 59828c7b5975f442ad5bb74a031fe388341f323e
change-id: 20240211-bus_cleanup-scsi2-16c3cfba91af

Best regards,
--
Ricardo B. Marliere <[email protected]>



2024-02-12 19:06:59

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH v2] scsi: Make scsi_bus_type const

On Mon, Feb 12, 2024 at 03:38:37PM -0300, Ricardo B. Marliere wrote:
> 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 <[email protected]>
> Suggested-by: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Ricardo B. Marliere <[email protected]>
> ---
> Changes in v2:
> - Improved changelog to remove the word "Now".
> - Removed unrelated whitespace cleanup.
> - Link to v1: https://lore.kernel.org/r/[email protected]
> ---

Reviewed-by: Greg Kroah-Hartman <[email protected]>

2024-02-13 01:52:17

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH v2] scsi: Make scsi_bus_type const


Ricardo,

> 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.

Applied to 6.9/scsi-staging, thanks!

--
Martin K. Petersen Oracle Linux Engineering

2024-02-15 20:38:34

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH v2] scsi: Make scsi_bus_type const

On Mon, 12 Feb 2024 15:38:37 -0300, Ricardo B. Marliere wrote:

> 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.
>
>
> [...]

Applied to 6.9/scsi-queue, thanks!

[1/1] scsi: Make scsi_bus_type const
https://git.kernel.org/mkp/scsi/c/a0bcad233fd6

--
Martin K. Petersen Oracle Linux Engineering