diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-22 20:30:48 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-22 20:30:48 -0700 |
commit | 5cc103506289de7ee0a0b526ae0381541990cad4 (patch) | |
tree | ae8a4958e70c6d1295030b40e333dcc007b3c074 /drivers/usb/misc | |
parent | 73ecf3a6e3f0206bf56a0fefe3b3eda042fb7034 (diff) | |
parent | 92ca0dc5ee022e4c0e488177e1d8865a0778c6c2 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (141 commits)
USB: mct_u232: fix broken close
USB: gadget: amd5536udc.c: fix error path
USB: imx21-hcd - fix off by one resource size calculation
usb: gadget: fix Kconfig warning
usb: r8a66597-udc: Add processing when USB was removed.
mxc_udc: add workaround for ENGcm09152 for i.MX35
USB: ftdi_sio: add device ids for ScienceScope
USB: musb: AM35x: Workaround for fifo read issue
USB: musb: add musb support for AM35x
USB: AM35x: Add musb support
usb: Fix linker errors with CONFIG_PM=n
USB: ohci-sh - use resource_size instead of defining its own resource_len macro
USB: isp1362-hcd - use resource_size instead of defining its own resource_len macro
USB: isp116x-hcd - use resource_size instead of defining its own resource_len macro
USB: xhci: Fix compile error when CONFIG_PM=n
USB: accept some invalid ep0-maxpacket values
USB: xHCI: PCI power management implementation
USB: xHCI: bus power management implementation
USB: xHCI: port remote wakeup implementation
USB: xHCI: port power management implementation
...
Manually fix up (non-data) conflict: the SCSI merge gad renamed the
'hw_sector_size' member to 'physical_block_size', and the USB tree
brought a new use of it.
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r-- | drivers/usb/misc/Kconfig | 13 | ||||
-rw-r--r-- | drivers/usb/misc/Makefile | 45 | ||||
-rw-r--r-- | drivers/usb/misc/ftdi-elan.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/iowarrior.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/sisusbvga/Makefile | 3 | ||||
-rw-r--r-- | drivers/usb/misc/usbtest.c | 667 | ||||
-rw-r--r-- | drivers/usb/misc/yurex.c | 563 |
7 files changed, 944 insertions, 351 deletions
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 55660eaf947..1bfcd02ebeb 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig @@ -231,3 +231,16 @@ config USB_ISIGHTFW driver beforehand. Tools for doing so are available at http://bersace03.free.fr +config USB_YUREX + tristate "USB YUREX driver support" + depends on USB + help + Say Y here if you want to connect a YUREX to your computer's + USB port. The YUREX is a leg-shakes sensor. See + <http://bbu.kayac.com/en/> for further information. + This driver supports read/write of leg-shakes counter and + fasync for the counter update via a device file /dev/yurex*. + + To compile this driver as a module, choose M here: the + module will be called yurex. + diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 717703e8142..796ce7ebccc 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile @@ -3,28 +3,27 @@ # (the ones that don't fit into any other categories) # -obj-$(CONFIG_USB_ADUTUX) += adutux.o -obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o -obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o -obj-$(CONFIG_USB_CYTHERM) += cytherm.o -obj-$(CONFIG_USB_EMI26) += emi26.o -obj-$(CONFIG_USB_EMI62) += emi62.o -obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o -obj-$(CONFIG_USB_IDMOUSE) += idmouse.o -obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o -obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o -obj-$(CONFIG_USB_LCD) += usblcd.o -obj-$(CONFIG_USB_LD) += ldusb.o -obj-$(CONFIG_USB_LED) += usbled.o -obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o -obj-$(CONFIG_USB_RIO500) += rio500.o -obj-$(CONFIG_USB_TEST) += usbtest.o -obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o -obj-$(CONFIG_USB_USS720) += uss720.o -obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o +ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG -obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ +obj-$(CONFIG_USB_ADUTUX) += adutux.o +obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o +obj-$(CONFIG_USB_CYPRESS_CY7C63) += cypress_cy7c63.o +obj-$(CONFIG_USB_CYTHERM) += cytherm.o +obj-$(CONFIG_USB_EMI26) += emi26.o +obj-$(CONFIG_USB_EMI62) += emi62.o +obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o +obj-$(CONFIG_USB_IDMOUSE) += idmouse.o +obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o +obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o +obj-$(CONFIG_USB_LCD) += usblcd.o +obj-$(CONFIG_USB_LD) += ldusb.o +obj-$(CONFIG_USB_LED) += usbled.o +obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o +obj-$(CONFIG_USB_RIO500) += rio500.o +obj-$(CONFIG_USB_TEST) += usbtest.o +obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o +obj-$(CONFIG_USB_USS720) += uss720.o +obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o +obj-$(CONFIG_USB_YUREX) += yurex.o -ifeq ($(CONFIG_USB_DEBUG),y) -EXTRA_CFLAGS += -DDEBUG -endif +obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index aecf380f6ec..c8eec9c2d89 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c @@ -2769,7 +2769,7 @@ static int ftdi_elan_probe(struct usb_interface *interface, ftdi->sequence_num = ++ftdi_instances; mutex_unlock(&ftdi_module_lock); ftdi_elan_init_kref(ftdi); - init_MUTEX(&ftdi->sw_lock); + sema_init(&ftdi->sw_lock, 1); ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); ftdi->interface = interface; mutex_init(&ftdi->u132_lock); diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 9b50db25701..37566419877 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -374,7 +374,7 @@ static ssize_t iowarrior_write(struct file *file, case USB_DEVICE_ID_CODEMERCS_IOWPV2: case USB_DEVICE_ID_CODEMERCS_IOW40: /* IOW24 and IOW40 use a synchronous call */ - buf = kmalloc(8, GFP_KERNEL); /* 8 bytes are enough for both products */ + buf = kmalloc(count, GFP_KERNEL); if (!buf) { retval = -ENOMEM; goto exit; diff --git a/drivers/usb/misc/sisusbvga/Makefile b/drivers/usb/misc/sisusbvga/Makefile index 7f934cfc906..3142476ccc8 100644 --- a/drivers/usb/misc/sisusbvga/Makefile +++ b/drivers/usb/misc/sisusbvga/Makefile @@ -4,5 +4,4 @@ obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga.o -sisusbvga-objs := sisusb.o sisusb_init.o sisusb_con.o - +sisusbvga-y := sisusb.o sisusb_init.o sisusb_con.o diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index eef370eb7a5..a35b427c0ba 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -13,17 +13,16 @@ /*-------------------------------------------------------------------------*/ -// FIXME make these public somewhere; usbdevfs.h? -// +/* FIXME make these public somewhere; usbdevfs.h? */ struct usbtest_param { - // inputs + /* inputs */ unsigned test_num; /* 0..(TEST_CASES-1) */ unsigned iterations; unsigned length; unsigned vary; unsigned sglen; - // outputs + /* outputs */ struct timeval duration; }; #define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param) @@ -45,9 +44,9 @@ struct usbtest_info { const char *name; u8 ep_in; /* bulk/intr source */ u8 ep_out; /* bulk/intr sink */ - unsigned autoconf : 1; - unsigned ctrl_out : 1; - unsigned iso : 1; /* try iso in/out */ + unsigned autoconf:1; + unsigned ctrl_out:1; + unsigned iso:1; /* try iso in/out */ int alt; }; @@ -71,9 +70,9 @@ struct usbtest_dev { u8 *buf; }; -static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test) +static struct usb_device *testdev_to_usbdev(struct usbtest_dev *test) { - return interface_to_usbdev (test->intf); + return interface_to_usbdev(test->intf); } /* set up all urbs so they can be used with either bulk or interrupt */ @@ -87,7 +86,7 @@ static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test) /*-------------------------------------------------------------------------*/ static int -get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf) +get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf) { int tmp; struct usb_host_interface *alt; @@ -115,7 +114,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf) case USB_ENDPOINT_XFER_ISOC: if (dev->info->iso) goto try_iso; - // FALLTHROUGH + /* FALLTHROUGH */ default: continue; } @@ -142,9 +141,9 @@ try_iso: return -EINVAL; found: - udev = testdev_to_usbdev (dev); + udev = testdev_to_usbdev(dev); if (alt->desc.bAlternateSetting != 0) { - tmp = usb_set_interface (udev, + tmp = usb_set_interface(udev, alt->desc.bInterfaceNumber, alt->desc.bAlternateSetting); if (tmp < 0) @@ -152,21 +151,21 @@ found: } if (in) { - dev->in_pipe = usb_rcvbulkpipe (udev, + dev->in_pipe = usb_rcvbulkpipe(udev, in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - dev->out_pipe = usb_sndbulkpipe (udev, + dev->out_pipe = usb_sndbulkpipe(udev, out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); } if (iso_in) { dev->iso_in = &iso_in->desc; - dev->in_iso_pipe = usb_rcvisocpipe (udev, + dev->in_iso_pipe = usb_rcvisocpipe(udev, iso_in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); } if (iso_out) { dev->iso_out = &iso_out->desc; - dev->out_iso_pipe = usb_sndisocpipe (udev, + dev->out_iso_pipe = usb_sndisocpipe(udev, iso_out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); } @@ -182,12 +181,12 @@ found: * them with non-zero test data (or test for it) when appropriate. */ -static void simple_callback (struct urb *urb) +static void simple_callback(struct urb *urb) { complete(urb->context); } -static struct urb *simple_alloc_urb ( +static struct urb *simple_alloc_urb( struct usb_device *udev, int pipe, unsigned long bytes @@ -195,32 +194,32 @@ static struct urb *simple_alloc_urb ( { struct urb *urb; - urb = usb_alloc_urb (0, GFP_KERNEL); + urb = usb_alloc_urb(0, GFP_KERNEL); if (!urb) return urb; - usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL); + usb_fill_bulk_urb(urb, udev, pipe, NULL, bytes, simple_callback, NULL); urb->interval = (udev->speed == USB_SPEED_HIGH) ? (INTERRUPT_RATE << 3) : INTERRUPT_RATE; urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; - if (usb_pipein (pipe)) + if (usb_pipein(pipe)) urb->transfer_flags |= URB_SHORT_NOT_OK; - urb->transfer_buffer = usb_alloc_coherent (udev, bytes, GFP_KERNEL, + urb->transfer_buffer = usb_alloc_coherent(udev, bytes, GFP_KERNEL, &urb->transfer_dma); if (!urb->transfer_buffer) { - usb_free_urb (urb); + usb_free_urb(urb); urb = NULL; } else - memset (urb->transfer_buffer, 0, bytes); + memset(urb->transfer_buffer, 0, bytes); return urb; } -static unsigned pattern = 0; +static unsigned pattern; static unsigned mod_pattern; module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)"); -static inline void simple_fill_buf (struct urb *urb) +static inline void simple_fill_buf(struct urb *urb) { unsigned i; u8 *buf = urb->transfer_buffer; @@ -228,9 +227,9 @@ static inline void simple_fill_buf (struct urb *urb) switch (pattern) { default: - // FALLTHROUGH + /* FALLTHROUGH */ case 0: - memset (buf, 0, len); + memset(buf, 0, len); break; case 1: /* mod63 */ for (i = 0; i < len; i++) @@ -273,14 +272,14 @@ static inline int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb) return 0; } -static void simple_free_urb (struct urb *urb) +static void simple_free_urb(struct urb *urb) { usb_free_coherent(urb->dev, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_dma); - usb_free_urb (urb); + usb_free_urb(urb); } -static int simple_io ( +static int simple_io( struct usbtest_dev *tdev, struct urb *urb, int iterations, @@ -296,17 +295,18 @@ static int simple_io ( urb->context = &completion; while (retval == 0 && iterations-- > 0) { - init_completion (&completion); - if (usb_pipeout (urb->pipe)) - simple_fill_buf (urb); - if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) + init_completion(&completion); + if (usb_pipeout(urb->pipe)) + simple_fill_buf(urb); + retval = usb_submit_urb(urb, GFP_KERNEL); + if (retval != 0) break; /* NOTE: no timeouts; can't be broken out of by interrupt */ - wait_for_completion (&completion); + wait_for_completion(&completion); retval = urb->status; urb->dev = udev; - if (retval == 0 && usb_pipein (urb->pipe)) + if (retval == 0 && usb_pipein(urb->pipe)) retval = simple_check_buf(tdev, urb); if (vary) { @@ -337,7 +337,7 @@ static int simple_io ( * Yes, this also tests the scatterlist primitives. */ -static void free_sglist (struct scatterlist *sg, int nents) +static void free_sglist(struct scatterlist *sg, int nents) { unsigned i; @@ -346,19 +346,19 @@ static void free_sglist (struct scatterlist *sg, int nents) for (i = 0; i < nents; i++) { if (!sg_page(&sg[i])) continue; - kfree (sg_virt(&sg[i])); + kfree(sg_virt(&sg[i])); } - kfree (sg); + kfree(sg); } static struct scatterlist * -alloc_sglist (int nents, int max, int vary) +alloc_sglist(int nents, int max, int vary) { struct scatterlist *sg; unsigned i; unsigned size = max; - sg = kmalloc (nents * sizeof *sg, GFP_KERNEL); + sg = kmalloc(nents * sizeof *sg, GFP_KERNEL); if (!sg) return NULL; sg_init_table(sg, nents); @@ -367,9 +367,9 @@ alloc_sglist (int nents, int max, int vary) char *buf; unsigned j; - buf = kzalloc (size, GFP_KERNEL); + buf = kzalloc(size, GFP_KERNEL); if (!buf) { - free_sglist (sg, i); + free_sglist(sg, i); return NULL; } @@ -397,7 +397,7 @@ alloc_sglist (int nents, int max, int vary) return sg; } -static int perform_sglist ( +static int perform_sglist( struct usbtest_dev *tdev, unsigned iterations, int pipe, @@ -410,7 +410,7 @@ static int perform_sglist ( int retval = 0; while (retval == 0 && iterations-- > 0) { - retval = usb_sg_init (req, udev, pipe, + retval = usb_sg_init(req, udev, pipe, (udev->speed == USB_SPEED_HIGH) ? (INTERRUPT_RATE << 3) : INTERRUPT_RATE, @@ -418,7 +418,7 @@ static int perform_sglist ( if (retval) break; - usb_sg_wait (req); + usb_sg_wait(req); retval = req->status; /* FIXME check resulting data pattern */ @@ -426,9 +426,9 @@ static int perform_sglist ( /* FIXME if endpoint halted, clear halt (and log) */ } - // FIXME for unlink or fault handling tests, don't report - // failure if retval is as we expected ... - + /* FIXME for unlink or fault handling tests, don't report + * failure if retval is as we expected ... + */ if (retval) ERROR(tdev, "perform_sglist failed, " "iterations left %d, status %d\n", @@ -452,31 +452,31 @@ static int perform_sglist ( */ static unsigned realworld = 1; -module_param (realworld, uint, 0); -MODULE_PARM_DESC (realworld, "clear to demand stricter spec compliance"); +module_param(realworld, uint, 0); +MODULE_PARM_DESC(realworld, "clear to demand stricter spec compliance"); -static int get_altsetting (struct usbtest_dev *dev) +static int get_altsetting(struct usbtest_dev *dev) { struct usb_interface *iface = dev->intf; - struct usb_device *udev = interface_to_usbdev (iface); + struct usb_device *udev = interface_to_usbdev(iface); int retval; - retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0), + retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE, - 0, iface->altsetting [0].desc.bInterfaceNumber, + 0, iface->altsetting[0].desc.bInterfaceNumber, dev->buf, 1, USB_CTRL_GET_TIMEOUT); switch (retval) { case 1: - return dev->buf [0]; + return dev->buf[0]; case 0: retval = -ERANGE; - // FALLTHROUGH + /* FALLTHROUGH */ default: return retval; } } -static int set_altsetting (struct usbtest_dev *dev, int alternate) +static int set_altsetting(struct usbtest_dev *dev, int alternate) { struct usb_interface *iface = dev->intf; struct usb_device *udev; @@ -484,9 +484,9 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate) if (alternate < 0 || alternate >= 256) return -EINVAL; - udev = interface_to_usbdev (iface); - return usb_set_interface (udev, - iface->altsetting [0].desc.bInterfaceNumber, + udev = interface_to_usbdev(iface); + return usb_set_interface(udev, + iface->altsetting[0].desc.bInterfaceNumber, alternate); } @@ -519,9 +519,9 @@ static int is_good_config(struct usbtest_dev *tdev, int len) return 0; } - if (le16_to_cpu(config->wTotalLength) == len) /* read it all */ + if (le16_to_cpu(config->wTotalLength) == len) /* read it all */ return 1; - if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ + if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ return 1; ERROR(tdev, "bogus config descriptor read size\n"); return 0; @@ -542,10 +542,10 @@ static int is_good_config(struct usbtest_dev *tdev, int len) * to see if usbcore, hcd, and device all behave right. such testing would * involve varied read sizes and other operation sequences. */ -static int ch9_postconfig (struct usbtest_dev *dev) +static int ch9_postconfig(struct usbtest_dev *dev) { struct usb_interface *iface = dev->intf; - struct usb_device *udev = interface_to_usbdev (iface); + struct usb_device *udev = interface_to_usbdev(iface); int i, alt, retval; /* [9.2.3] if there's more than one altsetting, we need to be able to @@ -554,7 +554,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) for (i = 0; i < iface->num_altsetting; i++) { /* 9.2.3 constrains the range here */ - alt = iface->altsetting [i].desc.bAlternateSetting; + alt = iface->altsetting[i].desc.bAlternateSetting; if (alt < 0 || alt >= iface->num_altsetting) { dev_err(&iface->dev, "invalid alt [%d].bAltSetting = %d\n", @@ -566,7 +566,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) continue; /* [9.4.10] set_interface */ - retval = set_altsetting (dev, alt); + retval = set_altsetting(dev, alt); if (retval) { dev_err(&iface->dev, "can't set_interface = %d, %d\n", alt, retval); @@ -574,7 +574,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) } /* [9.4.4] get_interface always works */ - retval = get_altsetting (dev); + retval = get_altsetting(dev); if (retval != alt) { dev_err(&iface->dev, "get alt should be %d, was %d\n", alt, retval); @@ -591,11 +591,11 @@ static int ch9_postconfig (struct usbtest_dev *dev) * ... although some cheap devices (like one TI Hub I've got) * won't return config descriptors except before set_config. */ - retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0), + retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), USB_REQ_GET_CONFIGURATION, USB_DIR_IN | USB_RECIP_DEVICE, 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); - if (retval != 1 || dev->buf [0] != expected) { + if (retval != 1 || dev->buf[0] != expected) { dev_err(&iface->dev, "get config --> %d %d (1 %d)\n", retval, dev->buf[0], expected); return (retval < 0) ? retval : -EDOM; @@ -603,7 +603,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) } /* there's always [9.4.3] a device descriptor [9.6.1] */ - retval = usb_get_descriptor (udev, USB_DT_DEVICE, 0, + retval = usb_get_descriptor(udev, USB_DT_DEVICE, 0, dev->buf, sizeof udev->descriptor); if (retval != sizeof udev->descriptor) { dev_err(&iface->dev, "dev descriptor --> %d\n", retval); @@ -612,7 +612,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) /* there's always [9.4.3] at least one config descriptor [9.6.3] */ for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { - retval = usb_get_descriptor (udev, USB_DT_CONFIG, i, + retval = usb_get_descriptor(udev, USB_DT_CONFIG, i, dev->buf, TBUF_SIZE); if (!is_good_config(dev, retval)) { dev_err(&iface->dev, @@ -621,18 +621,19 @@ static int ch9_postconfig (struct usbtest_dev *dev) return (retval < 0) ? retval : -EDOM; } - // FIXME cross-checking udev->config[i] to make sure usbcore - // parsed it right (etc) would be good testing paranoia + /* FIXME cross-checking udev->config[i] to make sure usbcore + * parsed it right (etc) would be good testing paranoia + */ } /* and sometimes [9.2.6.6] speed dependent descriptors */ if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) { - struct usb_qualifier_descriptor *d = NULL; + struct usb_qualifier_descriptor *d = NULL; /* device qualifier [9.6.2] */ - retval = usb_get_descriptor (udev, + retval = usb_get_descriptor(udev, USB_DT_DEVICE_QUALIFIER, 0, dev->buf, - sizeof (struct usb_qualifier_descriptor)); + sizeof(struct usb_qualifier_descriptor)); if (retval == -EPIPE) { if (udev->speed == USB_SPEED_HIGH) { dev_err(&iface->dev, @@ -641,7 +642,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) return (retval < 0) ? retval : -EDOM; } /* usb2.0 but not high-speed capable; fine */ - } else if (retval != sizeof (struct usb_qualifier_descriptor)) { + } else if (retval != sizeof(struct usb_qualifier_descriptor)) { dev_err(&iface->dev, "dev qualifier --> %d\n", retval); return (retval < 0) ? retval : -EDOM; } else @@ -651,7 +652,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) if (d) { unsigned max = d->bNumConfigurations; for (i = 0; i < max; i++) { - retval = usb_get_descriptor (udev, + retval = usb_get_descriptor(udev, USB_DT_OTHER_SPEED_CONFIG, i, dev->buf, TBUF_SIZE); if (!is_good_config(dev, retval)) { @@ -663,25 +664,26 @@ static int ch9_postconfig (struct usbtest_dev *dev) } } } - // FIXME fetch strings from at least the device descriptor + /* FIXME fetch strings from at least the device descriptor */ /* [9.4.5] get_status always works */ - retval = usb_get_status (udev, USB_RECIP_DEVICE, 0, dev->buf); + retval = usb_get_status(udev, USB_RECIP_DEVICE, 0, dev->buf); if (retval != 2) { dev_err(&iface->dev, "get dev status --> %d\n", retval); return (retval < 0) ? retval : -EDOM; } - // FIXME configuration.bmAttributes says if we could try to set/clear - // the device's remote wakeup feature ... if we can, test that here + /* FIXME configuration.bmAttributes says if we could try to set/clear + * the device's remote wakeup feature ... if we can, test that here + */ - retval = usb_get_status (udev, USB_RECIP_INTERFACE, - iface->altsetting [0].desc.bInterfaceNumber, dev->buf); + retval = usb_get_status(udev, USB_RECIP_INTERFACE, + iface->altsetting[0].desc.bInterfaceNumber, dev->buf); if (retval != 2) { dev_err(&iface->dev, "get interface status --> %d\n", retval); return (retval < 0) ? retval : -EDOM; } - // FIXME get status for each endpoint in the interface + /* FIXME get status for each endpoint in the interface */ return 0; } @@ -717,7 +719,7 @@ struct subcase { int expected; }; -static void ctrl_complete (struct urb *urb) +static void ctrl_complete(struct urb *urb) { struct ctrl_ctx *ctx = urb->context; struct usb_ctrlrequest *reqp; @@ -725,9 +727,9 @@ static void ctrl_complete (struct urb *urb) int status = urb->status; reqp = (struct usb_ctrlrequest *)urb->setup_packet; - subcase = container_of (reqp, struct subcase, setup); + subcase = container_of(reqp, struct subcase, setup); - spin_lock (&ctx->lock); + spin_lock(&ctx->lock); ctx->count--; ctx->pending--; @@ -787,14 +789,14 @@ error: /* unlink whatever's still pending */ for (i = 1; i < ctx->param->sglen; i++) { - struct urb *u = ctx->urb [ - (i + subcase->number) - % ctx->param->sglen]; + struct urb *u = ctx->urb[ + (i + subcase->number) + % ctx->param->sglen]; if (u == urb || !u->dev) continue; spin_unlock(&ctx->lock); - status = usb_unlink_urb (u); + status = usb_unlink_urb(u); spin_lock(&ctx->lock); switch (status) { case -EINPROGRESS: @@ -812,7 +814,8 @@ error: /* resubmit if we need to, else mark this as done */ if ((status == 0) && (ctx->pending < ctx->count)) { - if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) { + status = usb_submit_urb(urb, GFP_ATOMIC); + if (status != 0) { ERROR(ctx->dev, "can't resubmit ctrl %02x.%02x, err %d\n", reqp->bRequestType, reqp->bRequest, status); @@ -824,21 +827,21 @@ error: /* signal completion when nothing's queued */ if (ctx->pending == 0) - complete (&ctx->complete); - spin_unlock (&ctx->lock); + complete(&ctx->complete); + spin_unlock(&ctx->lock); } static int -test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) +test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param) { - struct usb_device *udev = testdev_to_usbdev (dev); + struct usb_device *udev = testdev_to_usbdev(dev); struct urb **urb; struct ctrl_ctx context; int i; - spin_lock_init (&context.lock); + spin_lock_init(&context.lock); context.dev = dev; - init_completion (&context.complete); + init_completion(&context.complete); context.count = param->sglen * param->iterations; context.pending = 0; context.status = -ENOMEM; @@ -853,7 +856,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) if (!urb) return -ENOMEM; for (i = 0; i < param->sglen; i++) { - int pipe = usb_rcvctrlpipe (udev, 0); + int pipe = usb_rcvctrlpipe(udev, 0); unsigned len; struct urb *u; struct usb_ctrlrequest req; @@ -869,104 +872,108 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) * device, but some are chosen to trigger protocol stalls * or short reads. */ - memset (&req, 0, sizeof req); + memset(&req, 0, sizeof req); req.bRequest = USB_REQ_GET_DESCRIPTOR; req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; switch (i % NUM_SUBCASES) { - case 0: // get device descriptor - req.wValue = cpu_to_le16 (USB_DT_DEVICE << 8); - len = sizeof (struct usb_device_descriptor); + case 0: /* get device descriptor */ + req.wValue = cpu_to_le16(USB_DT_DEVICE << 8); + len = sizeof(struct usb_device_descriptor); break; - case 1: // get first config descriptor (only) - req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); - len = sizeof (struct usb_config_descriptor); + case 1: /* get first config descriptor (only) */ + req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); + len = sizeof(struct usb_config_descriptor); break; - case 2: // get altsetting (OFTEN STALLS) + case 2: /* get altsetting (OFTEN STALLS) */ req.bRequest = USB_REQ_GET_INTERFACE; req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; - // index = 0 means first interface + /* index = 0 means first interface */ len = 1; expected = EPIPE; break; - case 3: // get interface status + case 3: /* get interface status */ req.bRequest = USB_REQ_GET_STATUS; req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; - // interface 0 + /* interface 0 */ len = 2; break; - case 4: // get device status + case 4: /* get device status */ req.bRequest = USB_REQ_GET_STATUS; req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; len = 2; break; - case 5: // get device qualifier (MAY STALL) + case 5: /* get device qualifier (MAY STALL) */ req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8); - len = sizeof (struct usb_qualifier_descriptor); + len = sizeof(struct usb_qualifier_descriptor); if (udev->speed != USB_SPEED_HIGH) expected = EPIPE; break; - case 6: // get first config descriptor, plus interface - req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); - len = sizeof (struct usb_config_descriptor); - len += sizeof (struct usb_interface_descriptor); + case 6: /* get first config descriptor, plus interface */ + req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); + len = sizeof(struct usb_config_descriptor); + len += sizeof(struct usb_interface_descriptor); break; - case 7: // get interface descriptor (ALWAYS STALLS) + case 7: /* get interface descriptor (ALWAYS STALLS) */ req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); - // interface == 0 - len = sizeof (struct usb_interface_descriptor); + /* interface == 0 */ + len = sizeof(struct usb_interface_descriptor); expected = -EPIPE; break; - // NOTE: two consecutive stalls in the queue here. - // that tests fault recovery a bit more aggressively. - case 8: // clear endpoint halt (MAY STALL) + /* NOTE: two consecutive stalls in the queue here. + * that tests fault recovery a bit more aggressively. */ + case 8: /* clear endpoint halt (MAY STALL) */ req.bRequest = USB_REQ_CLEAR_FEATURE; req.bRequestType = USB_RECIP_ENDPOINT; - // wValue 0 == ep halt - // wIndex 0 == ep0 (shouldn't halt!) + /* wValue 0 == ep halt */ + /* wIndex 0 == ep0 (shouldn't halt!) */ len = 0; - pipe = usb_sndctrlpipe (udev, 0); + pipe = usb_sndctrlpipe(udev, 0); expected = EPIPE; break; - case 9: // get endpoint status + case 9: /* get endpoint status */ req.bRequest = USB_REQ_GET_STATUS; req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT; - // endpoint 0 + /* endpoint 0 */ len = 2; break; - case 10: // trigger short read (EREMOTEIO) - req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); + case 10: /* trigger short read (EREMOTEIO) */ + req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); len = 1024; expected = -EREMOTEIO; break; - // NOTE: two consecutive _different_ faults in the queue. - case 11: // get endpoint descriptor (ALWAYS STALLS) - req.wValue = cpu_to_le16 (USB_DT_ENDPOINT << 8); - // endpoint == 0 - len = sizeof (struct usb_interface_descriptor); + /* NOTE: two consecutive _different_ faults in the queue. */ + case 11: /* get endpoint descriptor (ALWAYS STALLS) */ + req.wValue = cpu_to_le16(USB_DT_ENDPOINT << 8); + /* endpoint == 0 */ + len = sizeof(struct usb_interface_descriptor); expected = EPIPE; break; - // NOTE: sometimes even a third fault in the queue! - case 12: // get string 0 descriptor (MAY STALL) - req.wValue = cpu_to_le16 (USB_DT_STRING << 8); - // string == 0, for language IDs - len = sizeof (struct usb_interface_descriptor); - // may succeed when > 4 languages - expected = EREMOTEIO; // or EPIPE, if no strings + /* NOTE: sometimes even a third fault in the queue! */ + case 12: /* get string 0 descriptor (MAY STALL) */ + req.wValue = cpu_to_le16(USB_DT_STRING << 8); + /* string == 0, for language IDs */ + len = sizeof(struct usb_interface_descriptor); + /* may succeed when > 4 languages */ + expected = EREMOTEIO; /* or EPIPE, if no strings */ break; - case 13: // short read, resembling case 10 - req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); - // last data packet "should" be DATA1, not DATA0 + case 13: /* short read, resembling case 10 */ + req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); + /* last data packet "should" be DATA1, not DATA0 */ len = 1024 - udev->descriptor.bMaxPacketSize0; expected = -EREMOTEIO; break; - case 14: // short read; try to fill the last packet - req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0); + case 14: /* short read; try to fill the last packet */ + req.wValue = cpu_to_le16((USB_DT_DEVICE << 8) | 0); /* device descriptor size == 18 bytes */ len = udev->descriptor.bMaxPacketSize0; switch (len) { - case 8: len = 24; break; - case 16: len = 32; break; + case 8: + len = 24; + break; + case 16: + len = 32; + break; } expected = -EREMOTEIO; break; @@ -975,8 +982,8 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) context.status = -EINVAL; goto cleanup; } - req.wLength = cpu_to_le16 (len); - urb [i] = u = simple_alloc_urb (udev, pipe, len); + req.wLength = cpu_to_le16(len); + urb[i] = u = simple_alloc_urb(udev, pipe, len); if (!u) goto cleanup; @@ -994,9 +1001,9 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) /* queue the urbs */ context.urb = urb; - spin_lock_irq (&context.lock); + spin_lock_irq(&context.lock); for (i = 0; i < param->sglen; i++) { - context.status = usb_submit_urb (urb [i], GFP_ATOMIC); + context.status = usb_submit_urb(urb[i], GFP_ATOMIC); if (context.status != 0) { ERROR(dev, "can't submit urb[%d], status %d\n", i, context.status); @@ -1005,23 +1012,23 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) } context.pending++; } - spin_unlock_irq (&context.lock); + spin_unlock_irq(&context.lock); /* FIXME set timer and time out; provide a disconnect hook */ /* wait for the last one to complete */ if (context.pending > 0) - wait_for_completion (&context.complete); + wait_for_completion(&context.complete); cleanup: for (i = 0; i < param->sglen; i++) { - if (!urb [i]) + if (!urb[i]) continue; - urb [i]->dev = udev; + urb[i]->dev = udev; kfree(urb[i]->setup_packet); - simple_free_urb (urb [i]); + simple_free_urb(urb[i]); } - kfree (urb); + kfree(urb); return context.status; } #undef NUM_SUBCASES @@ -1029,27 +1036,27 @@ cleanup: /*-------------------------------------------------------------------------*/ -static void unlink1_callback (struct urb *urb) +static void unlink1_callback(struct urb *urb) { int status = urb->status; - // we "know" -EPIPE (stall) never happens + /* we "know" -EPIPE (stall) never happens */ if (!status) - status = usb_submit_urb (urb, GFP_ATOMIC); + status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { urb->status = status; complete(urb->context); } } |