Re: [PATCH 4/5] USB: Select better matching USB drivers when available

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 9 Oct 2019, Bastien Nocera wrote:

> On Wed, 2019-10-09 at 13:28 -0400, Alan Stern wrote:
> <snip>
> > No, that's not quite it.
> > 
> > Here's what should happen when the subclass driver is being probed:
> > First, call the generic_probe routine, and return immediately if that
> > fails.  Then call the subclass driver's probe routine.  If that gets
> > an
> > error, fail the probe call but tell the device core that the device
> > is
> > now bound to the generic driver, not to the subclass driver.
> 
> So, something like that, on top of the existing patches? (I'm not sure
> whether device_driver_attach is the correct call to use here).
> 
> -       if (udriver->probe)
> -               return udriver->probe(udev);
> -       return 0;
> +       if (!udriver->probe)
> +               return 0;

This test is unnecessary; all drivers must have a probe routine.  
Otherwise how would they know when they get bound to a device?

> +       error = udriver->probe(udev);
> +       if (error == -ENODEV &&
> +           udrv != &usb_generic_driver)

No need to test for usb_generic_driver; its probe routine always 
returns 0.  But if you want to include the test anyway, at least don't 
split the line -- it will all fit in under 80 columns.

> +               return device_driver_attach(usb_generic_driver.drvwrap.driver, dev);
> +       return error;

I think that's right.  A little testing wouldn't hurt.

> Anything else in this patch series? I was concerned about the naming
> for "generic_init" in patch 2 ("subclass").

Yes; see the suggestions in

	https://marc.info/?l=linux-usb&m=157063168632242&w=2

Also (I didn't notice this earlier), in patch 1/5 it's not necessary to 
EXPORT the usb_generic_* routines.  They don't get used in the subclass 
driver, only in usbcore.

> If there's nothing, I'll test and respin the patchset with the above
> changes tomorrow.

Okay, good.

Alan Stern




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux