2024-02-04 16:21:47

by Ricardo B. Marliere

[permalink] [raw]
Subject: [PATCH 0/2] ntb: struct bus_type cleanup

This series is part of an effort to cleanup the users of the driver
core, as can be seen in many recent patches authored by Greg across the
tree (e.g. [1]). Specifically, this series is part of the task of
splitting one of his TODOs [2].

---
[1]: https://lore.kernel.org/lkml/?q=f%3Agregkh%40linuxfoundation.org+s%3A%22make%22+and+s%3A%22const%22
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=bus_cleanup&id=26105f537f0c60eacfeb430abd2e05d7ddcdd8aa

Cc: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Ricardo B. Marliere <[email protected]>

---
Ricardo B. Marliere (2):
ntb: ntb_transport: make ntb_transport_bus const
ntb: core: make ntb_bus const

drivers/ntb/core.c | 4 ++--
drivers/ntb/ntb_transport.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
---
base-commit: 9341b37ec17a8793e8439e9b18354ba69556b786
change-id: 20240204-bus_cleanup-ntb-6038064ed198

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



2024-02-04 16:22:02

by Ricardo B. Marliere

[permalink] [raw]
Subject: [PATCH 1/2] ntb: ntb_transport: make ntb_transport_bus const

Now that the driver core can properly handle constant struct bus_type,
move the ntb_transport_bus 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]>
---
drivers/ntb/ntb_transport.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index f9e7847a378e..0291d80611dc 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -314,7 +314,7 @@ static void ntb_transport_bus_remove(struct device *dev)
put_device(dev);
}

-static struct bus_type ntb_transport_bus = {
+static const struct bus_type ntb_transport_bus = {
.name = "ntb_transport",
.match = ntb_transport_bus_match,
.probe = ntb_transport_bus_probe,

--
2.43.0


2024-02-04 16:22:21

by Ricardo B. Marliere

[permalink] [raw]
Subject: [PATCH 2/2] ntb: core: make ntb_bus const

Now that the driver core can properly handle constant struct bus_type,
move the ntb_bus 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]>
---
drivers/ntb/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ntb/core.c b/drivers/ntb/core.c
index 27dd93deff6e..f32b77c7e00d 100644
--- a/drivers/ntb/core.c
+++ b/drivers/ntb/core.c
@@ -72,7 +72,7 @@ MODULE_VERSION(DRIVER_VERSION);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESCRIPTION);

-static struct bus_type ntb_bus;
+static const struct bus_type ntb_bus;
static void ntb_dev_release(struct device *dev);

int __ntb_register_client(struct ntb_client *client, struct module *mod,
@@ -292,7 +292,7 @@ static void ntb_dev_release(struct device *dev)
complete(&ntb->released);
}

-static struct bus_type ntb_bus = {
+static const struct bus_type ntb_bus = {
.name = "ntb",
.probe = ntb_probe,
.remove = ntb_remove,

--
2.43.0


2024-02-05 17:32:55

by Dave Jiang

[permalink] [raw]
Subject: Re: [PATCH 1/2] ntb: ntb_transport: make ntb_transport_bus const



On 2/4/24 9:22 AM, Ricardo B. Marliere wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move the ntb_transport_bus 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]>

Reviewed-by: Dave Jiang <[email protected]>
> ---
> drivers/ntb/ntb_transport.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
> index f9e7847a378e..0291d80611dc 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -314,7 +314,7 @@ static void ntb_transport_bus_remove(struct device *dev)
> put_device(dev);
> }
>
> -static struct bus_type ntb_transport_bus = {
> +static const struct bus_type ntb_transport_bus = {
> .name = "ntb_transport",
> .match = ntb_transport_bus_match,
> .probe = ntb_transport_bus_probe,
>

2024-02-05 17:33:18

by Dave Jiang

[permalink] [raw]
Subject: Re: [PATCH 2/2] ntb: core: make ntb_bus const



On 2/4/24 9:22 AM, Ricardo B. Marliere wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move the ntb_bus 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]>

Reviewed-by: Dave Jiang <[email protected]>

> ---
> drivers/ntb/core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ntb/core.c b/drivers/ntb/core.c
> index 27dd93deff6e..f32b77c7e00d 100644
> --- a/drivers/ntb/core.c
> +++ b/drivers/ntb/core.c
> @@ -72,7 +72,7 @@ MODULE_VERSION(DRIVER_VERSION);
> MODULE_AUTHOR(DRIVER_AUTHOR);
> MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
>
> -static struct bus_type ntb_bus;
> +static const struct bus_type ntb_bus;
> static void ntb_dev_release(struct device *dev);
>
> int __ntb_register_client(struct ntb_client *client, struct module *mod,
> @@ -292,7 +292,7 @@ static void ntb_dev_release(struct device *dev)
> complete(&ntb->released);
> }
>
> -static struct bus_type ntb_bus = {
> +static const struct bus_type ntb_bus = {
> .name = "ntb",
> .probe = ntb_probe,
> .remove = ntb_remove,
>

2024-02-05 20:11:14

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 0/2] ntb: struct bus_type cleanup

On Sun, Feb 04, 2024 at 01:21:59PM -0300, Ricardo B. Marliere wrote:
> This series is part of an effort to cleanup the users of the driver
> core, as can be seen in many recent patches authored by Greg across the
> tree (e.g. [1]). Specifically, this series is part of the task of
> splitting one of his TODOs [2].
>
> ---
> [1]: https://lore.kernel.org/lkml/?q=f%3Agregkh%40linuxfoundation.org+s%3A%22make%22+and+s%3A%22const%22
> [2]: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=bus_cleanup&id=26105f537f0c60eacfeb430abd2e05d7ddcdd8aa
>
> Cc: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Ricardo B. Marliere <[email protected]>
>
> ---
> Ricardo B. Marliere (2):
> ntb: ntb_transport: make ntb_transport_bus const
> ntb: core: make ntb_bus const

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