aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2005-04-22 16:17:00 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-27 17:43:46 -0400
commitff7c79e4f37821235b51fb8e19088c08938cc8fc (patch)
treee874b6f1a68f5538b94bf00afc85014b92486d6f /drivers/usb/misc
parent884b600f63dc7c646f415a5d8f356df1f66ff6f2 (diff)
[PATCH] USB: usbtest updates
Updates to "usbtest" driver: * Improve some diagnostics. One path that never generated diagnostics before should now generate two ... unless you hit a GCC bug that all my compilers seem to have, go figure. * Add suspend/resume support, so this behaves when the Linux host being used for testing suspends. * Don't test the "zero byte ep0 read" case unless real-world relevance for the testing is is irrelevant. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/usbtest.c60
1 files changed, 52 insertions, 8 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 3104f28f6aa8..cda7249a90b2 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -461,7 +461,7 @@ static int perform_sglist (
461 461
462static unsigned realworld = 1; 462static unsigned realworld = 1;
463module_param (realworld, uint, 0); 463module_param (realworld, uint, 0);
464MODULE_PARM_DESC (realworld, "clear to demand stricter ch9 compliance"); 464MODULE_PARM_DESC (realworld, "clear to demand stricter spec compliance");
465 465
466static int get_altsetting (struct usbtest_dev *dev) 466static int get_altsetting (struct usbtest_dev *dev)
467{ 467{
@@ -604,9 +604,8 @@ static int ch9_postconfig (struct usbtest_dev *dev)
604 USB_DIR_IN | USB_RECIP_DEVICE, 604 USB_DIR_IN | USB_RECIP_DEVICE,
605 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); 605 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT);
606 if (retval != 1 || dev->buf [0] != expected) { 606 if (retval != 1 || dev->buf [0] != expected) {
607 dev_dbg (&iface->dev, 607 dev_dbg (&iface->dev, "get config --> %d %d (1 %d)\n",
608 "get config --> %d (%d)\n", retval, 608 retval, dev->buf[0], expected);
609 expected);
610 return (retval < 0) ? retval : -EDOM; 609 return (retval < 0) ? retval : -EDOM;
611 } 610 }
612 } 611 }
@@ -1243,7 +1242,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1243 char *what = "?"; 1242 char *what = "?";
1244 struct usb_device *udev; 1243 struct usb_device *udev;
1245 1244
1246 if (length > 0xffff || vary >= length) 1245 if (length < 1 || length > 0xffff || vary >= length)
1247 return -EINVAL; 1246 return -EINVAL;
1248 1247
1249 buf = kmalloc(length, SLAB_KERNEL); 1248 buf = kmalloc(length, SLAB_KERNEL);
@@ -1266,6 +1265,11 @@ static int ctrl_out (struct usbtest_dev *dev,
1266 0, 0, buf, len, USB_CTRL_SET_TIMEOUT); 1265 0, 0, buf, len, USB_CTRL_SET_TIMEOUT);
1267 if (retval != len) { 1266 if (retval != len) {
1268 what = "write"; 1267 what = "write";
1268 if (retval >= 0) {
1269 INFO(dev, "ctrl_out, wlen %d (expected %d)\n",
1270 retval, len);
1271 retval = -EBADMSG;
1272 }
1269 break; 1273 break;
1270 } 1274 }
1271 1275
@@ -1275,6 +1279,11 @@ static int ctrl_out (struct usbtest_dev *dev,
1275 0, 0, buf, len, USB_CTRL_GET_TIMEOUT); 1279 0, 0, buf, len, USB_CTRL_GET_TIMEOUT);
1276 if (retval != len) { 1280 if (retval != len) {
1277 what = "read"; 1281 what = "read";
1282 if (retval >= 0) {
1283 INFO(dev, "ctrl_out, rlen %d (expected %d)\n",
1284 retval, len);
1285 retval = -EBADMSG;
1286 }
1278 break; 1287 break;
1279 } 1288 }
1280 1289
@@ -1293,8 +1302,13 @@ static int ctrl_out (struct usbtest_dev *dev,
1293 } 1302 }
1294 1303
1295 len += vary; 1304 len += vary;
1305
1306 /* [real world] the "zero bytes IN" case isn't really used.
1307 * hardware can easily trip up in this wierd case, since its
1308 * status stage is IN, not OUT like other ep0in transfers.
1309 */
1296 if (len > length) 1310 if (len > length)
1297 len = 0; 1311 len = realworld ? 1 : 0;
1298 } 1312 }
1299 1313
1300 if (retval < 0) 1314 if (retval < 0)
@@ -1519,6 +1533,11 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1519 if (down_interruptible (&dev->sem)) 1533 if (down_interruptible (&dev->sem))
1520 return -ERESTARTSYS; 1534 return -ERESTARTSYS;
1521 1535
1536 if (intf->dev.power.power_state != PMSG_ON) {
1537 up (&dev->sem);
1538 return -EHOSTUNREACH;
1539 }
1540
1522 /* some devices, like ez-usb default devices, need a non-default 1541 /* some devices, like ez-usb default devices, need a non-default
1523 * altsetting to have any active endpoints. some tests change 1542 * altsetting to have any active endpoints. some tests change
1524 * altsettings; force a default so most tests don't need to check. 1543 * altsettings; force a default so most tests don't need to check.
@@ -1762,8 +1781,10 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
1762 case 14: 1781 case 14:
1763 if (!dev->info->ctrl_out) 1782 if (!dev->info->ctrl_out)
1764 break; 1783 break;
1765 dev_dbg (&intf->dev, "TEST 14: %d ep0out, 0..%d vary %d\n", 1784 dev_dbg (&intf->dev, "TEST 14: %d ep0out, %d..%d vary %d\n",
1766 param->iterations, param->length, param->vary); 1785 param->iterations,
1786 realworld ? 1 : 0, param->length,
1787 param->vary);
1767 retval = ctrl_out (dev, param->iterations, 1788 retval = ctrl_out (dev, param->iterations,
1768 param->length, param->vary); 1789 param->length, param->vary);
1769 break; 1790 break;
@@ -1927,6 +1948,27 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1927 return 0; 1948 return 0;
1928} 1949}
1929 1950
1951static int usbtest_suspend (struct usb_interface *intf, pm_message_t message)
1952{
1953 struct usbtest_dev *dev = usb_get_intfdata (intf);
1954
1955 down (&dev->sem);
1956 intf->dev.power.power_state = PMSG_SUSPEND;
1957 up (&dev->sem);
1958 return 0;
1959}
1960
1961static int usbtest_resume (struct usb_interface *intf)
1962{
1963 struct usbtest_dev *dev = usb_get_intfdata (intf);
1964
1965 down (&dev->sem);
1966 intf->dev.power.power_state = PMSG_ON;
1967 up (&dev->sem);
1968 return 0;
1969}
1970
1971
1930static void usbtest_disconnect (struct usb_interface *intf) 1972static void usbtest_disconnect (struct usb_interface *intf)
1931{ 1973{
1932 struct usbtest_dev *dev = usb_get_intfdata (intf); 1974 struct usbtest_dev *dev = usb_get_intfdata (intf);
@@ -2115,6 +2157,8 @@ static struct usb_driver usbtest_driver = {
2115 .probe = usbtest_probe, 2157 .probe = usbtest_probe,
2116 .ioctl = usbtest_ioctl, 2158 .ioctl = usbtest_ioctl,
2117 .disconnect = usbtest_disconnect, 2159 .disconnect = usbtest_disconnect,
2160 .suspend = usbtest_suspend,
2161 .resume = usbtest_resume,
2118}; 2162};
2119 2163
2120/*-------------------------------------------------------------------------*/ 2164/*-------------------------------------------------------------------------*/