[PATCH] netdevsim: make nsim_bus const

Ricardo B. Marliere posted 1 patch 2 years ago
drivers/net/netdevsim/bus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] netdevsim: make nsim_bus const
Posted by Ricardo B. Marliere 2 years ago
Now that the driver core can properly handle constant struct bus_type,
move the nsim_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 <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
 drivers/net/netdevsim/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c
index bcbc1e19edde..aedab1d9623a 100644
--- a/drivers/net/netdevsim/bus.c
+++ b/drivers/net/netdevsim/bus.c
@@ -260,7 +260,7 @@ static int nsim_num_vf(struct device *dev)
 	return nsim_bus_dev->num_vfs;
 }
 
-static struct bus_type nsim_bus = {
+static const struct bus_type nsim_bus = {
 	.name		= DRV_NAME,
 	.dev_name	= DRV_NAME,
 	.bus_groups	= nsim_bus_groups,

---
base-commit: ffabe98cb576097b77d404d39e8b3df03caa986a
change-id: 20240204-bus_cleanup-net-9361456dbe19

Best regards,
-- 
Ricardo B. Marliere <ricardo@marliere.net>
Re: [PATCH] netdevsim: make nsim_bus const
Posted by Greg Kroah-Hartman 2 years ago
On Sun, Feb 04, 2024 at 05:16:34PM -0300, Ricardo B. Marliere wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move the nsim_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 <gregkh@linuxfoundation.org>
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>