diff mbox series

[2/3] USB: Also check for ->match

Message ID 25f9d978b791d25583b18f4b5d0a929e031fec1f.camel@hadess.net (mailing list archive)
State Superseded
Headers show
Series [1/3] USB: Simplify USB ID table match | expand

Commit Message

Bastien Nocera July 25, 2020, 9:14 a.m. UTC
We only ever used a the ID table matching before, but we should probably
also support an open-coded match function.

Fixes: 88b7381a939de ("USB: Select better matching USB drivers when available")
Signed-off-by: Bastien Nocera <hadess@hadess.net>
---
 drivers/usb/core/generic.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Sergey Shtylyov July 25, 2020, 9:43 a.m. UTC | #1
Hello!

On 25.07.2020 12:14, Bastien Nocera wrote:

> We only ever used a the ID table matching before, but we should probably

   So "a" (actually "an") or "the"? :-)

> also support an open-coded match function.
> 
> Fixes: 88b7381a939de ("USB: Select better matching USB drivers when available")
> Signed-off-by: Bastien Nocera <hadess@hadess.net>
> ---
>   drivers/usb/core/generic.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
> index b6f2d4b44754..2b2f1ab6e36a 100644
> --- a/drivers/usb/core/generic.c
> +++ b/drivers/usb/core/generic.c
> @@ -205,8 +205,9 @@ static int __check_usb_generic(struct device_driver *drv, void *data)
>   	udrv = to_usb_device_driver(drv);
>   	if (udrv == &usb_generic_driver)
>   		return 0;
> -
> -	return usb_device_match_id(udev, udrv->id_table) != NULL;
> +	if (usb_device_match_id(udev, udrv->id_table) != NULL)
> +		return 1;
> +	return (udrv->match && udrv->match(udev));

    Outer () not neccesary...

[...]

MBR, Sergei
Bastien Nocera July 25, 2020, 9:47 a.m. UTC | #2
On Sat, 2020-07-25 at 12:43 +0300, Sergei Shtylyov wrote:
> Hello!
> 
> On 25.07.2020 12:14, Bastien Nocera wrote:
> 
> > We only ever used a the ID table matching before, but we should
> > probably
> 
>    So "a" (actually "an") or "the"? :-)

"the" :)

I'll let the tree maintainer fixup the commit message if it's accepted
as-is.

> > also support an open-coded match function.
> > 
> > Fixes: 88b7381a939de ("USB: Select better matching USB drivers when
> > available")
> > Signed-off-by: Bastien Nocera <hadess@hadess.net>
> > ---
> >   drivers/usb/core/generic.c | 5 +++--
> >   1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/core/generic.c
> > b/drivers/usb/core/generic.c
> > index b6f2d4b44754..2b2f1ab6e36a 100644
> > --- a/drivers/usb/core/generic.c
> > +++ b/drivers/usb/core/generic.c
> > @@ -205,8 +205,9 @@ static int __check_usb_generic(struct
> > device_driver *drv, void *data)
> >   	udrv = to_usb_device_driver(drv);
> >   	if (udrv == &usb_generic_driver)
> >   		return 0;
> > -
> > -	return usb_device_match_id(udev, udrv->id_table) != NULL;
> > +	if (usb_device_match_id(udev, udrv->id_table) != NULL)
> > +		return 1;
> > +	return (udrv->match && udrv->match(udev));
> 
>     Outer () not neccesary...

I find it clearer. Unless there's a style guide that disagrees, I'll
leave this as-is.

Cheers
Alan Stern July 25, 2020, 2:51 p.m. UTC | #3
On Sat, Jul 25, 2020 at 11:14:07AM +0200, Bastien Nocera wrote:
> We only ever used a the ID table matching before, but we should probably
> also support an open-coded match function.
> 
> Fixes: 88b7381a939de ("USB: Select better matching USB drivers when available")
> Signed-off-by: Bastien Nocera <hadess@hadess.net>
> ---
>  drivers/usb/core/generic.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
> index b6f2d4b44754..2b2f1ab6e36a 100644
> --- a/drivers/usb/core/generic.c
> +++ b/drivers/usb/core/generic.c
> @@ -205,8 +205,9 @@ static int __check_usb_generic(struct device_driver *drv, void *data)
>  	udrv = to_usb_device_driver(drv);
>  	if (udrv == &usb_generic_driver)
>  		return 0;
> -
> -	return usb_device_match_id(udev, udrv->id_table) != NULL;
> +	if (usb_device_match_id(udev, udrv->id_table) != NULL)
> +		return 1;
> +	return (udrv->match && udrv->match(udev));
>  }
>  
>  static bool usb_generic_driver_match(struct usb_device *udev)

Acked-by: Alan Stern <stern@rowland.harvard.edu>

You know, at some point it would be nice to change the name of this 
function.  __check_usb_generic doesn't explain very well what the 
function actually does: It checks to see whether the driver is 
non-generic and matches the device.  Something like 
check_for_non_generic_match would be a lot better.

Alan Stern
Bastien Nocera July 25, 2020, 3:14 p.m. UTC | #4
On Sat, 2020-07-25 at 10:51 -0400, Alan Stern wrote:
> On Sat, Jul 25, 2020 at 11:14:07AM +0200, Bastien Nocera wrote:
> > We only ever used a the ID table matching before, but we should
> > probably
> > also support an open-coded match function.
> > 
> > Fixes: 88b7381a939de ("USB: Select better matching USB drivers when
> > available")
> > Signed-off-by: Bastien Nocera <hadess@hadess.net>
> > ---
> >  drivers/usb/core/generic.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/core/generic.c
> > b/drivers/usb/core/generic.c
> > index b6f2d4b44754..2b2f1ab6e36a 100644
> > --- a/drivers/usb/core/generic.c
> > +++ b/drivers/usb/core/generic.c
> > @@ -205,8 +205,9 @@ static int __check_usb_generic(struct
> > device_driver *drv, void *data)
> >  	udrv = to_usb_device_driver(drv);
> >  	if (udrv == &usb_generic_driver)
> >  		return 0;
> > -
> > -	return usb_device_match_id(udev, udrv->id_table) != NULL;
> > +	if (usb_device_match_id(udev, udrv->id_table) != NULL)
> > +		return 1;
> > +	return (udrv->match && udrv->match(udev));
> >  }
> >  
> >  static bool usb_generic_driver_match(struct usb_device *udev)
> 
> Acked-by: Alan Stern <stern@rowland.harvard.edu>
> 
> You know, at some point it would be nice to change the name of this 
> function.  __check_usb_generic doesn't explain very well what the 
> function actually does: It checks to see whether the driver is 
> non-generic and matches the device.  Something like 
> check_for_non_generic_match would be a lot better.

Sure. I'll do a follow-up patch unless there's something requiring a
respin.

Greg, there's just the typo in this commit message, all the rest was
ack'ed. Did you want to take care of that typo, or do you want me to
respin?

Cheers
Greg KH July 26, 2020, 8:37 a.m. UTC | #5
On Sat, Jul 25, 2020 at 05:14:10PM +0200, Bastien Nocera wrote:
> On Sat, 2020-07-25 at 10:51 -0400, Alan Stern wrote:
> > On Sat, Jul 25, 2020 at 11:14:07AM +0200, Bastien Nocera wrote:
> > > We only ever used a the ID table matching before, but we should
> > > probably
> > > also support an open-coded match function.
> > > 
> > > Fixes: 88b7381a939de ("USB: Select better matching USB drivers when
> > > available")
> > > Signed-off-by: Bastien Nocera <hadess@hadess.net>
> > > ---
> > >  drivers/usb/core/generic.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/usb/core/generic.c
> > > b/drivers/usb/core/generic.c
> > > index b6f2d4b44754..2b2f1ab6e36a 100644
> > > --- a/drivers/usb/core/generic.c
> > > +++ b/drivers/usb/core/generic.c
> > > @@ -205,8 +205,9 @@ static int __check_usb_generic(struct
> > > device_driver *drv, void *data)
> > >  	udrv = to_usb_device_driver(drv);
> > >  	if (udrv == &usb_generic_driver)
> > >  		return 0;
> > > -
> > > -	return usb_device_match_id(udev, udrv->id_table) != NULL;
> > > +	if (usb_device_match_id(udev, udrv->id_table) != NULL)
> > > +		return 1;
> > > +	return (udrv->match && udrv->match(udev));
> > >  }
> > >  
> > >  static bool usb_generic_driver_match(struct usb_device *udev)
> > 
> > Acked-by: Alan Stern <stern@rowland.harvard.edu>
> > 
> > You know, at some point it would be nice to change the name of this 
> > function.  __check_usb_generic doesn't explain very well what the 
> > function actually does: It checks to see whether the driver is 
> > non-generic and matches the device.  Something like 
> > check_for_non_generic_match would be a lot better.
> 
> Sure. I'll do a follow-up patch unless there's something requiring a
> respin.
> 
> Greg, there's just the typo in this commit message, all the rest was
> ack'ed. Did you want to take care of that typo, or do you want me to
> respin?

Never make me hand-edit a patch, that ensures it will go to the end of
the line :(

ALso, your patches are not showing up as linked to each other, so they
are all over the place in my mailbox.  Please use something like git
send-email or other tools that will properly link them to ensure I can
see them correctly.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index b6f2d4b44754..2b2f1ab6e36a 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -205,8 +205,9 @@  static int __check_usb_generic(struct device_driver *drv, void *data)
 	udrv = to_usb_device_driver(drv);
 	if (udrv == &usb_generic_driver)
 		return 0;
-
-	return usb_device_match_id(udev, udrv->id_table) != NULL;
+	if (usb_device_match_id(udev, udrv->id_table) != NULL)
+		return 1;
+	return (udrv->match && udrv->match(udev));
 }
 
 static bool usb_generic_driver_match(struct usb_device *udev)