[PATCH] dio: Have dio_bus_match() callback take a const *

Geert Uytterhoeven posted 1 patch 1 year, 5 months ago
drivers/dio/dio-driver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] dio: Have dio_bus_match() callback take a const *
Posted by Geert Uytterhoeven 1 year, 5 months ago
drivers/dio/dio-driver.c:128:11: error: initialization of ‘int (*)(struct device *, const struct device_driver *)’ from incompatible pointer type ‘int (*)(struct device *, struct device_driver *)’ [-Werror=incompatible-pointer-types]
  128 |  .match = dio_bus_match,
      |           ^~~~~~~~~~~~~
drivers/dio/dio-driver.c:128:11: note: (near initialization for ‘dio_bus_type.match’)

Reported-by: noreply@ellerman.id.au
Fixes: d69d804845985c29 ("driver core: have match() callback in struct bus_type take a const *")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/dio/dio-driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c
index 2d9fa6011945d88b..12fa2d209dab9d3c 100644
--- a/drivers/dio/dio-driver.c
+++ b/drivers/dio/dio-driver.c
@@ -110,10 +110,10 @@ void dio_unregister_driver(struct dio_driver *drv)
  *  and 0 if there is no match.
  */
 
-static int dio_bus_match(struct device *dev, struct device_driver *drv)
+static int dio_bus_match(struct device *dev, const struct device_driver *drv)
 {
 	struct dio_dev *d = to_dio_dev(dev);
-	struct dio_driver *dio_drv = to_dio_driver(drv);
+	const struct dio_driver *dio_drv = to_dio_driver(drv);
 	const struct dio_device_id *ids = dio_drv->id_table;
 
 	if (!ids)
-- 
2.34.1

Re: [PATCH] dio: Have dio_bus_match() callback take a const *
Posted by Greg Kroah-Hartman 1 year, 5 months ago
On Wed, Jul 10, 2024 at 09:44:52AM +0200, Geert Uytterhoeven wrote:
> drivers/dio/dio-driver.c:128:11: error: initialization of ‘int (*)(struct device *, const struct device_driver *)’ from incompatible pointer type ‘int (*)(struct device *, struct device_driver *)’ [-Werror=incompatible-pointer-types]
>   128 |  .match = dio_bus_match,
>       |           ^~~~~~~~~~~~~
> drivers/dio/dio-driver.c:128:11: note: (near initialization for ‘dio_bus_type.match’)
> 
> Reported-by: noreply@ellerman.id.au
> Fixes: d69d804845985c29 ("driver core: have match() callback in struct bus_type take a const *")
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
>  drivers/dio/dio-driver.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c
> index 2d9fa6011945d88b..12fa2d209dab9d3c 100644
> --- a/drivers/dio/dio-driver.c
> +++ b/drivers/dio/dio-driver.c
> @@ -110,10 +110,10 @@ void dio_unregister_driver(struct dio_driver *drv)
>   *  and 0 if there is no match.
>   */
>  
> -static int dio_bus_match(struct device *dev, struct device_driver *drv)
> +static int dio_bus_match(struct device *dev, const struct device_driver *drv)
>  {
>  	struct dio_dev *d = to_dio_dev(dev);
> -	struct dio_driver *dio_drv = to_dio_driver(drv);
> +	const struct dio_driver *dio_drv = to_dio_driver(drv);

Same here, to_dio_driver() should be changed to use container_of_const()

thanks,

greg k-h
Re: [PATCH] dio: Have dio_bus_match() callback take a const *
Posted by Greg Kroah-Hartman 1 year, 5 months ago
On Wed, Jul 10, 2024 at 09:47:47AM +0200, Greg Kroah-Hartman wrote:
> On Wed, Jul 10, 2024 at 09:44:52AM +0200, Geert Uytterhoeven wrote:
> > drivers/dio/dio-driver.c:128:11: error: initialization of ‘int (*)(struct device *, const struct device_driver *)’ from incompatible pointer type ‘int (*)(struct device *, struct device_driver *)’ [-Werror=incompatible-pointer-types]
> >   128 |  .match = dio_bus_match,
> >       |           ^~~~~~~~~~~~~
> > drivers/dio/dio-driver.c:128:11: note: (near initialization for ‘dio_bus_type.match’)
> > 
> > Reported-by: noreply@ellerman.id.au
> > Fixes: d69d804845985c29 ("driver core: have match() callback in struct bus_type take a const *")
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > ---
> >  drivers/dio/dio-driver.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c
> > index 2d9fa6011945d88b..12fa2d209dab9d3c 100644
> > --- a/drivers/dio/dio-driver.c
> > +++ b/drivers/dio/dio-driver.c
> > @@ -110,10 +110,10 @@ void dio_unregister_driver(struct dio_driver *drv)
> >   *  and 0 if there is no match.
> >   */
> >  
> > -static int dio_bus_match(struct device *dev, struct device_driver *drv)
> > +static int dio_bus_match(struct device *dev, const struct device_driver *drv)
> >  {
> >  	struct dio_dev *d = to_dio_dev(dev);
> > -	struct dio_driver *dio_drv = to_dio_driver(drv);
> > +	const struct dio_driver *dio_drv = to_dio_driver(drv);
> 
> Same here, to_dio_driver() should be changed to use container_of_const()

I've added that to the change when I've merged this to my tree, thanks!

greg k-h