mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 08:31:55 +00:00
USB: altsetting overrides for usbtest
The usbtest driver includes some rather simple-minded logic for selecting an altsetting to test. It doesn't work well for the g_zero gadget, because it selects altsetting 0 (which doesn't have isochronous endpoints) rather than altsetting 1 (which does have them, if the gadget's hardware supports them). This prevents usbtest's isochronous tests (15, 16, 22, and 23) from working with g_zero. Since g_zero is one of the most common gadget drivers used for USB testing, usbtest should do a better job of supporting it. But since some programs may rely on the current scheme for selecting altsettings, I didn't want to change it. Instead, this patch (as1655) adds a module parameter to usbtest, which can be used to override the default altsetting. Since usbtest is never used by normal users (most distributions probably don't even build it), the new module parameter won't inconvenience anybody. In any case, it is entirely optional -- leaving it unset preserves the existing behavior. The patch also fixes a related bug in usbtest: After selecting an altsetting, the driver neglects to store its selection. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7b8bc3aad0
commit
d0b4652f80
@ -11,6 +11,12 @@
|
|||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static int override_alt = -1;
|
||||||
|
module_param_named(alt, override_alt, int, 0644);
|
||||||
|
MODULE_PARM_DESC(alt, ">= 0 to override altsetting selection");
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* FIXME make these public somewhere; usbdevfs.h? */
|
/* FIXME make these public somewhere; usbdevfs.h? */
|
||||||
@ -103,6 +109,10 @@ get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf)
|
|||||||
iso_in = iso_out = NULL;
|
iso_in = iso_out = NULL;
|
||||||
alt = intf->altsetting + tmp;
|
alt = intf->altsetting + tmp;
|
||||||
|
|
||||||
|
if (override_alt >= 0 &&
|
||||||
|
override_alt != alt->desc.bAlternateSetting)
|
||||||
|
continue;
|
||||||
|
|
||||||
/* take the first altsetting with in-bulk + out-bulk;
|
/* take the first altsetting with in-bulk + out-bulk;
|
||||||
* ignore other endpoints and altsettings.
|
* ignore other endpoints and altsettings.
|
||||||
*/
|
*/
|
||||||
@ -144,6 +154,7 @@ try_iso:
|
|||||||
|
|
||||||
found:
|
found:
|
||||||
udev = testdev_to_usbdev(dev);
|
udev = testdev_to_usbdev(dev);
|
||||||
|
dev->info->alt = alt->desc.bAlternateSetting;
|
||||||
if (alt->desc.bAlternateSetting != 0) {
|
if (alt->desc.bAlternateSetting != 0) {
|
||||||
tmp = usb_set_interface(udev,
|
tmp = usb_set_interface(udev,
|
||||||
alt->desc.bInterfaceNumber,
|
alt->desc.bInterfaceNumber,
|
||||||
@ -2280,7 +2291,7 @@ usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
|||||||
wtest = " intr-out";
|
wtest = " intr-out";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (info->autoconf) {
|
if (override_alt >= 0 || info->autoconf) {
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = get_endpoints(dev, intf);
|
status = get_endpoints(dev, intf);
|
||||||
|
Loading…
Reference in New Issue
Block a user