dio: make dio_bus_type const

Message ID 20240211-bus_cleanup-dio-v1-1-02140fbc5289@marliere.net
State New
Headers
Series dio: make dio_bus_type const |

Commit Message

Ricardo B. Marliere Feb. 11, 2024, 3:40 p.m. UTC
  Now that the driver core can properly handle constant struct bus_type,
move the dio_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 <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
 drivers/dio/dio-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 047371968ffc470769f541d6933e262dc7085456
change-id: 20240211-bus_cleanup-dio-6cafa80e759b

Best regards,
  

Comments

Greg KH Feb. 12, 2024, 10:44 a.m. UTC | #1
On Sun, Feb 11, 2024 at 12:40:16PM -0300, Ricardo B. Marliere wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move the dio_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 <gregkh@linuxfoundation.org>
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
> ---
>  drivers/dio/dio-driver.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c
> index 69c46935ffc7..2d9fa6011945 100644
> --- a/drivers/dio/dio-driver.c
> +++ b/drivers/dio/dio-driver.c
> @@ -123,7 +123,7 @@ static int dio_bus_match(struct device *dev, struct device_driver *drv)
>  }
>  
>  
> -struct bus_type dio_bus_type = {
> +const struct bus_type dio_bus_type = {
>  	.name	= "dio",
>  	.match	= dio_bus_match,
>  	.probe	= dio_device_probe,
> 

Don't you also have to change this in include/linux/dio.h?

thanks,

greg k-h
  
Ricardo B. Marliere Feb. 12, 2024, 11:32 a.m. UTC | #2
On 12 Feb 11:44, Greg Kroah-Hartman wrote:
> On Sun, Feb 11, 2024 at 12:40:16PM -0300, Ricardo B. Marliere wrote:
> > Now that the driver core can properly handle constant struct bus_type,
> > move the dio_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 <gregkh@linuxfoundation.org>
> > Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
> > ---
> >  drivers/dio/dio-driver.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c
> > index 69c46935ffc7..2d9fa6011945 100644
> > --- a/drivers/dio/dio-driver.c
> > +++ b/drivers/dio/dio-driver.c
> > @@ -123,7 +123,7 @@ static int dio_bus_match(struct device *dev, struct device_driver *drv)
> >  }
> >  
> >  
> > -struct bus_type dio_bus_type = {
> > +const struct bus_type dio_bus_type = {
> >  	.name	= "dio",
> >  	.match	= dio_bus_match,
> >  	.probe	= dio_device_probe,
> > 
> 
> Don't you also have to change this in include/linux/dio.h?

Indeed, I missed it. Will send a v2, thank you.

> 
> thanks,
> 
> greg k-h
  

Patch

diff --git a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c
index 69c46935ffc7..2d9fa6011945 100644
--- a/drivers/dio/dio-driver.c
+++ b/drivers/dio/dio-driver.c
@@ -123,7 +123,7 @@  static int dio_bus_match(struct device *dev, struct device_driver *drv)
 }
 
 
-struct bus_type dio_bus_type = {
+const struct bus_type dio_bus_type = {
 	.name	= "dio",
 	.match	= dio_bus_match,
 	.probe	= dio_device_probe,