Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3fce396

Browse files
m-v-bgregkh
authored andcommitted
usbcore/driver: Accommodate usbip
Commit88b7381 ("USB: Select better matching USB drivers whenavailable") inadvertently broke usbip functionality. The commit inquestion allows USB device drivers to be explicitly matched withUSB devices via the use of driver-provided identifier tables andmatch functions, which is useful for a specialised device driverto be chosen for a device that can also be handled by another,more generic, device driver.Prior, the USB device section of usb_device_match() had anunconditional "return 1" statement, which allowed user-space to bindUSB devices to the usbip_host device driver, if desired. However,the aforementioned commit changed the default/fallback returnvalue to zero. This breaks device drivers such as usbip_host, sothis commit restores the legacy behaviour, but only if a devicedriver does not have an id_table and a match() function.In addition, if usb_device_match is called for a device driverand device pair where the device does not match the id_table of thedevice driver in question, then the device driver will be disqualifiedfor the device. This allows avoiding the default case of "return 1",which prevents undesirable probe() calls to a driver even thoughits id_table did not match the device.Finally, this commit changes the specialised-driver-to-generic-drivertransition code so that when a device driver returns -ENODEV, a moregeneric device driver is only considered if the current device driverdoes not have an id_table and a match() function. This ensures that"generic" drivers such as usbip_host will not be considered specialiseddevice drivers and will not cause the device to be locked in to thegeneric device driver, when a more specialised device driver could betried.All of these changes restore usbip functionality without regressions,ensure that the specialised/generic device driver selection logic worksas expected with the usb and apple-mfi-fastcharge drivers, and do notnegatively affect the use of devices provided by dummy_hcd.Fixes:88b7381 ("USB: Select better matching USB drivers when available")Cc: <stable@vger.kernel.org> # 5.8Cc: Bastien Nocera <hadess@hadess.net>Cc: Valentina Manea <valentina.manea.m@gmail.com>Cc: Shuah Khan <shuah@kernel.org>Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>Cc: Alan Stern <stern@rowland.harvard.edu>Cc: <syzkaller@googlegroups.com>Tested-by: Andrey Konovalov <andreyknvl@google.com>Acked-by: Shuah Khan <skhan@linuxfoundation.org>Signed-off-by: M. Vefa Bicakci <m.v.b@runbox.com>Link:https://lore.kernel.org/r/20200922110703.720960-5-m.v.b@runbox.comSigned-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent4df30e7 commit3fce396

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

‎drivers/usb/core/driver.c‎

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,30 @@ static int usb_probe_device(struct device *dev)
269269
if (error)
270270
returnerror;
271271

272+
/* Probe the USB device with the driver in hand, but only
273+
* defer to a generic driver in case the current USB
274+
* device driver has an id_table or a match function; i.e.,
275+
* when the device driver was explicitly matched against
276+
* a device.
277+
*
278+
* If the device driver does not have either of these,
279+
* then we assume that it can bind to any device and is
280+
* not truly a more specialized/non-generic driver, so a
281+
* return value of -ENODEV should not force the device
282+
* to be handled by the generic USB driver, as there
283+
* can still be another, more specialized, device driver.
284+
*
285+
* This accommodates the usbip driver.
286+
*
287+
* TODO: What if, in the future, there are multiple
288+
* specialized USB device drivers for a particular device?
289+
* In such cases, there is a need to try all matching
290+
* specialised device drivers prior to setting the
291+
* use_generic_driver bit.
292+
*/
272293
error=udriver->probe(udev);
273-
if (error==-ENODEV&&udriver!=&usb_generic_driver) {
294+
if (error==-ENODEV&&udriver!=&usb_generic_driver&&
295+
(udriver->id_table||udriver->match)) {
274296
udev->use_generic_driver=1;
275297
return-EPROBE_DEFER;
276298
}
@@ -831,14 +853,17 @@ static int usb_device_match(struct device *dev, struct device_driver *drv)
831853
udev=to_usb_device(dev);
832854
udrv=to_usb_device_driver(drv);
833855

834-
if (udrv->id_table&&
835-
usb_device_match_id(udev,udrv->id_table)!=NULL) {
836-
return1;
837-
}
856+
if (udrv->id_table)
857+
returnusb_device_match_id(udev,udrv->id_table)!=NULL;
838858

839859
if (udrv->match)
840860
returnudrv->match(udev);
841-
return0;
861+
862+
/* If the device driver under consideration does not have a
863+
* id_table or a match function, then let the driver's probe
864+
* function decide.
865+
*/
866+
return1;
842867

843868
}elseif (is_usb_interface(dev)) {
844869
structusb_interface*intf;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp