diff options
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/adutux.c | 3 | ||||
-rw-r--r-- | drivers/usb/misc/appledisplay.c | 1 | ||||
-rw-r--r-- | drivers/usb/misc/cypress_cy7c63.c | 6 | ||||
-rw-r--r-- | drivers/usb/misc/ftdi-elan.c | 7 | ||||
-rw-r--r-- | drivers/usb/misc/idmouse.c | 1 | ||||
-rw-r--r-- | drivers/usb/misc/iowarrior.c | 8 | ||||
-rw-r--r-- | drivers/usb/misc/ldusb.c | 55 | ||||
-rw-r--r-- | drivers/usb/misc/rio500.c | 1 | ||||
-rw-r--r-- | drivers/usb/misc/sisusbvga/Makefile | 3 | ||||
-rw-r--r-- | drivers/usb/misc/sisusbvga/sisusb.c | 1 | ||||
-rw-r--r-- | drivers/usb/misc/trancevibrator.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/usblcd.c | 1 | ||||
-rw-r--r-- | drivers/usb/misc/usbled.c | 122 | ||||
-rw-r--r-- | drivers/usb/misc/usbsevseg.c | 10 | ||||
-rw-r--r-- | drivers/usb/misc/usbtest.c | 1014 | ||||
-rw-r--r-- | drivers/usb/misc/uss720.c | 10 | ||||
-rw-r--r-- | drivers/usb/misc/yurex.c | 564 |
19 files changed, 1433 insertions, 434 deletions
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 55660eaf947c..1bfcd02ebeb5 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
@@ -231,3 +231,16 @@ config USB_ISIGHTFW | |||
231 | driver beforehand. Tools for doing so are available at | 231 | driver beforehand. Tools for doing so are available at |
232 | http://bersace03.free.fr | 232 | http://bersace03.free.fr |
233 | 233 | ||
234 | config USB_YUREX | ||
235 | tristate "USB YUREX driver support" | ||
236 | depends on USB | ||
237 | help | ||
238 | Say Y here if you want to connect a YUREX to your computer's | ||
239 | USB port. The YUREX is a leg-shakes sensor. See | ||
240 | <http://bbu.kayac.com/en/> for further information. | ||
241 | This driver supports read/write of leg-shakes counter and | ||
242 | fasync for the counter update via a device file /dev/yurex*. | ||
243 | |||
244 | To compile this driver as a module, choose M here: the | ||
245 | module will be called yurex. | ||
246 | |||
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 717703e81425..796ce7ebccc8 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile | |||
@@ -3,28 +3,27 @@ | |||
3 | # (the ones that don't fit into any other categories) | 3 | # (the ones that don't fit into any other categories) |
4 | # | 4 | # |
5 | 5 | ||
6 | obj-$(CONFIG_USB_ADUTUX) += adutux.o | 6 | ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG |
7 | obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o | ||
8 | obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o | ||
9 | obj-$(CONFIG_USB_CYTHERM) += cytherm.o | ||
10 | obj-$(CONFIG_USB_EMI26) += emi26.o | ||
11 | obj-$(CONFIG_USB_EMI62) += emi62.o | ||
12 | obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o | ||
13 | obj-$(CONFIG_USB_IDMOUSE) += idmouse.o | ||
14 | obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o | ||
15 | obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o | ||
16 | obj-$(CONFIG_USB_LCD) += usblcd.o | ||
17 | obj-$(CONFIG_USB_LD) += ldusb.o | ||
18 | obj-$(CONFIG_USB_LED) += usbled.o | ||
19 | obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o | ||
20 | obj-$(CONFIG_USB_RIO500) += rio500.o | ||
21 | obj-$(CONFIG_USB_TEST) += usbtest.o | ||
22 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o | ||
23 | obj-$(CONFIG_USB_USS720) += uss720.o | ||
24 | obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o | ||
25 | 7 | ||
26 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ | 8 | obj-$(CONFIG_USB_ADUTUX) += adutux.o |
9 | obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o | ||
10 | obj-$(CONFIG_USB_CYPRESS_CY7C63) += cypress_cy7c63.o | ||
11 | obj-$(CONFIG_USB_CYTHERM) += cytherm.o | ||
12 | obj-$(CONFIG_USB_EMI26) += emi26.o | ||
13 | obj-$(CONFIG_USB_EMI62) += emi62.o | ||
14 | obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o | ||
15 | obj-$(CONFIG_USB_IDMOUSE) += idmouse.o | ||
16 | obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o | ||
17 | obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o | ||
18 | obj-$(CONFIG_USB_LCD) += usblcd.o | ||
19 | obj-$(CONFIG_USB_LD) += ldusb.o | ||
20 | obj-$(CONFIG_USB_LED) += usbled.o | ||
21 | obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o | ||
22 | obj-$(CONFIG_USB_RIO500) += rio500.o | ||
23 | obj-$(CONFIG_USB_TEST) += usbtest.o | ||
24 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o | ||
25 | obj-$(CONFIG_USB_USS720) += uss720.o | ||
26 | obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o | ||
27 | obj-$(CONFIG_USB_YUREX) += yurex.o | ||
27 | 28 | ||
28 | ifeq ($(CONFIG_USB_DEBUG),y) | 29 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ |
29 | EXTRA_CFLAGS += -DDEBUG | ||
30 | endif | ||
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index 801324af9470..a6afd15f6a46 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c | |||
@@ -679,6 +679,7 @@ static const struct file_operations adu_fops = { | |||
679 | .write = adu_write, | 679 | .write = adu_write, |
680 | .open = adu_open, | 680 | .open = adu_open, |
681 | .release = adu_release, | 681 | .release = adu_release, |
682 | .llseek = noop_llseek, | ||
682 | }; | 683 | }; |
683 | 684 | ||
684 | /* | 685 | /* |
@@ -716,7 +717,7 @@ static int adu_probe(struct usb_interface *interface, | |||
716 | goto exit; | 717 | goto exit; |
717 | } | 718 | } |
718 | 719 | ||
719 | /* allocate memory for our device state and intialize it */ | 720 | /* allocate memory for our device state and initialize it */ |
720 | dev = kzalloc(sizeof(struct adu_device), GFP_KERNEL); | 721 | dev = kzalloc(sizeof(struct adu_device), GFP_KERNEL); |
721 | if (dev == NULL) { | 722 | if (dev == NULL) { |
722 | dev_err(&interface->dev, "Out of memory\n"); | 723 | dev_err(&interface->dev, "Out of memory\n"); |
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index 1fa6ce3e4a23..68ab460a735c 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c | |||
@@ -282,6 +282,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
282 | snprintf(bl_name, sizeof(bl_name), "appledisplay%d", | 282 | snprintf(bl_name, sizeof(bl_name), "appledisplay%d", |
283 | atomic_inc_return(&count_displays) - 1); | 283 | atomic_inc_return(&count_displays) - 1); |
284 | memset(&props, 0, sizeof(struct backlight_properties)); | 284 | memset(&props, 0, sizeof(struct backlight_properties)); |
285 | props.type = BACKLIGHT_RAW; | ||
285 | props.max_brightness = 0xff; | 286 | props.max_brightness = 0xff; |
286 | pdata->bd = backlight_device_register(bl_name, NULL, pdata, | 287 | pdata->bd = backlight_device_register(bl_name, NULL, pdata, |
287 | &appledisplay_bl_data, &props); | 288 | &appledisplay_bl_data, &props); |
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index 2f43c57743c9..9251773ecef4 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c | |||
@@ -196,11 +196,9 @@ static ssize_t get_port1_handler(struct device *dev, | |||
196 | return read_port(dev, attr, buf, 1, CYPRESS_READ_PORT_ID1); | 196 | return read_port(dev, attr, buf, 1, CYPRESS_READ_PORT_ID1); |
197 | } | 197 | } |
198 | 198 | ||
199 | static DEVICE_ATTR(port0, S_IWUGO | S_IRUGO, | 199 | static DEVICE_ATTR(port0, S_IRUGO | S_IWUSR, get_port0_handler, set_port0_handler); |
200 | get_port0_handler, set_port0_handler); | ||
201 | 200 | ||
202 | static DEVICE_ATTR(port1, S_IWUGO | S_IRUGO, | 201 | static DEVICE_ATTR(port1, S_IRUGO | S_IWUSR, get_port1_handler, set_port1_handler); |
203 | get_port1_handler, set_port1_handler); | ||
204 | 202 | ||
205 | 203 | ||
206 | static int cypress_probe(struct usb_interface *interface, | 204 | static int cypress_probe(struct usb_interface *interface, |
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index aecf380f6ecc..b16bd3ce3915 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -456,7 +456,6 @@ static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) | |||
456 | static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi) | 456 | static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi) |
457 | { | 457 | { |
458 | ftdi_command_queue_work(ftdi, 0); | 458 | ftdi_command_queue_work(ftdi, 0); |
459 | return; | ||
460 | } | 459 | } |
461 | 460 | ||
462 | static void ftdi_elan_command_work(struct work_struct *work) | 461 | static void ftdi_elan_command_work(struct work_struct *work) |
@@ -483,7 +482,6 @@ static void ftdi_elan_command_work(struct work_struct *work) | |||
483 | static void ftdi_elan_kick_respond_queue(struct usb_ftdi *ftdi) | 482 | static void ftdi_elan_kick_respond_queue(struct usb_ftdi *ftdi) |
484 | { | 483 | { |
485 | ftdi_respond_queue_work(ftdi, 0); | 484 | ftdi_respond_queue_work(ftdi, 0); |
486 | return; | ||
487 | } | 485 | } |
488 | 486 | ||
489 | static void ftdi_elan_respond_work(struct work_struct *work) | 487 | static void ftdi_elan_respond_work(struct work_struct *work) |
@@ -2769,7 +2767,7 @@ static int ftdi_elan_probe(struct usb_interface *interface, | |||
2769 | ftdi->sequence_num = ++ftdi_instances; | 2767 | ftdi->sequence_num = ++ftdi_instances; |
2770 | mutex_unlock(&ftdi_module_lock); | 2768 | mutex_unlock(&ftdi_module_lock); |
2771 | ftdi_elan_init_kref(ftdi); | 2769 | ftdi_elan_init_kref(ftdi); |
2772 | init_MUTEX(&ftdi->sw_lock); | 2770 | sema_init(&ftdi->sw_lock, 1); |
2773 | ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); | 2771 | ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); |
2774 | ftdi->interface = interface; | 2772 | ftdi->interface = interface; |
2775 | mutex_init(&ftdi->u132_lock); | 2773 | mutex_init(&ftdi->u132_lock); |
@@ -2891,8 +2889,7 @@ static struct usb_driver ftdi_elan_driver = { | |||
2891 | static int __init ftdi_elan_init(void) | 2889 | static int __init ftdi_elan_init(void) |
2892 | { | 2890 | { |
2893 | int result; | 2891 | int result; |
2894 | printk(KERN_INFO "driver %s built at %s on %s\n", ftdi_elan_driver.name, | 2892 | printk(KERN_INFO "driver %s\n", ftdi_elan_driver.name); |
2895 | __TIME__, __DATE__); | ||
2896 | mutex_init(&ftdi_module_lock); | 2893 | mutex_init(&ftdi_module_lock); |
2897 | INIT_LIST_HEAD(&ftdi_static_list); | 2894 | INIT_LIST_HEAD(&ftdi_static_list); |
2898 | status_queue = create_singlethread_workqueue("ftdi-status-control"); | 2895 | status_queue = create_singlethread_workqueue("ftdi-status-control"); |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index a54c3cb804ce..c6184b4d1695 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -105,6 +105,7 @@ static const struct file_operations idmouse_fops = { | |||
105 | .read = idmouse_read, | 105 | .read = idmouse_read, |
106 | .open = idmouse_open, | 106 | .open = idmouse_open, |
107 | .release = idmouse_release, | 107 | .release = idmouse_release, |
108 | .llseek = default_llseek, | ||
108 | }; | 109 | }; |
109 | 110 | ||
110 | /* class driver information */ | 111 | /* class driver information */ |
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index bc88c79875a1..a2190b983f52 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #ifdef CONFIG_USB_DYNAMIC_MINORS | 40 | #ifdef CONFIG_USB_DYNAMIC_MINORS |
41 | #define IOWARRIOR_MINOR_BASE 0 | 41 | #define IOWARRIOR_MINOR_BASE 0 |
42 | #else | 42 | #else |
43 | #define IOWARRIOR_MINOR_BASE 208 // SKELETON_MINOR_BASE 192 + 16, not offical yet | 43 | #define IOWARRIOR_MINOR_BASE 208 // SKELETON_MINOR_BASE 192 + 16, not official yet |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | /* interrupt input queue size */ | 46 | /* interrupt input queue size */ |
@@ -374,7 +374,7 @@ static ssize_t iowarrior_write(struct file *file, | |||
374 | case USB_DEVICE_ID_CODEMERCS_IOWPV2: | 374 | case USB_DEVICE_ID_CODEMERCS_IOWPV2: |
375 | case USB_DEVICE_ID_CODEMERCS_IOW40: | 375 | case USB_DEVICE_ID_CODEMERCS_IOW40: |
376 | /* IOW24 and IOW40 use a synchronous call */ | 376 | /* IOW24 and IOW40 use a synchronous call */ |
377 | buf = kmalloc(8, GFP_KERNEL); /* 8 bytes are enough for both products */ | 377 | buf = kmalloc(count, GFP_KERNEL); |
378 | if (!buf) { | 378 | if (!buf) { |
379 | retval = -ENOMEM; | 379 | retval = -ENOMEM; |
380 | goto exit; | 380 | goto exit; |
@@ -553,6 +553,7 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd, | |||
553 | /* needed for power consumption */ | 553 | /* needed for power consumption */ |
554 | struct usb_config_descriptor *cfg_descriptor = &dev->udev->actconfig->desc; | 554 | struct usb_config_descriptor *cfg_descriptor = &dev->udev->actconfig->desc; |
555 | 555 | ||
556 | memset(&info, 0, sizeof(info)); | ||
556 | /* directly from the descriptor */ | 557 | /* directly from the descriptor */ |
557 | info.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); | 558 | info.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); |
558 | info.product = dev->product_id; | 559 | info.product = dev->product_id; |
@@ -730,6 +731,7 @@ static const struct file_operations iowarrior_fops = { | |||
730 | .open = iowarrior_open, | 731 | .open = iowarrior_open, |
731 | .release = iowarrior_release, | 732 | .release = iowarrior_release, |
732 | .poll = iowarrior_poll, | 733 | .poll = iowarrior_poll, |
734 | .llseek = noop_llseek, | ||
733 | }; | 735 | }; |
734 | 736 | ||
735 | static char *iowarrior_devnode(struct device *dev, mode_t *mode) | 737 | static char *iowarrior_devnode(struct device *dev, mode_t *mode) |
@@ -767,7 +769,7 @@ static int iowarrior_probe(struct usb_interface *interface, | |||
767 | int i; | 769 | int i; |
768 | int retval = -ENOMEM; | 770 | int retval = -ENOMEM; |
769 | 771 | ||
770 | /* allocate memory for our device state and intialize it */ | 772 | /* allocate memory for our device state and initialize it */ |
771 | dev = kzalloc(sizeof(struct iowarrior), GFP_KERNEL); | 773 | dev = kzalloc(sizeof(struct iowarrior), GFP_KERNEL); |
772 | if (dev == NULL) { | 774 | if (dev == NULL) { |
773 | dev_err(&interface->dev, "Out of memory\n"); | 775 | dev_err(&interface->dev, "Out of memory\n"); |
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index dd41d8710043..cb4096201e29 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
@@ -20,11 +20,6 @@ | |||
20 | * Derived from Lego USB Tower driver | 20 | * Derived from Lego USB Tower driver |
21 | * Copyright (C) 2003 David Glance <advidgsf@sourceforge.net> | 21 | * Copyright (C) 2003 David Glance <advidgsf@sourceforge.net> |
22 | * 2001-2004 Juergen Stuber <starblue@users.sourceforge.net> | 22 | * 2001-2004 Juergen Stuber <starblue@users.sourceforge.net> |
23 | * | ||
24 | * V0.1 (mh) Initial version | ||
25 | * V0.11 (mh) Added raw support for HID 1.0 devices (no interrupt out endpoint) | ||
26 | * V0.12 (mh) Added kmalloc check for string buffer | ||
27 | * V0.13 (mh) Added support for LD X-Ray and Machine Test System | ||
28 | */ | 23 | */ |
29 | 24 | ||
30 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
@@ -41,20 +36,39 @@ | |||
41 | 36 | ||
42 | /* Define these values to match your devices */ | 37 | /* Define these values to match your devices */ |
43 | #define USB_VENDOR_ID_LD 0x0f11 /* USB Vendor ID of LD Didactic GmbH */ | 38 | #define USB_VENDOR_ID_LD 0x0f11 /* USB Vendor ID of LD Didactic GmbH */ |
44 | #define USB_DEVICE_ID_LD_CASSY 0x1000 /* USB Product ID of CASSY-S */ | 39 | #define USB_DEVICE_ID_LD_CASSY 0x1000 /* USB Product ID of CASSY-S modules with 8 bytes endpoint size */ |
40 | #define USB_DEVICE_ID_LD_CASSY2 0x1001 /* USB Product ID of CASSY-S modules with 64 bytes endpoint size */ | ||
45 | #define USB_DEVICE_ID_LD_POCKETCASSY 0x1010 /* USB Product ID of Pocket-CASSY */ | 41 | #define USB_DEVICE_ID_LD_POCKETCASSY 0x1010 /* USB Product ID of Pocket-CASSY */ |
42 | #define USB_DEVICE_ID_LD_POCKETCASSY2 0x1011 /* USB Product ID of Pocket-CASSY 2 (reserved) */ | ||
46 | #define USB_DEVICE_ID_LD_MOBILECASSY 0x1020 /* USB Product ID of Mobile-CASSY */ | 43 | #define USB_DEVICE_ID_LD_MOBILECASSY 0x1020 /* USB Product ID of Mobile-CASSY */ |
44 | #define USB_DEVICE_ID_LD_MOBILECASSY2 0x1021 /* USB Product ID of Mobile-CASSY 2 (reserved) */ | ||
45 | #define USB_DEVICE_ID_LD_MICROCASSYVOLTAGE 0x1031 /* USB Product ID of Micro-CASSY Voltage */ | ||
46 | #define USB_DEVICE_ID_LD_MICROCASSYCURRENT 0x1032 /* USB Product ID of Micro-CASSY Current */ | ||
47 | #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 /* USB Product ID of Micro-CASSY Time (reserved) */ | ||
48 | #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 /* USB Product ID of Micro-CASSY Temperature */ | ||
49 | #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 /* USB Product ID of Micro-CASSY pH */ | ||
47 | #define USB_DEVICE_ID_LD_JWM 0x1080 /* USB Product ID of Joule and Wattmeter */ | 50 | #define USB_DEVICE_ID_LD_JWM 0x1080 /* USB Product ID of Joule and Wattmeter */ |
48 | #define USB_DEVICE_ID_LD_DMMP 0x1081 /* USB Product ID of Digital Multimeter P (reserved) */ | 51 | #define USB_DEVICE_ID_LD_DMMP 0x1081 /* USB Product ID of Digital Multimeter P (reserved) */ |
49 | #define USB_DEVICE_ID_LD_UMIP 0x1090 /* USB Product ID of UMI P */ | 52 | #define USB_DEVICE_ID_LD_UMIP 0x1090 /* USB Product ID of UMI P */ |
50 | #define USB_DEVICE_ID_LD_XRAY1 0x1100 /* USB Product ID of X-Ray Apparatus */ | 53 | #define USB_DEVICE_ID_LD_UMIC 0x10A0 /* USB Product ID of UMI C */ |
51 | #define USB_DEVICE_ID_LD_XRAY2 0x1101 /* USB Product ID of X-Ray Apparatus */ | 54 | #define USB_DEVICE_ID_LD_UMIB 0x10B0 /* USB Product ID of UMI B */ |
55 | #define USB_DEVICE_ID_LD_XRAY 0x1100 /* USB Product ID of X-Ray Apparatus 55481 */ | ||
56 | #define USB_DEVICE_ID_LD_XRAY2 0x1101 /* USB Product ID of X-Ray Apparatus 554800 */ | ||
57 | #define USB_DEVICE_ID_LD_XRAYCT 0x1110 /* USB Product ID of X-Ray Apparatus CT 554821*/ | ||
52 | #define USB_DEVICE_ID_LD_VIDEOCOM 0x1200 /* USB Product ID of VideoCom */ | 58 | #define USB_DEVICE_ID_LD_VIDEOCOM 0x1200 /* USB Product ID of VideoCom */ |
59 | #define USB_DEVICE_ID_LD_MOTOR 0x1210 /* USB Product ID of Motor (reserved) */ | ||
53 | #define USB_DEVICE_ID_LD_COM3LAB 0x2000 /* USB Product ID of COM3LAB */ | 60 | #define USB_DEVICE_ID_LD_COM3LAB 0x2000 /* USB Product ID of COM3LAB */ |
54 | #define USB_DEVICE_ID_LD_TELEPORT 0x2010 /* USB Product ID of Terminal Adapter */ | 61 | #define USB_DEVICE_ID_LD_TELEPORT 0x2010 /* USB Product ID of Terminal Adapter */ |
55 | #define USB_DEVICE_ID_LD_NETWORKANALYSER 0x2020 /* USB Product ID of Network Analyser */ | 62 | #define USB_DEVICE_ID_LD_NETWORKANALYSER 0x2020 /* USB Product ID of Network Analyser */ |
56 | #define USB_DEVICE_ID_LD_POWERCONTROL 0x2030 /* USB Product ID of Converter Control Unit */ | 63 | #define USB_DEVICE_ID_LD_POWERCONTROL 0x2030 /* USB Product ID of Converter Control Unit */ |
57 | #define USB_DEVICE_ID_LD_MACHINETEST 0x2040 /* USB Product ID of Machine Test System */ | 64 | #define USB_DEVICE_ID_LD_MACHINETEST 0x2040 /* USB Product ID of Machine Test System */ |
65 | #define USB_DEVICE_ID_LD_MOSTANALYSER 0x2050 /* USB Product ID of MOST Protocol Analyser */ | ||
66 | #define USB_DEVICE_ID_LD_MOSTANALYSER2 0x2051 /* USB Product ID of MOST Protocol Analyser 2 */ | ||
67 | #define USB_DEVICE_ID_LD_ABSESP 0x2060 /* USB Product ID of ABS ESP */ | ||
68 | #define USB_DEVICE_ID_LD_AUTODATABUS 0x2070 /* USB Product ID of Automotive Data Buses */ | ||
69 | #define USB_DEVICE_ID_LD_MCT 0x2080 /* USB Product ID of Microcontroller technique */ | ||
70 | #define USB_DEVICE_ID_LD_HYBRID 0x2090 /* USB Product ID of Automotive Hybrid */ | ||
71 | #define USB_DEVICE_ID_LD_HEATCONTROL 0x20A0 /* USB Product ID of Heat control */ | ||
58 | 72 | ||
59 | #define USB_VENDOR_ID_VERNIER 0x08f7 | 73 | #define USB_VENDOR_ID_VERNIER 0x08f7 |
60 | #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 | 74 | #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 |
@@ -71,19 +85,37 @@ | |||
71 | /* table of devices that work with this driver */ | 85 | /* table of devices that work with this driver */ |
72 | static const struct usb_device_id ld_usb_table[] = { | 86 | static const struct usb_device_id ld_usb_table[] = { |
73 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, | 87 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, |
88 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) }, | ||
74 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, | 89 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, |
90 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) }, | ||
75 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, | 91 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, |
92 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) }, | ||
93 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) }, | ||
94 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) }, | ||
95 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, | ||
96 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, | ||
97 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, | ||
76 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, | 98 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, |
77 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, | 99 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, |
78 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, | 100 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, |
79 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1) }, | 101 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) }, |
102 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) }, | ||
103 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) }, | ||
80 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, | 104 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, |
81 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, | 105 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, |
106 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) }, | ||
82 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, | 107 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, |
83 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, | 108 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, |
84 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, | 109 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, |
85 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, | 110 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, |
86 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, | 111 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, |
112 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) }, | ||
113 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) }, | ||
114 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) }, | ||
115 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) }, | ||
116 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) }, | ||
117 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) }, | ||
118 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) }, | ||
87 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, | 119 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, |
88 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, | 120 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, |
89 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, | 121 | { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, |
@@ -91,7 +123,7 @@ static const struct usb_device_id ld_usb_table[] = { | |||
91 | { } /* Terminating entry */ | 123 | { } /* Terminating entry */ |
92 | }; | 124 | }; |
93 | MODULE_DEVICE_TABLE(usb, ld_usb_table); | 125 | MODULE_DEVICE_TABLE(usb, ld_usb_table); |
94 | MODULE_VERSION("V0.13"); | 126 | MODULE_VERSION("V0.14"); |
95 | MODULE_AUTHOR("Michael Hund <mhund@ld-didactic.de>"); | 127 | MODULE_AUTHOR("Michael Hund <mhund@ld-didactic.de>"); |
96 | MODULE_DESCRIPTION("LD USB Driver"); | 128 | MODULE_DESCRIPTION("LD USB Driver"); |
97 | MODULE_LICENSE("GPL"); | 129 | MODULE_LICENSE("GPL"); |
@@ -613,6 +645,7 @@ static const struct file_operations ld_usb_fops = { | |||
613 | .open = ld_usb_open, | 645 | .open = ld_usb_open, |
614 | .release = ld_usb_release, | 646 | .release = ld_usb_release, |
615 | .poll = ld_usb_poll, | 647 | .poll = ld_usb_poll, |
648 | .llseek = no_llseek, | ||
616 | }; | 649 | }; |
617 | 650 | ||
618 | /* | 651 | /* |
@@ -641,7 +674,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * | |||
641 | int i; | 674 | int i; |
642 | int retval = -ENOMEM; | 675 | int retval = -ENOMEM; |
643 | 676 | ||
644 | /* allocate memory for our device state and intialize it */ | 677 | /* allocate memory for our device state and initialize it */ |
645 | 678 | ||
646 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 679 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
647 | if (dev == NULL) { | 680 | if (dev == NULL) { |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index cc13ae61712a..4e23d3841b43 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -439,6 +439,7 @@ static const struct file_operations usb_rio_fops = { | |||
439 | .unlocked_ioctl = ioctl_rio, | 439 | .unlocked_ioctl = ioctl_rio, |
440 | .open = open_rio, | 440 | .open = open_rio, |
441 | .release = close_rio, | 441 | .release = close_rio, |
442 | .llseek = noop_llseek, | ||
442 | }; | 443 | }; |
443 | 444 | ||
444 | static struct usb_class_driver usb_rio_class = { | 445 | static struct usb_class_driver usb_rio_class = { |
diff --git a/drivers/usb/misc/sisusbvga/Makefile b/drivers/usb/misc/sisusbvga/Makefile index 7f934cfc906c..3142476ccc8e 100644 --- a/drivers/usb/misc/sisusbvga/Makefile +++ b/drivers/usb/misc/sisusbvga/Makefile | |||
@@ -4,5 +4,4 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga.o | 5 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga.o |
6 | 6 | ||
7 | sisusbvga-objs := sisusb.o sisusb_init.o sisusb_con.o | 7 | sisusbvga-y := sisusb.o sisusb_init.o sisusb_con.o |
8 | |||
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 70d00e99a4b4..dd573abd2d1e 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -3008,6 +3008,7 @@ sisusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
3008 | #else | 3008 | #else |
3009 | x.sisusb_conactive = 0; | 3009 | x.sisusb_conactive = 0; |
3010 | #endif | 3010 | #endif |
3011 | memset(x.sisusb_reserved, 0, sizeof(x.sisusb_reserved)); | ||
3011 | 3012 | ||
3012 | if (copy_to_user((void __user *)arg, &x, sizeof(x))) | 3013 | if (copy_to_user((void __user *)arg, &x, sizeof(x))) |
3013 | retval = -EFAULT; | 3014 | retval = -EFAULT; |
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index d77aba46ae85..f63776a48e2a 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c | |||
@@ -86,7 +86,7 @@ static ssize_t set_speed(struct device *dev, struct device_attribute *attr, | |||
86 | return count; | 86 | return count; |
87 | } | 87 | } |
88 | 88 | ||
89 | static DEVICE_ATTR(speed, S_IWUGO | S_IRUGO, show_speed, set_speed); | 89 | static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR, show_speed, set_speed); |
90 | 90 | ||
91 | static int tv_probe(struct usb_interface *interface, | 91 | static int tv_probe(struct usb_interface *interface, |
92 | const struct usb_device_id *id) | 92 | const struct usb_device_id *id) |
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index d00dde19194c..51648154bb44 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -282,6 +282,7 @@ static const struct file_operations lcd_fops = { | |||
282 | .open = lcd_open, | 282 | .open = lcd_open, |
283 | .unlocked_ioctl = lcd_ioctl, | 283 | .unlocked_ioctl = lcd_ioctl, |
284 | .release = lcd_release, | 284 | .release = lcd_release, |
285 | .llseek = noop_llseek, | ||
285 | }; | 286 | }; |
286 | 287 | ||
287 | /* | 288 | /* |
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c index 63da2c3c838f..1616ad1793a4 100644 --- a/drivers/usb/misc/usbled.c +++ b/drivers/usb/misc/usbled.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * USB LED driver - 1.1 | 2 | * USB LED driver |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Greg Kroah-Hartman (greg@kroah.com) | 4 | * Copyright (C) 2004 Greg Kroah-Hartman (greg@kroah.com) |
5 | * | 5 | * |
@@ -20,12 +20,17 @@ | |||
20 | #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com" | 20 | #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com" |
21 | #define DRIVER_DESC "USB LED Driver" | 21 | #define DRIVER_DESC "USB LED Driver" |
22 | 22 | ||
23 | #define VENDOR_ID 0x0fc5 | 23 | enum led_type { |
24 | #define PRODUCT_ID 0x1223 | 24 | DELCOM_VISUAL_SIGNAL_INDICATOR, |
25 | DREAM_CHEEKY_WEBMAIL_NOTIFIER, | ||
26 | }; | ||
25 | 27 | ||
26 | /* table of devices that work with this driver */ | 28 | /* table of devices that work with this driver */ |
27 | static const struct usb_device_id id_table[] = { | 29 | static const struct usb_device_id id_table[] = { |
28 | { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, | 30 | { USB_DEVICE(0x0fc5, 0x1223), |
31 | .driver_info = DELCOM_VISUAL_SIGNAL_INDICATOR }, | ||
32 | { USB_DEVICE(0x1d34, 0x0004), | ||
33 | .driver_info = DREAM_CHEEKY_WEBMAIL_NOTIFIER }, | ||
29 | { }, | 34 | { }, |
30 | }; | 35 | }; |
31 | MODULE_DEVICE_TABLE (usb, id_table); | 36 | MODULE_DEVICE_TABLE (usb, id_table); |
@@ -35,15 +40,12 @@ struct usb_led { | |||
35 | unsigned char blue; | 40 | unsigned char blue; |
36 | unsigned char red; | 41 | unsigned char red; |
37 | unsigned char green; | 42 | unsigned char green; |
43 | enum led_type type; | ||
38 | }; | 44 | }; |
39 | 45 | ||
40 | #define BLUE 0x04 | ||
41 | #define RED 0x02 | ||
42 | #define GREEN 0x01 | ||
43 | static void change_color(struct usb_led *led) | 46 | static void change_color(struct usb_led *led) |
44 | { | 47 | { |
45 | int retval; | 48 | int retval = 0; |
46 | unsigned char color = 0x07; | ||
47 | unsigned char *buffer; | 49 | unsigned char *buffer; |
48 | 50 | ||
49 | buffer = kmalloc(8, GFP_KERNEL); | 51 | buffer = kmalloc(8, GFP_KERNEL); |
@@ -52,25 +54,59 @@ static void change_color(struct usb_led *led) | |||
52 | return; | 54 | return; |
53 | } | 55 | } |
54 | 56 | ||
55 | if (led->blue) | 57 | switch (led->type) { |
56 | color &= ~(BLUE); | 58 | case DELCOM_VISUAL_SIGNAL_INDICATOR: { |
57 | if (led->red) | 59 | unsigned char color = 0x07; |
58 | color &= ~(RED); | 60 | |
59 | if (led->green) | 61 | if (led->blue) |
60 | color &= ~(GREEN); | 62 | color &= ~0x04; |
61 | dev_dbg(&led->udev->dev, | 63 | if (led->red) |
62 | "blue = %d, red = %d, green = %d, color = %.2x\n", | 64 | color &= ~0x02; |
63 | led->blue, led->red, led->green, color); | 65 | if (led->green) |
64 | 66 | color &= ~0x01; | |
65 | retval = usb_control_msg(led->udev, | 67 | dev_dbg(&led->udev->dev, |
66 | usb_sndctrlpipe(led->udev, 0), | 68 | "blue = %d, red = %d, green = %d, color = %.2x\n", |
67 | 0x12, | 69 | led->blue, led->red, led->green, color); |
68 | 0xc8, | 70 | |
69 | (0x02 * 0x100) + 0x0a, | 71 | retval = usb_control_msg(led->udev, |
70 | (0x00 * 0x100) + color, | 72 | usb_sndctrlpipe(led->udev, 0), |
71 | buffer, | 73 | 0x12, |
72 | 8, | 74 | 0xc8, |
73 | 2000); | 75 | (0x02 * 0x100) + 0x0a, |
76 | (0x00 * 0x100) + color, | ||
77 | buffer, | ||
78 | 8, | ||
79 | 2000); | ||
80 | break; | ||
81 | } | ||
82 | |||
83 | case DREAM_CHEEKY_WEBMAIL_NOTIFIER: | ||
84 | dev_dbg(&led->udev->dev, | ||
85 | "red = %d, green = %d, blue = %d\n", | ||
86 | led->red, led->green, led->blue); | ||
87 | |||
88 | buffer[0] = led->red; | ||
89 | buffer[1] = led->green; | ||
90 | buffer[2] = led->blue; | ||
91 | buffer[3] = buffer[4] = buffer[5] = 0; | ||
92 | buffer[6] = 0x1a; | ||
93 | buffer[7] = 0x05; | ||
94 | |||
95 | retval = usb_control_msg(led->udev, | ||
96 | usb_sndctrlpipe(led->udev, 0), | ||
97 | 0x09, | ||
98 | 0x21, | ||
99 | 0x200, | ||
100 | 0, | ||
101 | buffer, | ||
102 | 8, | ||
103 | 2000); | ||
104 | break; | ||
105 | |||
106 | default: | ||
107 | dev_err(&led->udev->dev, "unknown device type %d\n", led->type); | ||
108 | } | ||
109 | |||
74 | if (retval) | 110 | if (retval) |
75 | dev_dbg(&led->udev->dev, "retval = %d\n", retval); | 111 | dev_dbg(&led->udev->dev, "retval = %d\n", retval); |
76 | kfree(buffer); | 112 | kfree(buffer); |
@@ -94,7 +130,7 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co | |||
94 | change_color(led); \ | 130 | change_color(led); \ |
95 | return count; \ | 131 | return count; \ |
96 | } \ | 132 | } \ |
97 | static DEVICE_ATTR(value, S_IWUGO | S_IRUGO, show_##value, set_##value); | 133 | static DEVICE_ATTR(value, S_IRUGO | S_IWUSR, show_##value, set_##value); |
98 | show_set(blue); | 134 | show_set(blue); |
99 | show_set(red); | 135 | show_set(red); |
100 | show_set(green); | 136 | show_set(green); |
@@ -107,11 +143,12 @@ static int led_probe(struct usb_interface *interface, const struct usb_device_id | |||
107 | 143 | ||
108 | dev = kzalloc(sizeof(struct usb_led), GFP_KERNEL); | 144 | dev = kzalloc(sizeof(struct usb_led), GFP_KERNEL); |
109 | if (dev == NULL) { | 145 | if (dev == NULL) { |
110 | dev_err(&interface->dev, "Out of memory\n"); | 146 | dev_err(&interface->dev, "out of memory\n"); |
111 | goto error_mem; | 147 | goto error_mem; |
112 | } | 148 | } |
113 | 149 | ||
114 | dev->udev = usb_get_dev(udev); | 150 | dev->udev = usb_get_dev(udev); |
151 | dev->type = id->driver_info; | ||
115 | 152 | ||
116 | usb_set_intfdata (interface, dev); | 153 | usb_set_intfdata (interface, dev); |
117 | 154 | ||
@@ -125,6 +162,31 @@ static int led_probe(struct usb_interface *interface, const struct usb_device_id | |||
125 | if (retval) | 162 | if (retval) |
126 | goto error; | 163 | goto error; |
127 | 164 | ||
165 | if (dev->type == DREAM_CHEEKY_WEBMAIL_NOTIFIER) { | ||
166 | unsigned char *enable; | ||
167 | |||
168 | enable = kmemdup("\x1f\x02\0\x5f\0\0\x1a\x03", 8, GFP_KERNEL); | ||
169 | if (!enable) { | ||
170 | dev_err(&interface->dev, "out of memory\n"); | ||
171 | retval = -ENOMEM; | ||
172 | goto error; | ||
173 | } | ||
174 | |||
175 | retval = usb_control_msg(udev, | ||
176 | usb_sndctrlpipe(udev, 0), | ||
177 | 0x09, | ||
178 | 0x21, | ||
179 | 0x200, | ||
180 | 0, | ||
181 | enable, | ||
182 | 8, | ||
183 | 2000); | ||
184 | |||
185 | kfree(enable); | ||
186 | if (retval != 8) | ||
187 | goto error; | ||
188 | } | ||
189 | |||
128 | dev_info(&interface->dev, "USB LED device now attached\n"); | 190 | dev_info(&interface->dev, "USB LED device now attached\n"); |
129 | return 0; | 191 | return 0; |
130 | 192 | ||
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c index de8ef945b536..417b8f207e8b 100644 --- a/drivers/usb/misc/usbsevseg.c +++ b/drivers/usb/misc/usbsevseg.c | |||
@@ -192,7 +192,7 @@ static ssize_t set_attr_##name(struct device *dev, \ | |||
192 | \ | 192 | \ |
193 | return count; \ | 193 | return count; \ |
194 | } \ | 194 | } \ |
195 | static DEVICE_ATTR(name, S_IWUGO | S_IRUGO, show_attr_##name, set_attr_##name); | 195 | static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_attr_##name, set_attr_##name); |
196 | 196 | ||
197 | static ssize_t show_attr_text(struct device *dev, | 197 | static ssize_t show_attr_text(struct device *dev, |
198 | struct device_attribute *attr, char *buf) | 198 | struct device_attribute *attr, char *buf) |
@@ -223,7 +223,7 @@ static ssize_t set_attr_text(struct device *dev, | |||
223 | return count; | 223 | return count; |
224 | } | 224 | } |
225 | 225 | ||
226 | static DEVICE_ATTR(text, S_IWUGO | S_IRUGO, show_attr_text, set_attr_text); | 226 | static DEVICE_ATTR(text, S_IRUGO | S_IWUSR, show_attr_text, set_attr_text); |
227 | 227 | ||
228 | static ssize_t show_attr_decimals(struct device *dev, | 228 | static ssize_t show_attr_decimals(struct device *dev, |
229 | struct device_attribute *attr, char *buf) | 229 | struct device_attribute *attr, char *buf) |
@@ -272,8 +272,7 @@ static ssize_t set_attr_decimals(struct device *dev, | |||
272 | return count; | 272 | return count; |
273 | } | 273 | } |
274 | 274 | ||
275 | static DEVICE_ATTR(decimals, S_IWUGO | S_IRUGO, | 275 | static DEVICE_ATTR(decimals, S_IRUGO | S_IWUSR, show_attr_decimals, set_attr_decimals); |
276 | show_attr_decimals, set_attr_decimals); | ||
277 | 276 | ||
278 | static ssize_t show_attr_textmode(struct device *dev, | 277 | static ssize_t show_attr_textmode(struct device *dev, |
279 | struct device_attribute *attr, char *buf) | 278 | struct device_attribute *attr, char *buf) |
@@ -319,8 +318,7 @@ static ssize_t set_attr_textmode(struct device *dev, | |||
319 | return -EINVAL; | 318 | return -EINVAL; |
320 | } | 319 | } |
321 | 320 | ||
322 | static DEVICE_ATTR(textmode, S_IWUGO | S_IRUGO, | 321 | static DEVICE_ATTR(textmode, S_IRUGO | S_IWUSR, show_attr_textmode, set_attr_textmode); |
323 | show_attr_textmode, set_attr_textmode); | ||
324 | 322 | ||
325 | 323 | ||
326 | MYDEV_ATTR_SIMPLE_UNSIGNED(powered, update_display_powered); | 324 | MYDEV_ATTR_SIMPLE_UNSIGNED(powered, update_display_powered); |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index eef370eb7a54..bb10846affc3 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -13,17 +13,16 @@ | |||
13 | 13 | ||
14 | /*-------------------------------------------------------------------------*/ | 14 | /*-------------------------------------------------------------------------*/ |
15 | 15 | ||
16 | // FIXME make these public somewhere; usbdevfs.h? | 16 | /* FIXME make these public somewhere; usbdevfs.h? */ |
17 | // | ||
18 | struct usbtest_param { | 17 | struct usbtest_param { |
19 | // inputs | 18 | /* inputs */ |
20 | unsigned test_num; /* 0..(TEST_CASES-1) */ | 19 | unsigned test_num; /* 0..(TEST_CASES-1) */ |
21 | unsigned iterations; | 20 | unsigned iterations; |
22 | unsigned length; | 21 | unsigned length; |
23 | unsigned vary; | 22 | unsigned vary; |
24 | unsigned sglen; | 23 | unsigned sglen; |
25 | 24 | ||
26 | // outputs | 25 | /* outputs */ |
27 | struct timeval duration; | 26 | struct timeval duration; |
28 | }; | 27 | }; |
29 | #define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param) | 28 | #define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param) |
@@ -45,9 +44,9 @@ struct usbtest_info { | |||
45 | const char *name; | 44 | const char *name; |
46 | u8 ep_in; /* bulk/intr source */ | 45 | u8 ep_in; /* bulk/intr source */ |
47 | u8 ep_out; /* bulk/intr sink */ | 46 | u8 ep_out; /* bulk/intr sink */ |
48 | unsigned autoconf : 1; | 47 | unsigned autoconf:1; |
49 | unsigned ctrl_out : 1; | 48 | unsigned ctrl_out:1; |
50 | unsigned iso : 1; /* try iso in/out */ | 49 | unsigned iso:1; /* try iso in/out */ |
51 | int alt; | 50 | int alt; |
52 | }; | 51 | }; |
53 | 52 | ||
@@ -71,9 +70,9 @@ struct usbtest_dev { | |||
71 | u8 *buf; | 70 | u8 *buf; |
72 | }; | 71 | }; |
73 | 72 | ||
74 | static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test) | 73 | static struct usb_device *testdev_to_usbdev(struct usbtest_dev *test) |
75 | { | 74 | { |
76 | return interface_to_usbdev (test->intf); | 75 | return interface_to_usbdev(test->intf); |
77 | } | 76 | } |
78 | 77 | ||
79 | /* set up all urbs so they can be used with either bulk or interrupt */ | 78 | /* set up all urbs so they can be used with either bulk or interrupt */ |
@@ -84,10 +83,12 @@ static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test) | |||
84 | #define WARNING(tdev, fmt, args...) \ | 83 | #define WARNING(tdev, fmt, args...) \ |
85 | dev_warn(&(tdev)->intf->dev , fmt , ## args) | 84 | dev_warn(&(tdev)->intf->dev , fmt , ## args) |
86 | 85 | ||
86 | #define GUARD_BYTE 0xA5 | ||
87 | |||
87 | /*-------------------------------------------------------------------------*/ | 88 | /*-------------------------------------------------------------------------*/ |
88 | 89 | ||
89 | static int | 90 | static int |
90 | get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf) | 91 | get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf) |
91 | { | 92 | { |
92 | int tmp; | 93 | int tmp; |
93 | struct usb_host_interface *alt; | 94 | struct usb_host_interface *alt; |
@@ -103,7 +104,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf) | |||
103 | alt = intf->altsetting + tmp; | 104 | alt = intf->altsetting + tmp; |
104 | 105 | ||
105 | /* take the first altsetting with in-bulk + out-bulk; | 106 | /* take the first altsetting with in-bulk + out-bulk; |
106 | * ignore other endpoints and altsetttings. | 107 | * ignore other endpoints and altsettings. |
107 | */ | 108 | */ |
108 | for (ep = 0; ep < alt->desc.bNumEndpoints; ep++) { | 109 | for (ep = 0; ep < alt->desc.bNumEndpoints; ep++) { |
109 | struct usb_host_endpoint *e; | 110 | struct usb_host_endpoint *e; |
@@ -115,7 +116,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf) | |||
115 | case USB_ENDPOINT_XFER_ISOC: | 116 | case USB_ENDPOINT_XFER_ISOC: |
116 | if (dev->info->iso) | 117 | if (dev->info->iso) |
117 | goto try_iso; | 118 | goto try_iso; |
118 | // FALLTHROUGH | 119 | /* FALLTHROUGH */ |
119 | default: | 120 | default: |
120 | continue; | 121 | continue; |
121 | } | 122 | } |
@@ -142,9 +143,9 @@ try_iso: | |||
142 | return -EINVAL; | 143 | return -EINVAL; |
143 | 144 | ||
144 | found: | 145 | found: |
145 | udev = testdev_to_usbdev (dev); | 146 | udev = testdev_to_usbdev(dev); |
146 | if (alt->desc.bAlternateSetting != 0) { | 147 | if (alt->desc.bAlternateSetting != 0) { |
147 | tmp = usb_set_interface (udev, | 148 | tmp = usb_set_interface(udev, |
148 | alt->desc.bInterfaceNumber, | 149 | alt->desc.bInterfaceNumber, |
149 | alt->desc.bAlternateSetting); | 150 | alt->desc.bAlternateSetting); |
150 | if (tmp < 0) | 151 | if (tmp < 0) |
@@ -152,21 +153,21 @@ found: | |||
152 | } | 153 | } |
153 | 154 | ||
154 | if (in) { | 155 | if (in) { |
155 | dev->in_pipe = usb_rcvbulkpipe (udev, | 156 | dev->in_pipe = usb_rcvbulkpipe(udev, |
156 | in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); | 157 | in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); |
157 | dev->out_pipe = usb_sndbulkpipe (udev, | 158 | dev->out_pipe = usb_sndbulkpipe(udev, |
158 | out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); | 159 | out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); |
159 | } | 160 | } |
160 | if (iso_in) { | 161 | if (iso_in) { |
161 | dev->iso_in = &iso_in->desc; | 162 | dev->iso_in = &iso_in->desc; |
162 | dev->in_iso_pipe = usb_rcvisocpipe (udev, | 163 | dev->in_iso_pipe = usb_rcvisocpipe(udev, |
163 | iso_in->desc.bEndpointAddress | 164 | iso_in->desc.bEndpointAddress |
164 | & USB_ENDPOINT_NUMBER_MASK); | 165 | & USB_ENDPOINT_NUMBER_MASK); |
165 | } | 166 | } |
166 | 167 | ||
167 | if (iso_out) { | 168 | if (iso_out) { |
168 | dev->iso_out = &iso_out->desc; | 169 | dev->iso_out = &iso_out->desc; |
169 | dev->out_iso_pipe = usb_sndisocpipe (udev, | 170 | dev->out_iso_pipe = usb_sndisocpipe(udev, |
170 | iso_out->desc.bEndpointAddress | 171 | iso_out->desc.bEndpointAddress |
171 | & USB_ENDPOINT_NUMBER_MASK); | 172 | & USB_ENDPOINT_NUMBER_MASK); |
172 | } | 173 | } |
@@ -182,45 +183,73 @@ found: | |||
182 | * them with non-zero test data (or test for it) when appropriate. | 183 | * them with non-zero test data (or test for it) when appropriate. |
183 | */ | 184 | */ |
184 | 185 | ||
185 | static void simple_callback (struct urb *urb) | 186 | static void simple_callback(struct urb *urb) |
186 | { | 187 | { |
187 | complete(urb->context); | 188 | complete(urb->context); |
188 | } | 189 | } |
189 | 190 | ||
190 | static struct urb *simple_alloc_urb ( | 191 | static struct urb *usbtest_alloc_urb( |
191 | struct usb_device *udev, | 192 | struct usb_device *udev, |
192 | int pipe, | 193 | int pipe, |
193 | unsigned long bytes | 194 | unsigned long bytes, |
194 | ) | 195 | unsigned transfer_flags, |
196 | unsigned offset) | ||
195 | { | 197 | { |
196 | struct urb *urb; | 198 | struct urb *urb; |
197 | 199 | ||
198 | urb = usb_alloc_urb (0, GFP_KERNEL); | 200 | urb = usb_alloc_urb(0, GFP_KERNEL); |
199 | if (!urb) | 201 | if (!urb) |
200 | return urb; | 202 | return urb; |
201 | usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL); | 203 | usb_fill_bulk_urb(urb, udev, pipe, NULL, bytes, simple_callback, NULL); |
202 | urb->interval = (udev->speed == USB_SPEED_HIGH) | 204 | urb->interval = (udev->speed == USB_SPEED_HIGH) |
203 | ? (INTERRUPT_RATE << 3) | 205 | ? (INTERRUPT_RATE << 3) |
204 | : INTERRUPT_RATE; | 206 | : INTERRUPT_RATE; |
205 | urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | 207 | urb->transfer_flags = transfer_flags; |
206 | if (usb_pipein (pipe)) | 208 | if (usb_pipein(pipe)) |
207 | urb->transfer_flags |= URB_SHORT_NOT_OK; | 209 | urb->transfer_flags |= URB_SHORT_NOT_OK; |
208 | urb->transfer_buffer = usb_alloc_coherent (udev, bytes, GFP_KERNEL, | 210 | |
209 | &urb->transfer_dma); | 211 | if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) |
212 | urb->transfer_buffer = usb_alloc_coherent(udev, bytes + offset, | ||
213 | GFP_KERNEL, &urb->transfer_dma); | ||
214 | else | ||
215 | urb->transfer_buffer = kmalloc(bytes + offset, GFP_KERNEL); | ||
216 | |||
210 | if (!urb->transfer_buffer) { | 217 | if (!urb->transfer_buffer) { |
211 | usb_free_urb (urb); | 218 | usb_free_urb(urb); |
212 | urb = NULL; | 219 | return NULL; |
213 | } else | 220 | } |
214 | memset (urb->transfer_buffer, 0, bytes); | 221 | |
222 | /* To test unaligned transfers add an offset and fill the | ||
223 | unused memory with a guard value */ | ||
224 | if (offset) { | ||
225 | memset(urb->transfer_buffer, GUARD_BYTE, offset); | ||
226 | urb->transfer_buffer += offset; | ||
227 | if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) | ||
228 | urb->transfer_dma += offset; | ||
229 | } | ||
230 | |||
231 | /* For inbound transfers use guard byte so that test fails if | ||
232 | data not correctly copied */ | ||
233 | memset(urb->transfer_buffer, | ||
234 | usb_pipein(urb->pipe) ? GUARD_BYTE : 0, | ||
235 | bytes); | ||
215 | return urb; | 236 | return urb; |
216 | } | 237 | } |
217 | 238 | ||
218 | static unsigned pattern = 0; | 239 | static struct urb *simple_alloc_urb( |
240 | struct usb_device *udev, | ||
241 | int pipe, | ||
242 | unsigned long bytes) | ||
243 | { | ||
244 | return usbtest_alloc_urb(udev, pipe, bytes, URB_NO_TRANSFER_DMA_MAP, 0); | ||
245 | } | ||
246 | |||
247 | static unsigned pattern; | ||
219 | static unsigned mod_pattern; | 248 | static unsigned mod_pattern; |
220 | module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR); | 249 | module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR); |
221 | MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)"); | 250 | MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)"); |
222 | 251 | ||
223 | static inline void simple_fill_buf (struct urb *urb) | 252 | static inline void simple_fill_buf(struct urb *urb) |
224 | { | 253 | { |
225 | unsigned i; | 254 | unsigned i; |
226 | u8 *buf = urb->transfer_buffer; | 255 | u8 *buf = urb->transfer_buffer; |
@@ -228,9 +257,9 @@ static inline void simple_fill_buf (struct urb *urb) | |||
228 | 257 | ||
229 | switch (pattern) { | 258 | switch (pattern) { |
230 | default: | 259 | default: |
231 | // FALLTHROUGH | 260 | /* FALLTHROUGH */ |
232 | case 0: | 261 | case 0: |
233 | memset (buf, 0, len); | 262 | memset(buf, 0, len); |
234 | break; | 263 | break; |
235 | case 1: /* mod63 */ | 264 | case 1: /* mod63 */ |
236 | for (i = 0; i < len; i++) | 265 | for (i = 0; i < len; i++) |
@@ -239,13 +268,38 @@ static inline void simple_fill_buf (struct urb *urb) | |||
239 | } | 268 | } |
240 | } | 269 | } |
241 | 270 | ||
242 | static inline int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb) | 271 | static inline unsigned long buffer_offset(void *buf) |
272 | { | ||
273 | return (unsigned long)buf & (ARCH_KMALLOC_MINALIGN - 1); | ||
274 | } | ||
275 | |||
276 | static int check_guard_bytes(struct usbtest_dev *tdev, struct urb *urb) | ||
277 | { | ||
278 | u8 *buf = urb->transfer_buffer; | ||
279 | u8 *guard = buf - buffer_offset(buf); | ||
280 | unsigned i; | ||
281 | |||
282 | for (i = 0; guard < buf; i++, guard++) { | ||
283 | if (*guard != GUARD_BYTE) { | ||
284 | ERROR(tdev, "guard byte[%d] %d (not %d)\n", | ||
285 | i, *guard, GUARD_BYTE); | ||
286 | return -EINVAL; | ||
287 | } | ||
288 | } | ||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb) | ||
243 | { | 293 | { |
244 | unsigned i; | 294 | unsigned i; |
245 | u8 expected; | 295 | u8 expected; |
246 | u8 *buf = urb->transfer_buffer; | 296 | u8 *buf = urb->transfer_buffer; |
247 | unsigned len = urb->actual_length; | 297 | unsigned len = urb->actual_length; |
248 | 298 | ||
299 | int ret = check_guard_bytes(tdev, urb); | ||
300 | if (ret) | ||
301 | return ret; | ||
302 | |||
249 | for (i = 0; i < len; i++, buf++) { | 303 | for (i = 0; i < len; i++, buf++) { |
250 | switch (pattern) { | 304 | switch (pattern) { |
251 | /* all-zeroes has no synchronization issues */ | 305 | /* all-zeroes has no synchronization issues */ |
@@ -273,14 +327,22 @@ static inline int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb) | |||
273 | return 0; | 327 | return 0; |
274 | } | 328 | } |
275 | 329 | ||
276 | static void simple_free_urb (struct urb *urb) | 330 | static void simple_free_urb(struct urb *urb) |
277 | { | 331 | { |
278 | usb_free_coherent(urb->dev, urb->transfer_buffer_length, | 332 | unsigned long offset = buffer_offset(urb->transfer_buffer); |
279 | urb->transfer_buffer, urb->transfer_dma); | 333 | |
280 | usb_free_urb (urb); | 334 | if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) |
335 | usb_free_coherent( | ||
336 | urb->dev, | ||
337 | urb->transfer_buffer_length + offset, | ||
338 | urb->transfer_buffer - offset, | ||
339 | urb->transfer_dma - offset); | ||
340 | else | ||
341 | kfree(urb->transfer_buffer - offset); | ||
342 | usb_free_urb(urb); | ||
281 | } | 343 | } |
282 | 344 | ||
283 | static int simple_io ( | 345 | static int simple_io( |
284 | struct usbtest_dev *tdev, | 346 | struct usbtest_dev *tdev, |
285 | struct urb *urb, | 347 | struct urb *urb, |
286 | int iterations, | 348 | int iterations, |
@@ -296,17 +358,18 @@ static int simple_io ( | |||
296 | 358 | ||
297 | urb->context = &completion; | 359 | urb->context = &completion; |
298 | while (retval == 0 && iterations-- > 0) { | 360 | while (retval == 0 && iterations-- > 0) { |
299 | init_completion (&completion); | 361 | init_completion(&completion); |
300 | if (usb_pipeout (urb->pipe)) | 362 | if (usb_pipeout(urb->pipe)) |
301 | simple_fill_buf (urb); | 363 | simple_fill_buf(urb); |
302 | if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) | 364 | retval = usb_submit_urb(urb, GFP_KERNEL); |
365 | if (retval != 0) | ||
303 | break; | 366 | break; |
304 | 367 | ||
305 | /* NOTE: no timeouts; can't be broken out of by interrupt */ | 368 | /* NOTE: no timeouts; can't be broken out of by interrupt */ |
306 | wait_for_completion (&completion); | 369 | wait_for_completion(&completion); |
307 | retval = urb->status; | 370 | retval = urb->status; |
308 | urb->dev = udev; | 371 | urb->dev = udev; |
309 | if (retval == 0 && usb_pipein (urb->pipe)) | 372 | if (retval == 0 && usb_pipein(urb->pipe)) |
310 | retval = simple_check_buf(tdev, urb); | 373 | retval = simple_check_buf(tdev, urb); |
311 | 374 | ||
312 | if (vary) { | 375 | if (vary) { |
@@ -337,7 +400,7 @@ static int simple_io ( | |||
337 | * Yes, this also tests the scatterlist primitives. | 400 | * Yes, this also tests the scatterlist primitives. |
338 | */ | 401 | */ |
339 | 402 | ||
340 | static void free_sglist (struct scatterlist *sg, int nents) | 403 | static void free_sglist(struct scatterlist *sg, int nents) |
341 | { | 404 | { |
342 | unsigned i; | 405 | unsigned i; |
343 | 406 | ||
@@ -346,19 +409,19 @@ static void free_sglist (struct scatterlist *sg, int nents) | |||
346 | for (i = 0; i < nents; i++) { | 409 | for (i = 0; i < nents; i++) { |
347 | if (!sg_page(&sg[i])) | 410 | if (!sg_page(&sg[i])) |
348 | continue; | 411 | continue; |
349 | kfree (sg_virt(&sg[i])); | 412 | kfree(sg_virt(&sg[i])); |
350 | } | 413 | } |
351 | kfree (sg); | 414 | kfree(sg); |
352 | } | 415 | } |
353 | 416 | ||
354 | static struct scatterlist * | 417 | static struct scatterlist * |
355 | alloc_sglist (int nents, int max, int vary) | 418 | alloc_sglist(int nents, int max, int vary) |
356 | { | 419 | { |
357 | struct scatterlist *sg; | 420 | struct scatterlist *sg; |
358 | unsigned i; | 421 | unsigned i; |
359 | unsigned size = max; | 422 | unsigned size = max; |
360 | 423 | ||
361 | sg = kmalloc (nents * sizeof *sg, GFP_KERNEL); | 424 | sg = kmalloc(nents * sizeof *sg, GFP_KERNEL); |
362 | if (!sg) | 425 | if (!sg) |
363 | return NULL; | 426 | return NULL; |
364 | sg_init_table(sg, nents); | 427 | sg_init_table(sg, nents); |
@@ -367,9 +430,9 @@ alloc_sglist (int nents, int max, int vary) | |||
367 | char *buf; | 430 | char *buf; |
368 | unsigned j; | 431 | unsigned j; |
369 | 432 | ||
370 | buf = kzalloc (size, GFP_KERNEL); | 433 | buf = kzalloc(size, GFP_KERNEL); |
371 | if (!buf) { | 434 | if (!buf) { |
372 | free_sglist (sg, i); | 435 | free_sglist(sg, i); |
373 | return NULL; | 436 | return NULL; |
374 | } | 437 | } |
375 | 438 | ||
@@ -397,7 +460,7 @@ alloc_sglist (int nents, int max, int vary) | |||
397 | return sg; | 460 | return sg; |
398 | } | 461 | } |
399 | 462 | ||
400 | static int perform_sglist ( | 463 | static int perform_sglist( |
401 | struct usbtest_dev *tdev, | 464 | struct usbtest_dev *tdev, |
402 | unsigned iterations, | 465 | unsigned iterations, |
403 | int pipe, | 466 | int pipe, |
@@ -410,7 +473,7 @@ static int perform_sglist ( | |||
410 | int retval = 0; | 473 | int retval = 0; |
411 | 474 | ||
412 | while (retval == 0 && iterations-- > 0) { | 475 | while (retval == 0 && iterations-- > 0) { |
413 | retval = usb_sg_init (req, udev, pipe, | 476 | retval = usb_sg_init(req, udev, pipe, |
414 | (udev->speed == USB_SPEED_HIGH) | 477 | (udev->speed == USB_SPEED_HIGH) |
415 | ? (INTERRUPT_RATE << 3) | 478 | ? (INTERRUPT_RATE << 3) |
416 | : INTERRUPT_RATE, | 479 | : INTERRUPT_RATE, |
@@ -418,7 +481,7 @@ static int perform_sglist ( | |||
418 | 481 | ||
419 | if (retval) | 482 | if (retval) |
420 | break; | 483 | break; |
421 | usb_sg_wait (req); | 484 | usb_sg_wait(req); |
422 | retval = req->status; | 485 | retval = req->status; |
423 | 486 | ||
424 | /* FIXME check resulting data pattern */ | 487 | /* FIXME check resulting data pattern */ |
@@ -426,9 +489,9 @@ static int perform_sglist ( | |||
426 | /* FIXME if endpoint halted, clear halt (and log) */ | 489 | /* FIXME if endpoint halted, clear halt (and log) */ |
427 | } | 490 | } |
428 | 491 | ||
429 | // FIXME for unlink or fault handling tests, don't report | 492 | /* FIXME for unlink or fault handling tests, don't report |
430 | // failure if retval is as we expected ... | 493 | * failure if retval is as we expected ... |
431 | 494 | */ | |
432 | if (retval) | 495 | if (retval) |
433 | ERROR(tdev, "perform_sglist failed, " | 496 | ERROR(tdev, "perform_sglist failed, " |
434 | "iterations left %d, status %d\n", | 497 | "iterations left %d, status %d\n", |
@@ -452,31 +515,31 @@ static int perform_sglist ( | |||
452 | */ | 515 | */ |
453 | 516 | ||
454 | static unsigned realworld = 1; | 517 | static unsigned realworld = 1; |
455 | module_param (realworld, uint, 0); | 518 | module_param(realworld, uint, 0); |
456 | MODULE_PARM_DESC (realworld, "clear to demand stricter spec compliance"); | 519 | MODULE_PARM_DESC(realworld, "clear to demand stricter spec compliance"); |
457 | 520 | ||
458 | static int get_altsetting (struct usbtest_dev *dev) | 521 | static int get_altsetting(struct usbtest_dev *dev) |
459 | { | 522 | { |
460 | struct usb_interface *iface = dev->intf; | 523 | struct usb_interface *iface = dev->intf; |
461 | struct usb_device *udev = interface_to_usbdev (iface); | 524 | struct usb_device *udev = interface_to_usbdev(iface); |
462 | int retval; | 525 | int retval; |
463 | 526 | ||
464 | retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0), | 527 | retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
465 | USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE, | 528 | USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE, |
466 | 0, iface->altsetting [0].desc.bInterfaceNumber, | 529 | 0, iface->altsetting[0].desc.bInterfaceNumber, |
467 | dev->buf, 1, USB_CTRL_GET_TIMEOUT); | 530 | dev->buf, 1, USB_CTRL_GET_TIMEOUT); |
468 | switch (retval) { | 531 | switch (retval) { |
469 | case 1: | 532 | case 1: |
470 | return dev->buf [0]; | 533 | return dev->buf[0]; |
471 | case 0: | 534 | case 0: |
472 | retval = -ERANGE; | 535 | retval = -ERANGE; |
473 | // FALLTHROUGH | 536 | /* FALLTHROUGH */ |
474 | default: | 537 | default: |
475 | return retval; | 538 | return retval; |
476 | } | 539 | } |
477 | } | 540 | } |
478 | 541 | ||
479 | static int set_altsetting (struct usbtest_dev *dev, int alternate) | 542 | static int set_altsetting(struct usbtest_dev *dev, int alternate) |
480 | { | 543 | { |
481 | struct usb_interface *iface = dev->intf; | 544 | struct usb_interface *iface = dev->intf; |
482 | struct usb_device *udev; | 545 | struct usb_device *udev; |
@@ -484,9 +547,9 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate) | |||
484 | if (alternate < 0 || alternate >= 256) | 547 | if (alternate < 0 || alternate >= 256) |
485 | return -EINVAL; | 548 | return -EINVAL; |
486 | 549 | ||
487 | udev = interface_to_usbdev (iface); | 550 | udev = interface_to_usbdev(iface); |
488 | return usb_set_interface (udev, | 551 | return usb_set_interface(udev, |
489 | iface->altsetting [0].desc.bInterfaceNumber, | 552 | iface->altsetting[0].desc.bInterfaceNumber, |
490 | alternate); | 553 | alternate); |
491 | } | 554 | } |
492 | 555 | ||
@@ -519,9 +582,9 @@ static int is_good_config(struct usbtest_dev *tdev, int len) | |||
519 | return 0; | 582 | return 0; |
520 | } | 583 | } |
521 | 584 | ||
522 | if (le16_to_cpu(config->wTotalLength) == len) /* read it all */ | 585 | if (le16_to_cpu(config->wTotalLength) == len) /* read it all */ |
523 | return 1; | 586 | return 1; |
524 | if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ | 587 | if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ |
525 | return 1; | 588 | return 1; |
526 | ERROR(tdev, "bogus config descriptor read size\n"); | 589 | ERROR(tdev, "bogus config descriptor read size\n"); |
527 | return 0; | 590 | return 0; |
@@ -542,10 +605,10 @@ static int is_good_config(struct usbtest_dev *tdev, int len) | |||
542 | * to see if usbcore, hcd, and device all behave right. such testing would | 605 | * to see if usbcore, hcd, and device all behave right. such testing would |
543 | * involve varied read sizes and other operation sequences. | 606 | * involve varied read sizes and other operation sequences. |
544 | */ | 607 | */ |
545 | static int ch9_postconfig (struct usbtest_dev *dev) | 608 | static int ch9_postconfig(struct usbtest_dev *dev) |
546 | { | 609 | { |
547 | struct usb_interface *iface = dev->intf; | 610 | struct usb_interface *iface = dev->intf; |
548 | struct usb_device *udev = interface_to_usbdev (iface); | 611 | struct usb_device *udev = interface_to_usbdev(iface); |
549 | int i, alt, retval; | 612 | int i, alt, retval; |
550 | 613 | ||
551 | /* [9.2.3] if there's more than one altsetting, we need to be able to | 614 | /* [9.2.3] if there's more than one altsetting, we need to be able to |
@@ -554,7 +617,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
554 | for (i = 0; i < iface->num_altsetting; i++) { | 617 | for (i = 0; i < iface->num_altsetting; i++) { |
555 | 618 | ||
556 | /* 9.2.3 constrains the range here */ | 619 | /* 9.2.3 constrains the range here */ |
557 | alt = iface->altsetting [i].desc.bAlternateSetting; | 620 | alt = iface->altsetting[i].desc.bAlternateSetting; |
558 | if (alt < 0 || alt >= iface->num_altsetting) { | 621 | if (alt < 0 || alt >= iface->num_altsetting) { |
559 | dev_err(&iface->dev, | 622 | dev_err(&iface->dev, |
560 | "invalid alt [%d].bAltSetting = %d\n", | 623 | "invalid alt [%d].bAltSetting = %d\n", |
@@ -566,7 +629,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
566 | continue; | 629 | continue; |
567 | 630 | ||
568 | /* [9.4.10] set_interface */ | 631 | /* [9.4.10] set_interface */ |
569 | retval = set_altsetting (dev, alt); | 632 | retval = set_altsetting(dev, alt); |
570 | if (retval) { | 633 | if (retval) { |
571 | dev_err(&iface->dev, "can't set_interface = %d, %d\n", | 634 | dev_err(&iface->dev, "can't set_interface = %d, %d\n", |
572 | alt, retval); | 635 | alt, retval); |
@@ -574,7 +637,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
574 | } | 637 | } |
575 | 638 | ||
576 | /* [9.4.4] get_interface always works */ | 639 | /* [9.4.4] get_interface always works */ |
577 | retval = get_altsetting (dev); | 640 | retval = get_altsetting(dev); |
578 | if (retval != alt) { | 641 | if (retval != alt) { |
579 | dev_err(&iface->dev, "get alt should be %d, was %d\n", | 642 | dev_err(&iface->dev, "get alt should be %d, was %d\n", |
580 | alt, retval); | 643 | alt, retval); |
@@ -591,11 +654,11 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
591 | * ... although some cheap devices (like one TI Hub I've got) | 654 | * ... although some cheap devices (like one TI Hub I've got) |
592 | * won't return config descriptors except before set_config. | 655 | * won't return config descriptors except before set_config. |
593 | */ | 656 | */ |
594 | retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0), | 657 | retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
595 | USB_REQ_GET_CONFIGURATION, | 658 | USB_REQ_GET_CONFIGURATION, |
596 | USB_DIR_IN | USB_RECIP_DEVICE, | 659 | USB_DIR_IN | USB_RECIP_DEVICE, |
597 | 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); | 660 | 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); |
598 | if (retval != 1 || dev->buf [0] != expected) { | 661 | if (retval != 1 || dev->buf[0] != expected) { |
599 | dev_err(&iface->dev, "get config --> %d %d (1 %d)\n", | 662 | dev_err(&iface->dev, "get config --> %d %d (1 %d)\n", |
600 | retval, dev->buf[0], expected); | 663 | retval, dev->buf[0], expected); |
601 | return (retval < 0) ? retval : -EDOM; | 664 | return (retval < 0) ? retval : -EDOM; |
@@ -603,7 +666,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
603 | } | 666 | } |
604 | 667 | ||
605 | /* there's always [9.4.3] a device descriptor [9.6.1] */ | 668 | /* there's always [9.4.3] a device descriptor [9.6.1] */ |
606 | retval = usb_get_descriptor (udev, USB_DT_DEVICE, 0, | 669 | retval = usb_get_descriptor(udev, USB_DT_DEVICE, 0, |
607 | dev->buf, sizeof udev->descriptor); | 670 | dev->buf, sizeof udev->descriptor); |
608 | if (retval != sizeof udev->descriptor) { | 671 | if (retval != sizeof udev->descriptor) { |
609 | dev_err(&iface->dev, "dev descriptor --> %d\n", retval); | 672 | dev_err(&iface->dev, "dev descriptor --> %d\n", retval); |
@@ -612,7 +675,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
612 | 675 | ||
613 | /* there's always [9.4.3] at least one config descriptor [9.6.3] */ | 676 | /* there's always [9.4.3] at least one config descriptor [9.6.3] */ |
614 | for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { | 677 | for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { |
615 | retval = usb_get_descriptor (udev, USB_DT_CONFIG, i, | 678 | retval = usb_get_descriptor(udev, USB_DT_CONFIG, i, |
616 | dev->buf, TBUF_SIZE); | 679 | dev->buf, TBUF_SIZE); |
617 | if (!is_good_config(dev, retval)) { | 680 | if (!is_good_config(dev, retval)) { |
618 | dev_err(&iface->dev, | 681 | dev_err(&iface->dev, |
@@ -621,18 +684,19 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
621 | return (retval < 0) ? retval : -EDOM; | 684 | return (retval < 0) ? retval : -EDOM; |
622 | } | 685 | } |
623 | 686 | ||
624 | // FIXME cross-checking udev->config[i] to make sure usbcore | 687 | /* FIXME cross-checking udev->config[i] to make sure usbcore |
625 | // parsed it right (etc) would be good testing paranoia | 688 | * parsed it right (etc) would be good testing paranoia |
689 | */ | ||
626 | } | 690 | } |
627 | 691 | ||
628 | /* and sometimes [9.2.6.6] speed dependent descriptors */ | 692 | /* and sometimes [9.2.6.6] speed dependent descriptors */ |
629 | if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) { | 693 | if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) { |
630 | struct usb_qualifier_descriptor *d = NULL; | 694 | struct usb_qualifier_descriptor *d = NULL; |
631 | 695 | ||
632 | /* device qualifier [9.6.2] */ | 696 | /* device qualifier [9.6.2] */ |
633 | retval = usb_get_descriptor (udev, | 697 | retval = usb_get_descriptor(udev, |
634 | USB_DT_DEVICE_QUALIFIER, 0, dev->buf, | 698 | USB_DT_DEVICE_QUALIFIER, 0, dev->buf, |
635 | sizeof (struct usb_qualifier_descriptor)); | 699 | sizeof(struct usb_qualifier_descriptor)); |
636 | if (retval == -EPIPE) { | 700 | if (retval == -EPIPE) { |
637 | if (udev->speed == USB_SPEED_HIGH) { | 701 | if (udev->speed == USB_SPEED_HIGH) { |
638 | dev_err(&iface->dev, | 702 | dev_err(&iface->dev, |
@@ -641,7 +705,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
641 | return (retval < 0) ? retval : -EDOM; | 705 | return (retval < 0) ? retval : -EDOM; |
642 | } | 706 | } |
643 | /* usb2.0 but not high-speed capable; fine */ | 707 | /* usb2.0 but not high-speed capable; fine */ |
644 | } else if (retval != sizeof (struct usb_qualifier_descriptor)) { | 708 | } else if (retval != sizeof(struct usb_qualifier_descriptor)) { |
645 | dev_err(&iface->dev, "dev qualifier --> %d\n", retval); | 709 | dev_err(&iface->dev, "dev qualifier --> %d\n", retval); |
646 | return (retval < 0) ? retval : -EDOM; | 710 | return (retval < 0) ? retval : -EDOM; |
647 | } else | 711 | } else |
@@ -651,7 +715,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
651 | if (d) { | 715 | if (d) { |
652 | unsigned max = d->bNumConfigurations; | 716 | unsigned max = d->bNumConfigurations; |
653 | for (i = 0; i < max; i++) { | 717 | for (i = 0; i < max; i++) { |
654 | retval = usb_get_descriptor (udev, | 718 | retval = usb_get_descriptor(udev, |
655 | USB_DT_OTHER_SPEED_CONFIG, i, | 719 | USB_DT_OTHER_SPEED_CONFIG, i, |
656 | dev->buf, TBUF_SIZE); | 720 | dev->buf, TBUF_SIZE); |
657 | if (!is_good_config(dev, retval)) { | 721 | if (!is_good_config(dev, retval)) { |
@@ -663,25 +727,26 @@ static int ch9_postconfig (struct usbtest_dev *dev) | |||
663 | } | 727 | } |
664 | } | 728 | } |
665 | } | 729 | } |
666 | // FIXME fetch strings from at least the device descriptor | 730 | /* FIXME fetch strings from at least the device descriptor */ |
667 | 731 | ||
668 | /* [9.4.5] get_status always works */ | 732 | /* [9.4.5] get_status always works */ |
669 | retval = usb_get_status (udev, USB_RECIP_DEVICE, 0, dev->buf); | 733 | retval = usb_get_status(udev, USB_RECIP_DEVICE, 0, dev->buf); |
670 | if (retval != 2) { | 734 | if (retval != 2) { |
671 | dev_err(&iface->dev, "get dev status --> %d\n", retval); | 735 | dev_err(&iface->dev, "get dev status --> %d\n", retval); |
672 | return (retval < 0) ? retval : -EDOM; | 736 | return (retval < 0) ? retval : -EDOM; |
673 | } | 737 | } |
674 | 738 | ||
675 | // FIXME configuration.bmAttributes says if we could try to set/clear | 739 | /* FIXME configuration.bmAttributes says if we could try to set/clear |
676 | // the device's remote wakeup feature ... if we can, test that here | 740 | * the device's remote wakeup feature ... if we can, test that here |
741 | */ | ||
677 | 742 | ||
678 | retval = usb_get_status (udev, USB_RECIP_INTERFACE, | 743 | retval = usb_get_status(udev, USB_RECIP_INTERFACE, |
679 | iface->altsetting [0].desc.bInterfaceNumber, dev->buf); | 744 | iface->altsetting[0].desc.bInterfaceNumber, dev->buf); |
680 | if (retval != 2) { | 745 | if (retval != 2) { |
681 | dev_err(&iface->dev, "get interface status --> %d\n", retval); | 746 | dev_err(&iface->dev, "get interface status --> %d\n", retval); |
682 | return (retval < 0) ? retval : -EDOM; | 747 | return (retval < 0) ? retval : -EDOM; |
683 | } | 748 | } |
684 | // FIXME get status for each endpoint in the interface | 749 | /* FIXME get status for each endpoint in the interface */ |
685 | 750 | ||
686 | return 0; | 751 | return 0; |
687 | } | 752 | } |
@@ -717,7 +782,7 @@ struct subcase { | |||
717 | int expected; | 782 | int expected; |
718 | }; | 783 | }; |
719 | 784 | ||
720 | static void ctrl_complete (struct urb *urb) | 785 | static void ctrl_complete(struct urb *urb) |
721 | { | 786 | { |
722 | struct ctrl_ctx *ctx = urb->context; | 787 | struct ctrl_ctx *ctx = urb->context; |
723 | struct usb_ctrlrequest *reqp; | 788 | struct usb_ctrlrequest *reqp; |
@@ -725,9 +790,9 @@ static void ctrl_complete (struct urb *urb) | |||
725 | int status = urb->status; | 790 | int status = urb->status; |
726 | 791 | ||
727 | reqp = (struct usb_ctrlrequest *)urb->setup_packet; | 792 | reqp = (struct usb_ctrlrequest *)urb->setup_packet; |
728 | subcase = container_of (reqp, struct subcase, setup); | 793 | subcase = container_of(reqp, struct subcase, setup); |
729 | 794 | ||
730 | spin_lock (&ctx->lock); | 795 | spin_lock(&ctx->lock); |
731 | ctx->count--; | 796 | ctx->count--; |
732 | ctx->pending--; | 797 | ctx->pending--; |
733 | 798 | ||
@@ -787,14 +852,14 @@ error: | |||
787 | 852 | ||
788 | /* unlink whatever's still pending */ | 853 | /* unlink whatever's still pending */ |
789 | for (i = 1; i < ctx->param->sglen; i++) { | 854 | for (i = 1; i < ctx->param->sglen; i++) { |
790 | struct urb *u = ctx->urb [ | 855 | struct urb *u = ctx->urb[ |
791 | (i + subcase->number) | 856 | (i + subcase->number) |
792 | % ctx->param->sglen]; | 857 | % ctx->param->sglen]; |
793 | 858 | ||
794 | if (u == urb || !u->dev) | 859 | if (u == urb || !u->dev) |
795 | continue; | 860 | continue; |
796 | spin_unlock(&ctx->lock); | 861 | spin_unlock(&ctx->lock); |
797 | status = usb_unlink_urb (u); | 862 | status = usb_unlink_urb(u); |
798 | spin_lock(&ctx->lock); | 863 | spin_lock(&ctx->lock); |
799 | switch (status) { | 864 | switch (status) { |
800 | case -EINPROGRESS: | 865 | case -EINPROGRESS: |
@@ -812,7 +877,8 @@ error: | |||
812 | 877 | ||
813 | /* resubmit if we need to, else mark this as done */ | 878 | /* resubmit if we need to, else mark this as done */ |
814 | if ((status == 0) && (ctx->pending < ctx->count)) { | 879 | if ((status == 0) && (ctx->pending < ctx->count)) { |
815 | if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) { | 880 | status = usb_submit_urb(urb, GFP_ATOMIC); |
881 | if (status != 0) { | ||
816 | ERROR(ctx->dev, | 882 | ERROR(ctx->dev, |
817 | "can't resubmit ctrl %02x.%02x, err %d\n", | 883 | "can't resubmit ctrl %02x.%02x, err %d\n", |
818 | reqp->bRequestType, reqp->bRequest, status); | 884 | reqp->bRequestType, reqp->bRequest, status); |
@@ -824,21 +890,21 @@ error: | |||
824 | 890 | ||
825 | /* signal completion when nothing's queued */ | 891 | /* signal completion when nothing's queued */ |
826 | if (ctx->pending == 0) | 892 | if (ctx->pending == 0) |
827 | complete (&ctx->complete); | 893 | complete(&ctx->complete); |
828 | spin_unlock (&ctx->lock); | 894 | spin_unlock(&ctx->lock); |
829 | } | 895 | } |
830 | 896 | ||
831 | static int | 897 | static int |
832 | test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | 898 | test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param) |
833 | { | 899 | { |
834 | struct usb_device *udev = testdev_to_usbdev (dev); | 900 | struct usb_device *udev = testdev_to_usbdev(dev); |
835 | struct urb **urb; | 901 | struct urb **urb; |
836 | struct ctrl_ctx context; | 902 | struct ctrl_ctx context; |
837 | int i; | 903 | int i; |
838 | 904 | ||
839 | spin_lock_init (&context.lock); | 905 | spin_lock_init(&context.lock); |
840 | context.dev = dev; | 906 | context.dev = dev; |
841 | init_completion (&context.complete); | 907 | init_completion(&context.complete); |
842 | context.count = param->sglen * param->iterations; | 908 | context.count = param->sglen * param->iterations; |
843 | context.pending = 0; | 909 | context.pending = 0; |
844 | context.status = -ENOMEM; | 910 | context.status = -ENOMEM; |
@@ -853,7 +919,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
853 | if (!urb) | 919 | if (!urb) |
854 | return -ENOMEM; | 920 | return -ENOMEM; |
855 | for (i = 0; i < param->sglen; i++) { | 921 | for (i = 0; i < param->sglen; i++) { |
856 | int pipe = usb_rcvctrlpipe (udev, 0); | 922 | int pipe = usb_rcvctrlpipe(udev, 0); |
857 | unsigned len; | 923 | unsigned len; |
858 | struct urb *u; | 924 | struct urb *u; |
859 | struct usb_ctrlrequest req; | 925 | struct usb_ctrlrequest req; |
@@ -869,104 +935,110 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
869 | * device, but some are chosen to trigger protocol stalls | 935 | * device, but some are chosen to trigger protocol stalls |
870 | * or short reads. | 936 | * or short reads. |
871 | */ | 937 | */ |
872 | memset (&req, 0, sizeof req); | 938 | memset(&req, 0, sizeof req); |
873 | req.bRequest = USB_REQ_GET_DESCRIPTOR; | 939 | req.bRequest = USB_REQ_GET_DESCRIPTOR; |
874 | req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; | 940 | req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; |
875 | 941 | ||
876 | switch (i % NUM_SUBCASES) { | 942 | switch (i % NUM_SUBCASES) { |
877 | case 0: // get device descriptor | 943 | case 0: /* get device descriptor */ |
878 | req.wValue = cpu_to_le16 (USB_DT_DEVICE << 8); | 944 | req.wValue = cpu_to_le16(USB_DT_DEVICE << 8); |
879 | len = sizeof (struct usb_device_descriptor); | 945 | len = sizeof(struct usb_device_descriptor); |
880 | break; | 946 | break; |
881 | case 1: // get first config descriptor (only) | 947 | case 1: /* get first config descriptor (only) */ |
882 | req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); | 948 | req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); |
883 | len = sizeof (struct usb_config_descriptor); | 949 | len = sizeof(struct usb_config_descriptor); |
884 | break; | 950 | break; |
885 | case 2: // get altsetting (OFTEN STALLS) | 951 | case 2: /* get altsetting (OFTEN STALLS) */ |
886 | req.bRequest = USB_REQ_GET_INTERFACE; | 952 | req.bRequest = USB_REQ_GET_INTERFACE; |
887 | req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; | 953 | req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; |
888 | // index = 0 means first interface | 954 | /* index = 0 means first interface */ |
889 | len = 1; | 955 | len = 1; |
890 | expected = EPIPE; | 956 | expected = EPIPE; |
891 | break; | 957 | break; |
892 | case 3: // get interface status | 958 | case 3: /* get interface status */ |
893 | req.bRequest = USB_REQ_GET_STATUS; | 959 | req.bRequest = USB_REQ_GET_STATUS; |
894 | req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; | 960 | req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; |
895 | // interface 0 | 961 | /* interface 0 */ |
896 | len = 2; | 962 | len = 2; |
897 | break; | 963 | break; |
898 | case 4: // get device status | 964 | case 4: /* get device status */ |
899 | req.bRequest = USB_REQ_GET_STATUS; | 965 | req.bRequest = USB_REQ_GET_STATUS; |
900 | req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; | 966 | req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; |
901 | len = 2; | 967 | len = 2; |
902 | break; | 968 | break; |
903 | case 5: // get device qualifier (MAY STALL) | 969 | case 5: /* get device qualifier (MAY STALL) */ |
904 | req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8); | 970 | req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8); |
905 | len = sizeof (struct usb_qualifier_descriptor); | 971 | len = sizeof(struct usb_qualifier_descriptor); |
906 | if (udev->speed != USB_SPEED_HIGH) | 972 | if (udev->speed != USB_SPEED_HIGH) |
907 | expected = EPIPE; | 973 | expected = EPIPE; |
908 | break; | 974 | break; |
909 | case 6: // get first config descriptor, plus interface | 975 | case 6: /* get first config descriptor, plus interface */ |
910 | req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); | 976 | req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); |
911 | len = sizeof (struct usb_config_descriptor); | 977 | len = sizeof(struct usb_config_descriptor); |
912 | len += sizeof (struct usb_interface_descriptor); | 978 | len += sizeof(struct usb_interface_descriptor); |
913 | break; | 979 | break; |
914 | case 7: // get interface descriptor (ALWAYS STALLS) | 980 | case 7: /* get interface descriptor (ALWAYS STALLS) */ |
915 | req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); | 981 | req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); |
916 | // interface == 0 | 982 | /* interface == 0 */ |
917 | len = sizeof (struct usb_interface_descriptor); | 983 | len = sizeof(struct usb_interface_descriptor); |
918 | expected = -EPIPE; | 984 | expected = -EPIPE; |
919 | break; | 985 | break; |
920 | // NOTE: two consecutive stalls in the queue here. | 986 | /* NOTE: two consecutive stalls in the queue here. |
921 | // that tests fault recovery a bit more aggressively. | 987 | * that tests fault recovery a bit more aggressively. */ |
922 | case 8: // clear endpoint halt (MAY STALL) | 988 | case 8: /* clear endpoint halt (MAY STALL) */ |
923 | req.bRequest = USB_REQ_CLEAR_FEATURE; | 989 | req.bRequest = USB_REQ_CLEAR_FEATURE; |
924 | req.bRequestType = USB_RECIP_ENDPOINT; | 990 | req.bRequestType = USB_RECIP_ENDPOINT; |
925 | // wValue 0 == ep halt | 991 | /* wValue 0 == ep halt */ |
926 | // wIndex 0 == ep0 (shouldn't halt!) | 992 | /* wIndex 0 == ep0 (shouldn't halt!) */ |
927 | len = 0; | 993 | len = 0; |
928 | pipe = usb_sndctrlpipe (udev, 0); | 994 | pipe = usb_sndctrlpipe(udev, 0); |
929 | expected = EPIPE; | 995 | expected = EPIPE; |
930 | break; | 996 | break; |
931 | case 9: // get endpoint status | 997 | case 9: /* get endpoint status */ |
932 | req.bRequest = USB_REQ_GET_STATUS; | 998 | req.bRequest = USB_REQ_GET_STATUS; |
933 | req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT; | 999 | req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT; |
934 | // endpoint 0 | 1000 | /* endpoint 0 */ |
935 | len = 2; | 1001 | len = 2; |
936 | break; | 1002 | break; |
937 | case 10: // trigger short read (EREMOTEIO) | 1003 | case 10: /* trigger short read (EREMOTEIO) */ |
938 | req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); | 1004 | req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); |
939 | len = 1024; | 1005 | len = 1024; |
940 | expected = -EREMOTEIO; | 1006 | expected = -EREMOTEIO; |
941 | break; | 1007 | break; |
942 | // NOTE: two consecutive _different_ faults in the queue. | 1008 | /* NOTE: two consecutive _different_ faults in the queue. */ |
943 | case 11: // get endpoint descriptor (ALWAYS STALLS) | 1009 | case 11: /* get endpoint descriptor (ALWAYS STALLS) */ |
944 | req.wValue = cpu_to_le16 (USB_DT_ENDPOINT << 8); | 1010 | req.wValue = cpu_to_le16(USB_DT_ENDPOINT << 8); |
945 | // endpoint == 0 | 1011 | /* endpoint == 0 */ |
946 | len = sizeof (struct usb_interface_descriptor); | 1012 | len = sizeof(struct usb_interface_descriptor); |
947 | expected = EPIPE; | 1013 | expected = EPIPE; |
948 | break; | 1014 | break; |
949 | // NOTE: sometimes even a third fault in the queue! | 1015 | /* NOTE: sometimes even a third fault in the queue! */ |
950 | case 12: // get string 0 descriptor (MAY STALL) | 1016 | case 12: /* get string 0 descriptor (MAY STALL) */ |
951 | req.wValue = cpu_to_le16 (USB_DT_STRING << 8); | 1017 | req.wValue = cpu_to_le16(USB_DT_STRING << 8); |
952 | // string == 0, for language IDs | 1018 | /* string == 0, for language IDs */ |
953 | len = sizeof (struct usb_interface_descriptor); | 1019 | len = sizeof(struct usb_interface_descriptor); |
954 | // may succeed when > 4 languages | 1020 | /* may succeed when > 4 languages */ |
955 | expected = EREMOTEIO; // or EPIPE, if no strings | 1021 | expected = EREMOTEIO; /* or EPIPE, if no strings */ |
956 | break; | 1022 | break; |
957 | case 13: // short read, resembling case 10 | 1023 | case 13: /* short read, resembling case 10 */ |
958 | req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0); | 1024 | req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); |
959 | // last data packet "should" be DATA1, not DATA0 | 1025 | /* last data packet "should" be DATA1, not DATA0 */ |
960 | len = 1024 - udev->descriptor.bMaxPacketSize0; | 1026 | len = 1024 - udev->descriptor.bMaxPacketSize0; |
961 | expected = -EREMOTEIO; | 1027 | expected = -EREMOTEIO; |
962 | break; | 1028 | break; |
963 | case 14: // short read; try to fill the last packet | 1029 | case 14: /* short read; try to fill the last packet */ |
964 | req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0); | 1030 | req.wValue = cpu_to_le16((USB_DT_DEVICE << 8) | 0); |
965 | /* device descriptor size == 18 bytes */ | 1031 | /* device descriptor size == 18 bytes */ |
966 | len = udev->descriptor.bMaxPacketSize0; | 1032 | len = udev->descriptor.bMaxPacketSize0; |
1033 | if (udev->speed == USB_SPEED_SUPER) | ||
1034 | len = 512; | ||
967 | switch (len) { | 1035 | switch (len) { |
968 | case 8: len = 24; break; | 1036 | case 8: |
969 | case 16: len = 32; break; | 1037 | len = 24; |
1038 | break; | ||
1039 | case 16: | ||
1040 | len = 32; | ||
1041 | break; | ||
970 | } | 1042 | } |
971 | expected = -EREMOTEIO; | 1043 | expected = -EREMOTEIO; |
972 | break; | 1044 | break; |
@@ -975,8 +1047,8 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
975 | context.status = -EINVAL; | 1047 | context.status = -EINVAL; |
976 | goto cleanup; | 1048 | goto cleanup; |
977 | } | 1049 | } |
978 | req.wLength = cpu_to_le16 (len); | 1050 | req.wLength = cpu_to_le16(len); |
979 | urb [i] = u = simple_alloc_urb (udev, pipe, len); | 1051 | urb[i] = u = simple_alloc_urb(udev, pipe, len); |
980 | if (!u) | 1052 | if (!u) |
981 | goto cleanup; | 1053 | goto cleanup; |
982 | 1054 | ||
@@ -994,9 +1066,9 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
994 | 1066 | ||
995 | /* queue the urbs */ | 1067 | /* queue the urbs */ |
996 | context.urb = urb; | 1068 | context.urb = urb; |
997 | spin_lock_irq (&context.lock); | 1069 | spin_lock_irq(&context.lock); |
998 | for (i = 0; i < param->sglen; i++) { | 1070 | for (i = 0; i < param->sglen; i++) { |
999 | context.status = usb_submit_urb (urb [i], GFP_ATOMIC); | 1071 | context.status = usb_submit_urb(urb[i], GFP_ATOMIC); |
1000 | if (context.status != 0) { | 1072 | if (context.status != 0) { |
1001 | ERROR(dev, "can't submit urb[%d], status %d\n", | 1073 | ERROR(dev, "can't submit urb[%d], status %d\n", |
1002 | i, context.status); | 1074 | i, context.status); |
@@ -1005,23 +1077,23 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
1005 | } | 1077 | } |
1006 | context.pending++; | 1078 | context.pending++; |
1007 | } | 1079 | } |
1008 | spin_unlock_irq (&context.lock); | 1080 | spin_unlock_irq(&context.lock); |
1009 | 1081 | ||
1010 | /* FIXME set timer and time out; provide a disconnect hook */ | 1082 | /* FIXME set timer and time out; provide a disconnect hook */ |
1011 | 1083 | ||
1012 | /* wait for the last one to complete */ | 1084 | /* wait for the last one to complete */ |
1013 | if (context.pending > 0) | 1085 | if (context.pending > 0) |
1014 | wait_for_completion (&context.complete); | 1086 | wait_for_completion(&context.complete); |
1015 | 1087 | ||
1016 | cleanup: | 1088 | cleanup: |
1017 | for (i = 0; i < param->sglen; i++) { | 1089 | for (i = 0; i < param->sglen; i++) { |
1018 | if (!urb [i]) | 1090 | if (!urb[i]) |
1019 | continue; | 1091 | continue; |
1020 | urb [i]->dev = udev; | 1092 | urb[i]->dev = udev; |
1021 | kfree(urb[i]->setup_packet); | 1093 | kfree(urb[i]->setup_packet); |
1022 | simple_free_urb (urb [i]); | 1094 | simple_free_urb(urb[i]); |
1023 | } | 1095 | } |
1024 | kfree (urb); | 1096 | kfree(urb); |
1025 | return context.status; | 1097 | return context.status; |
1026 | } | 1098 | } |
1027 | #undef NUM_SUBCASES | 1099 | #undef NUM_SUBCASES |
@@ -1029,27 +1101,27 @@ cleanup: | |||
1029 | 1101 | ||
1030 | /*-------------------------------------------------------------------------*/ | 1102 | /*-------------------------------------------------------------------------*/ |
1031 | 1103 | ||
1032 | static void unlink1_callback (struct urb *urb) | 1104 | static void unlink1_callback(struct urb *urb) |
1033 | { | 1105 | { |
1034 | int status = urb->status; | 1106 | int status = urb->status; |
1035 | 1107 | ||
1036 | // we "know" -EPIPE (stall) never happens | 1108 | /* we "know" -EPIPE (stall) never happens */ |
1037 | if (!status) | 1109 | if (!status) |
1038 | status = usb_submit_urb (urb, GFP_ATOMIC); | 1110 | status = usb_submit_urb(urb, GFP_ATOMIC); |
1039 | if (status) { | 1111 | if (status) { |
1040 | urb->status = status; | 1112 | urb->status = status; |
1041 | complete(urb->context); | 1113 | complete(urb->context); |
1042 | } | 1114 | } |
1043 | } | 1115 | } |
1044 | 1116 | ||
1045 | static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | 1117 | static int unlink1(struct usbtest_dev *dev, int pipe, int size, int async) |
1046 | { | 1118 | { |
1047 | struct urb *urb; | 1119 | struct urb *urb; |
1048 | struct completion completion; | 1120 | struct completion completion; |
1049 | int retval = 0; | 1121 | int retval = 0; |
1050 | 1122 | ||
1051 | init_completion (&completion); | 1123 | init_completion(&completion); |
1052 | urb = simple_alloc_urb (testdev_to_usbdev (dev), pipe, size); | 1124 | urb = simple_alloc_urb(testdev_to_usbdev(dev), pipe, size); |
1053 | if (!urb) | 1125 | if (!urb) |
1054 | return -ENOMEM; | 1126 | return -ENOMEM; |
1055 | urb->context = &completion; | 1127 | urb->context = &completion; |
@@ -1061,7 +1133,8 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | |||
1061 | * FIXME want additional tests for when endpoint is STALLing | 1133 | * FIXME want additional tests for when endpoint is STALLing |
1062 | * due to errors, or is just NAKing requests. | 1134 | * due to errors, or is just NAKing requests. |
1063 | */ | 1135 | */ |
1064 | if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) { | 1136 | retval = usb_submit_urb(urb, GFP_KERNEL); |
1137 | if (retval != 0) { | ||
1065 | dev_err(&dev->intf->dev, "submit fail %d\n", retval); | 1138 | dev_err(&dev->intf->dev, "submit fail %d\n", retval); |
1066 | return retval; | 1139 | return retval; |
1067 | } | 1140 | } |
@@ -1069,7 +1142,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | |||
1069 | /* unlinking that should always work. variable delay tests more | 1142 | /* unlinking that should always work. variable delay tests more |
1070 | * hcd states and code paths, even with little other system load. | 1143 | * hcd states and code paths, even with little other system load. |
1071 | */ | 1144 | */ |
1072 | msleep (jiffies % (2 * INTERRUPT_RATE)); | 1145 | msleep(jiffies % (2 * INTERRUPT_RATE)); |
1073 | if (async) { | 1146 | if (async) { |
1074 | while (!completion_done(&completion)) { | 1147 | while (!completion_done(&completion)) { |
1075 | retval = usb_unlink_urb(urb); | 1148 | retval = usb_unlink_urb(urb); |
@@ -1098,11 +1171,11 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | |||
1098 | break; | 1171 | break; |
1099 | } | 1172 | } |
1100 | } else | 1173 | } else |
1101 | usb_kill_urb (urb); | 1174 | usb_kill_urb(urb); |
1102 | 1175 | ||
1103 | wait_for_completion (&completion); | 1176 | wait_for_completion(&completion); |
1104 | retval = urb->status; | 1177 | retval = urb->status; |
1105 | simple_free_urb (urb); | 1178 | simple_free_urb(urb); |
1106 | 1179 | ||
1107 | if (async) | 1180 | if (async) |
1108 | return (retval == -ECONNRESET) ? 0 : retval - 1000; | 1181 | return (retval == -ECONNRESET) ? 0 : retval - 1000; |
@@ -1111,14 +1184,112 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) | |||
1111 | 0 : retval - 2000; | 1184 | 0 : retval - 2000; |
1112 | } | 1185 | } |
1113 | 1186 | ||
1114 | static int unlink_simple (struct usbtest_dev *dev, int pipe, int len) | 1187 | static int unlink_simple(struct usbtest_dev *dev, int pipe, int len) |
1115 | { | 1188 | { |
1116 | int retval = 0; | 1189 | int retval = 0; |
1117 | 1190 | ||
1118 | /* test sync and async paths */ | 1191 | /* test sync and async paths */ |
1119 | retval = unlink1 (dev, pipe, len, 1); | 1192 | retval = unlink1(dev, pipe, len, 1); |
1120 | if (!retval) | 1193 | if (!retval) |
1121 | retval = unlink1 (dev, pipe, len, 0); | 1194 | retval = unlink1(dev, pipe, len, 0); |
1195 | return retval; | ||
1196 | } | ||
1197 | |||
1198 | /*-------------------------------------------------------------------------*/ | ||
1199 | |||
1200 | struct queued_ctx { | ||
1201 | struct completion complete; | ||
1202 | atomic_t pending; | ||
1203 | unsigned num; | ||
1204 | int status; | ||
1205 | struct urb **urbs; | ||
1206 | }; | ||
1207 | |||
1208 | static void unlink_queued_callback(struct urb *urb) | ||
1209 | { | ||
1210 | int status = urb->status; | ||
1211 | struct queued_ctx *ctx = urb->context; | ||
1212 | |||
1213 | if (ctx->status) | ||
1214 | goto done; | ||
1215 | if (urb == ctx->urbs[ctx->num - 4] || urb == ctx->urbs[ctx->num - 2]) { | ||
1216 | if (status == -ECONNRESET) | ||
1217 | goto done; | ||
1218 | /* What error should we report if the URB completed normally? */ | ||
1219 | } | ||
1220 | if (status != 0) | ||
1221 | ctx->status = status; | ||
1222 | |||
1223 | done: | ||
1224 | if (atomic_dec_and_test(&ctx->pending)) | ||
1225 | complete(&ctx->complete); | ||
1226 | } | ||
1227 | |||
1228 | static int unlink_queued(struct usbtest_dev *dev, int pipe, unsigned num, | ||
1229 | unsigned size) | ||
1230 | { | ||
1231 | struct queued_ctx ctx; | ||
1232 | struct usb_device *udev = testdev_to_usbdev(dev); | ||
1233 | void *buf; | ||
1234 | dma_addr_t buf_dma; | ||
1235 | int i; | ||
1236 | int retval = -ENOMEM; | ||
1237 | |||
1238 | init_completion(&ctx.complete); | ||
1239 | atomic_set(&ctx.pending, 1); /* One more than the actual value */ | ||
1240 | ctx.num = num; | ||
1241 | ctx.status = 0; | ||
1242 | |||
1243 | buf = usb_alloc_coherent(udev, size, GFP_KERNEL, &buf_dma); | ||
1244 | if (!buf) | ||
1245 | return retval; | ||
1246 | memset(buf, 0, size); | ||
1247 | |||
1248 | /* Allocate and init the urbs we'll queue */ | ||
1249 | ctx.urbs = kcalloc(num, sizeof(struct urb *), GFP_KERNEL); | ||
1250 | if (!ctx.urbs) | ||
1251 | goto free_buf; | ||
1252 | for (i = 0; i < num; i++) { | ||
1253 | ctx.urbs[i] = usb_alloc_urb(0, GFP_KERNEL); | ||
1254 | if (!ctx.urbs[i]) | ||
1255 | goto free_urbs; | ||
1256 | usb_fill_bulk_urb(ctx.urbs[i], udev, pipe, buf, size, | ||
1257 | unlink_queued_callback, &ctx); | ||
1258 | ctx.urbs[i]->transfer_dma = buf_dma; | ||
1259 | ctx.urbs[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | ||
1260 | } | ||
1261 | |||
1262 | /* Submit all the URBs and then unlink URBs num - 4 and num - 2. */ | ||
1263 | for (i = 0; i < num; i++) { | ||
1264 | atomic_inc(&ctx.pending); | ||
1265 | retval = usb_submit_urb(ctx.urbs[i], GFP_KERNEL); | ||
1266 | if (retval != 0) { | ||
1267 | dev_err(&dev->intf->dev, "submit urbs[%d] fail %d\n", | ||
1268 | i, retval); | ||
1269 | atomic_dec(&ctx.pending); | ||
1270 | ctx.status = retval; | ||
1271 | break; | ||
1272 | } | ||
1273 | } | ||
1274 | if (i == num) { | ||
1275 | usb_unlink_urb(ctx.urbs[num - 4]); | ||
1276 | usb_unlink_urb(ctx.urbs[num - 2]); | ||
1277 | } else { | ||
1278 | while (--i >= 0) | ||
1279 | usb_unlink_urb(ctx.urbs[i]); | ||
1280 | } | ||
1281 | |||
1282 | if (atomic_dec_and_test(&ctx.pending)) /* The extra count */ | ||
1283 | complete(&ctx.complete); | ||
1284 | wait_for_completion(&ctx.complete); | ||
1285 | retval = ctx.status; | ||
1286 | |||
1287 | free_urbs: | ||
1288 | for (i = 0; i < num; i++) | ||
1289 | usb_free_urb(ctx.urbs[i]); | ||
1290 | kfree(ctx.urbs); | ||
1291 | free_buf: | ||
1292 | usb_free_coherent(udev, size, buf, buf_dma); | ||
1122 | return retval; | 1293 | return retval; |
1123 | } | 1294 | } |
1124 | 1295 | ||
@@ -1130,7 +1301,7 @@ static int verify_not_halted(struct usbtest_dev *tdev, int ep, struct urb *urb) | |||
1130 | u16 status; | 1301 | u16 status; |
1131 | 1302 | ||
1132 | /* shouldn't look or act halted */ | 1303 | /* shouldn't look or act halted */ |
1133 | retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); | 1304 | retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status); |
1134 | if (retval < 0) { | 1305 | if (retval < 0) { |
1135 | ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n", | 1306 | ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n", |
1136 | ep, retval); | 1307 | ep, retval); |
@@ -1152,7 +1323,7 @@ static int verify_halted(struct usbtest_dev *tdev, int ep, struct urb *urb) | |||
1152 | u16 status; | 1323 | u16 status; |
1153 | 1324 | ||
1154 | /* should look and act halted */ | 1325 | /* should look and act halted */ |
1155 | retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status); | 1326 | retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status); |
1156 | if (retval < 0) { | 1327 | if (retval < 0) { |
1157 | ERROR(tdev, "ep %02x couldn't get halt status, %d\n", | 1328 | ERROR(tdev, "ep %02x couldn't get halt status, %d\n", |
1158 | ep, retval); | 1329 | ep, retval); |
@@ -1182,7 +1353,7 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb) | |||
1182 | return retval; | 1353 | return retval; |
1183 | 1354 | ||
1184 | /* set halt (protocol test only), verify it worked */ | 1355 | /* set halt (protocol test only), verify it worked */ |
1185 | retval = usb_control_msg (urb->dev, usb_sndctrlpipe (urb->dev, 0), | 1356 | retval = usb_control_msg(urb->dev, usb_sndctrlpipe(urb->dev, 0), |
1186 | USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT, | 1357 | USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT, |
1187 | USB_ENDPOINT_HALT, ep, | 1358 | USB_ENDPOINT_HALT, ep, |
1188 | NULL, 0, USB_CTRL_SET_TIMEOUT); | 1359 | NULL, 0, USB_CTRL_SET_TIMEOUT); |
@@ -1195,7 +1366,7 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb) | |||
1195 | return retval; | 1366 | return retval; |
1196 | 1367 | ||
1197 | /* clear halt (tests API + protocol), verify it worked */ | 1368 | /* clear halt (tests API + protocol), verify it worked */ |
1198 | retval = usb_clear_halt (urb->dev, urb->pipe); | 1369 | retval = usb_clear_halt(urb->dev, urb->pipe); |
1199 | if (retval < 0) { | 1370 | if (retval < 0) { |
1200 | ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval); | 1371 | ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval); |
1201 | return retval; | 1372 | return retval; |
@@ -1209,18 +1380,18 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb) | |||
1209 | return 0; | 1380 | return 0; |
1210 | } | 1381 | } |
1211 | 1382 | ||
1212 | static int halt_simple (struct usbtest_dev *dev) | 1383 | static int halt_simple(struct usbtest_dev *dev) |
1213 | { | 1384 | { |
1214 | int ep; | 1385 | int ep; |
1215 | int retval = 0; | 1386 | int retval = 0; |
1216 | struct urb *urb; | 1387 | struct urb *urb; |
1217 | 1388 | ||
1218 | urb = simple_alloc_urb (testdev_to_usbdev (dev), 0, 512); | 1389 | urb = simple_alloc_urb(testdev_to_usbdev(dev), 0, 512); |
1219 | if (urb == NULL) | 1390 | if (urb == NULL) |
1220 | return -ENOMEM; | 1391 | return -ENOMEM; |
1221 | 1392 | ||
1222 | if (dev->in_pipe) { | 1393 | if (dev->in_pipe) { |
1223 | ep = usb_pipeendpoint (dev->in_pipe) | USB_DIR_IN; | 1394 | ep = usb_pipeendpoint(dev->in_pipe) | USB_DIR_IN; |
1224 | urb->pipe = dev->in_pipe; | 1395 | urb->pipe = dev->in_pipe; |
1225 | retval = test_halt(dev, ep, urb); | 1396 | retval = test_halt(dev, ep, urb); |
1226 | if (retval < 0) | 1397 | if (retval < 0) |
@@ -1228,12 +1399,12 @@ static int halt_simple (struct usbtest_dev *dev) | |||
1228 | } | 1399 | } |
1229 | 1400 | ||
1230 | if (dev->out_pipe) { | 1401 | if (dev->out_pipe) { |
1231 | ep = usb_pipeendpoint (dev->out_pipe); | 1402 | ep = usb_pipeendpoint(dev->out_pipe); |
1232 | urb->pipe = dev->out_pipe; | 1403 | urb->pipe = dev->out_pipe; |
1233 | retval = test_halt(dev, ep, urb); | 1404 | retval = test_halt(dev, ep, urb); |
1234 | } | 1405 | } |
1235 | done: | 1406 | done: |
1236 | simple_free_urb (urb); | 1407 | simple_free_urb(urb); |
1237 | return retval; | 1408 | return retval; |
1238 | } | 1409 | } |
1239 | 1410 | ||
@@ -1247,8 +1418,8 @@ done: | |||
1247 | * need to be able to handle more than one OUT data packet. We'll | 1418 | * need to be able to handle more than one OUT data packet. We'll |
1248 | * try whatever we're told to try. | 1419 | * try whatever we're told to try. |
1249 | */ | 1420 | */ |
1250 | static int ctrl_out (struct usbtest_dev *dev, | 1421 | static int ctrl_out(struct usbtest_dev *dev, |
1251 | unsigned count, unsigned length, unsigned vary) | 1422 | unsigned count, unsigned length, unsigned vary, unsigned offset) |
1252 | { | 1423 | { |
1253 | unsigned i, j, len; | 1424 | unsigned i, j, len; |
1254 | int retval; | 1425 | int retval; |
@@ -1259,11 +1430,12 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1259 | if (length < 1 || length > 0xffff || vary >= length) | 1430 | if (length < 1 || length > 0xffff || vary >= length) |
1260 | return -EINVAL; | 1431 | return -EINVAL; |
1261 | 1432 | ||
1262 | buf = kmalloc(length, GFP_KERNEL); | 1433 | buf = kmalloc(length + offset, GFP_KERNEL); |
1263 | if (!buf) | 1434 | if (!buf) |
1264 | return -ENOMEM; | 1435 | return -ENOMEM; |
1265 | 1436 | ||
1266 | udev = testdev_to_usbdev (dev); | 1437 | buf += offset; |
1438 | udev = testdev_to_usbdev(dev); | ||
1267 | len = length; | 1439 | len = length; |
1268 | retval = 0; | 1440 | retval = 0; |
1269 | 1441 | ||
@@ -1273,8 +1445,8 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1273 | for (i = 0; i < count; i++) { | 1445 | for (i = 0; i < count; i++) { |
1274 | /* write patterned data */ | 1446 | /* write patterned data */ |
1275 | for (j = 0; j < len; j++) | 1447 | for (j = 0; j < len; j++) |
1276 | buf [j] = i + j; | 1448 | buf[j] = i + j; |
1277 | retval = usb_control_msg (udev, usb_sndctrlpipe (udev,0), | 1449 | retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
1278 | 0x5b, USB_DIR_OUT|USB_TYPE_VENDOR, | 1450 | 0x5b, USB_DIR_OUT|USB_TYPE_VENDOR, |
1279 | 0, 0, buf, len, USB_CTRL_SET_TIMEOUT); | 1451 | 0, 0, buf, len, USB_CTRL_SET_TIMEOUT); |
1280 | if (retval != len) { | 1452 | if (retval != len) { |
@@ -1288,7 +1460,7 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1288 | } | 1460 | } |
1289 | 1461 | ||
1290 | /* read it back -- assuming nothing intervened!! */ | 1462 | /* read it back -- assuming nothing intervened!! */ |
1291 | retval = usb_control_msg (udev, usb_rcvctrlpipe (udev,0), | 1463 | retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
1292 | 0x5c, USB_DIR_IN|USB_TYPE_VENDOR, | 1464 | 0x5c, USB_DIR_IN|USB_TYPE_VENDOR, |
1293 | 0, 0, buf, len, USB_CTRL_GET_TIMEOUT); | 1465 | 0, 0, buf, len, USB_CTRL_GET_TIMEOUT); |
1294 | if (retval != len) { | 1466 | if (retval != len) { |
@@ -1303,9 +1475,9 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1303 | 1475 | ||
1304 | /* fail if we can't verify */ | 1476 | /* fail if we can't verify */ |
1305 | for (j = 0; j < len; j++) { | 1477 | for (j = 0; j < len; j++) { |
1306 | if (buf [j] != (u8) (i + j)) { | 1478 | if (buf[j] != (u8) (i + j)) { |
1307 | ERROR(dev, "ctrl_out, byte %d is %d not %d\n", | 1479 | ERROR(dev, "ctrl_out, byte %d is %d not %d\n", |
1308 | j, buf [j], (u8) i + j); | 1480 | j, buf[j], (u8) i + j); |
1309 | retval = -EBADMSG; | 1481 | retval = -EBADMSG; |
1310 | break; | 1482 | break; |
1311 | } | 1483 | } |
@@ -1326,10 +1498,10 @@ static int ctrl_out (struct usbtest_dev *dev, | |||
1326 | } | 1498 | } |
1327 | 1499 | ||
1328 | if (retval < 0) | 1500 | if (retval < 0) |
1329 | ERROR (dev, "ctrl_out %s failed, code %d, count %d\n", | 1501 | ERROR(dev, "ctrl_out %s failed, code %d, count %d\n", |
1330 | what, retval, i); | 1502 | what, retval, i); |
1331 | 1503 | ||
1332 | kfree (buf); | 1504 | kfree(buf - offset); |
1333 | return retval; | 1505 | return retval; |
1334 | } | 1506 | } |
1335 | 1507 | ||
@@ -1351,7 +1523,7 @@ struct iso_context { | |||
1351 | struct usbtest_dev *dev; | 1523 | struct usbtest_dev *dev; |
1352 | }; | 1524 | }; |
1353 | 1525 | ||
1354 | static void iso_callback (struct urb *urb) | 1526 | static void iso_callback(struct urb *urb) |
1355 | { | 1527 | { |
1356 | struct iso_context *ctx = urb->context; | 1528 | struct iso_context *ctx = urb->context; |
1357 | 1529 | ||
@@ -1363,10 +1535,14 @@ static void iso_callback (struct urb *urb) | |||
1363 | ctx->errors += urb->error_count; | 1535 | ctx->errors += urb->error_count; |
1364 | else if (urb->status != 0) | 1536 | else if (urb->status != 0) |
1365 | ctx->errors += urb->number_of_packets; | 1537 | ctx->errors += urb->number_of_packets; |
1538 | else if (urb->actual_length != urb->transfer_buffer_length) | ||
1539 | ctx->errors++; | ||
1540 | else if (check_guard_bytes(ctx->dev, urb) != 0) | ||
1541 | ctx->errors++; | ||
1366 | 1542 | ||
1367 | if (urb->status == 0 && ctx->count > (ctx->pending - 1) | 1543 | if (urb->status == 0 && ctx->count > (ctx->pending - 1) |
1368 | && !ctx->submit_error) { | 1544 | && !ctx->submit_error) { |
1369 | int status = usb_submit_urb (urb, GFP_ATOMIC); | 1545 | int status = usb_submit_urb(urb, GFP_ATOMIC); |
1370 | switch (status) { | 1546 | switch (status) { |
1371 | case 0: | 1547 | case 0: |
1372 | goto done; | 1548 | goto done; |
@@ -1388,17 +1564,18 @@ static void iso_callback (struct urb *urb) | |||
1388 | dev_err(&ctx->dev->intf->dev, | 1564 | dev_err(&ctx->dev->intf->dev, |
1389 | "iso test, %lu errors out of %lu\n", | 1565 | "iso test, %lu errors out of %lu\n", |
1390 | ctx->errors, ctx->packet_count); | 1566 | ctx->errors, ctx->packet_count); |
1391 | complete (&ctx->done); | 1567 | complete(&ctx->done); |
1392 | } | 1568 | } |
1393 | done: | 1569 | done: |
1394 | spin_unlock(&ctx->lock); | 1570 | spin_unlock(&ctx->lock); |
1395 | } | 1571 | } |
1396 | 1572 | ||
1397 | static struct urb *iso_alloc_urb ( | 1573 | static struct urb *iso_alloc_urb( |
1398 | struct usb_device *udev, | 1574 | struct usb_device *udev, |
1399 | int pipe, | 1575 | int pipe, |
1400 | struct usb_endpoint_descriptor *desc, | 1576 | struct usb_endpoint_descriptor *desc, |
1401 | long bytes | 1577 | long bytes, |
1578 | unsigned offset | ||
1402 | ) | 1579 | ) |
1403 | { | 1580 | { |
1404 | struct urb *urb; | 1581 | struct urb *urb; |
@@ -1410,7 +1587,7 @@ static struct urb *iso_alloc_urb ( | |||
1410 | maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); | 1587 | maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); |
1411 | packets = DIV_ROUND_UP(bytes, maxp); | 1588 | packets = DIV_ROUND_UP(bytes, maxp); |
1412 | 1589 | ||
1413 | urb = usb_alloc_urb (packets, GFP_KERNEL); | 1590 | urb = usb_alloc_urb(packets, GFP_KERNEL); |
1414 | if (!urb) | 1591 | if (!urb) |
1415 | return urb; | 1592 | return urb; |
1416 | urb->dev = udev; | 1593 | urb->dev = udev; |
@@ -1418,31 +1595,42 @@ static struct urb *iso_alloc_urb ( | |||
1418 | 1595 | ||
1419 | urb->number_of_packets = packets; | 1596 | urb->number_of_packets = packets; |
1420 | urb->transfer_buffer_length = bytes; | 1597 | urb->transfer_buffer_length = bytes; |
1421 | urb->transfer_buffer = usb_alloc_coherent (udev, bytes, GFP_KERNEL, | 1598 | urb->transfer_buffer = usb_alloc_coherent(udev, bytes + offset, |
1422 | &urb->transfer_dma); | 1599 | GFP_KERNEL, |
1600 | &urb->transfer_dma); | ||
1423 | if (!urb->transfer_buffer) { | 1601 | if (!urb->transfer_buffer) { |
1424 | usb_free_urb (urb); | 1602 | usb_free_urb(urb); |
1425 | return NULL; | 1603 | return NULL; |
1426 | } | 1604 | } |
1427 | memset (urb->transfer_buffer, 0, bytes); | 1605 | if (offset) { |
1606 | memset(urb->transfer_buffer, GUARD_BYTE, offset); | ||
1607 | urb->transfer_buffer += offset; | ||
1608 | urb->transfer_dma += offset; | ||
1609 | } | ||
1610 | /* For inbound transfers use guard byte so that test fails if | ||
1611 | data not correctly copied */ | ||
1612 | memset(urb->transfer_buffer, | ||
1613 | usb_pipein(urb->pipe) ? GUARD_BYTE : 0, | ||
1614 | bytes); | ||
1615 | |||
1428 | for (i = 0; i < packets; i++) { | 1616 | for (i = 0; i < packets; i++) { |
1429 | /* here, only the last packet will be short */ | 1617 | /* here, only the last packet will be short */ |
1430 | urb->iso_frame_desc[i].length = min ((unsigned) bytes, maxp); | 1618 | urb->iso_frame_desc[i].length = min((unsigned) bytes, maxp); |
1431 | bytes -= urb->iso_frame_desc[i].length; | 1619 | bytes -= urb->iso_frame_desc[i].length; |
1432 | 1620 | ||
1433 | urb->iso_frame_desc[i].offset = maxp * i; | 1621 | urb->iso_frame_desc[i].offset = maxp * i; |
1434 | } | 1622 | } |
1435 | 1623 | ||
1436 | urb->complete = iso_callback; | 1624 | urb->complete = iso_callback; |
1437 | // urb->context = SET BY CALLER | 1625 | /* urb->context = SET BY CALLER */ |
1438 | urb->interval = 1 << (desc->bInterval - 1); | 1626 | urb->interval = 1 << (desc->bInterval - 1); |
1439 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; | 1627 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; |
1440 | return urb; | 1628 | return urb; |
1441 | } | 1629 | } |
1442 | 1630 | ||
1443 | static int | 1631 | static int |
1444 | test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | 1632 | test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param, |
1445 | int pipe, struct usb_endpoint_descriptor *desc) | 1633 | int pipe, struct usb_endpoint_descriptor *desc, unsigned offset) |
1446 | { | 1634 | { |
1447 | struct iso_context context; | 1635 | struct iso_context context; |
1448 | struct usb_device *udev; | 1636 | struct usb_device *udev; |
@@ -1457,11 +1645,11 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1457 | memset(&context, 0, sizeof context); | 1645 | memset(&context, 0, sizeof context); |
1458 | context.count = param->iterations * param->sglen; | 1646 | context.count = param->iterations * param->sglen; |
1459 | context.dev = dev; | 1647 | context.dev = dev; |
1460 | init_completion (&context.done); | 1648 | init_completion(&context.done); |
1461 | spin_lock_init (&context.lock); | 1649 | spin_lock_init(&context.lock); |
1462 | 1650 | ||
1463 | memset (urbs, 0, sizeof urbs); | 1651 | memset(urbs, 0, sizeof urbs); |
1464 | udev = testdev_to_usbdev (dev); | 1652 | udev = testdev_to_usbdev(dev); |
1465 | dev_info(&dev->intf->dev, | 1653 | dev_info(&dev->intf->dev, |
1466 | "... iso period %d %sframes, wMaxPacket %04x\n", | 1654 | "... iso period %d %sframes, wMaxPacket %04x\n", |
1467 | 1 << (desc->bInterval - 1), | 1655 | 1 << (desc->bInterval - 1), |
@@ -1469,14 +1657,14 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1469 | le16_to_cpu(desc->wMaxPacketSize)); | 1657 | le16_to_cpu(desc->wMaxPacketSize)); |
1470 | 1658 | ||
1471 | for (i = 0; i < param->sglen; i++) { | 1659 | for (i = 0; i < param->sglen; i++) { |
1472 | urbs [i] = iso_alloc_urb (udev, pipe, desc, | 1660 | urbs[i] = iso_alloc_urb(udev, pipe, desc, |
1473 | param->length); | 1661 | param->length, offset); |
1474 | if (!urbs [i]) { | 1662 | if (!urbs[i]) { |
1475 | status = -ENOMEM; | 1663 | status = -ENOMEM; |
1476 | goto fail; | 1664 | goto fail; |
1477 | } | 1665 | } |
1478 | packets += urbs[i]->number_of_packets; | 1666 | packets += urbs[i]->number_of_packets; |
1479 | urbs [i]->context = &context; | 1667 | urbs[i]->context = &context; |
1480 | } | 1668 | } |
1481 | packets *= param->iterations; | 1669 | packets *= param->iterations; |
1482 | dev_info(&dev->intf->dev, | 1670 | dev_info(&dev->intf->dev, |
@@ -1485,27 +1673,27 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1485 | / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), | 1673 | / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1), |
1486 | packets); | 1674 | packets); |
1487 | 1675 | ||
1488 | spin_lock_irq (&context.lock); | 1676 | spin_lock_irq(&context.lock); |
1489 | for (i = 0; i < param->sglen; i++) { | 1677 | for (i = 0; i < param->sglen; i++) { |
1490 | ++context.pending; | 1678 | ++context.pending; |
1491 | status = usb_submit_urb (urbs [i], GFP_ATOMIC); | 1679 | status = usb_submit_urb(urbs[i], GFP_ATOMIC); |
1492 | if (status < 0) { | 1680 | if (status < 0) { |
1493 | ERROR (dev, "submit iso[%d], error %d\n", i, status); | 1681 | ERROR(dev, "submit iso[%d], error %d\n", i, status); |
1494 | if (i == 0) { | 1682 | if (i == 0) { |
1495 | spin_unlock_irq (&context.lock); | 1683 | spin_unlock_irq(&context.lock); |
1496 | goto fail; | 1684 | goto fail; |
1497 | } | 1685 | } |
1498 | 1686 | ||
1499 | simple_free_urb (urbs [i]); | 1687 | simple_free_urb(urbs[i]); |
1500 | urbs[i] = NULL; | 1688 | urbs[i] = NULL; |
1501 | context.pending--; | 1689 | context.pending--; |
1502 | context.submit_error = 1; | 1690 | context.submit_error = 1; |
1503 | break; | 1691 | break; |
1504 | } | 1692 | } |
1505 | } | 1693 | } |
1506 | spin_unlock_irq (&context.lock); | 1694 | spin_unlock_irq(&context.lock); |
1507 | 1695 | ||
1508 | wait_for_completion (&context.done); | 1696 | wait_for_completion(&context.done); |
1509 | 1697 | ||
1510 | for (i = 0; i < param->sglen; i++) { | 1698 | for (i = 0; i < param->sglen; i++) { |
1511 | if (urbs[i]) | 1699 | if (urbs[i]) |
@@ -1526,12 +1714,32 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, | |||
1526 | 1714 | ||
1527 | fail: | 1715 | fail: |
1528 | for (i = 0; i < param->sglen; i++) { | 1716 | for (i = 0; i < param->sglen; i++) { |
1529 | if (urbs [i]) | 1717 | if (urbs[i]) |
1530 | simple_free_urb (urbs [i]); | 1718 | simple_free_urb(urbs[i]); |
1531 | } | 1719 | } |
1532 | return status; | 1720 | return status; |
1533 | } | 1721 | } |
1534 | 1722 | ||
1723 | static int test_unaligned_bulk( | ||
1724 | struct usbtest_dev *tdev, | ||
1725 | int pipe, | ||
1726 | unsigned length, | ||
1727 | int iterations, | ||
1728 | unsigned transfer_flags, | ||
1729 | const char *label) | ||
1730 | { | ||
1731 | int retval; | ||
1732 | struct urb *urb = usbtest_alloc_urb( | ||
1733 | testdev_to_usbdev(tdev), pipe, length, transfer_flags, 1); | ||
1734 | |||
1735 | if (!urb) | ||
1736 | return -ENOMEM; | ||
1737 | |||
1738 | retval = simple_io(tdev, urb, iterations, 0, 0, label); | ||
1739 | simple_free_urb(urb); | ||
1740 | return retval; | ||
1741 | } | ||
1742 | |||
1535 | /*-------------------------------------------------------------------------*/ | 1743 | /*-------------------------------------------------------------------------*/ |
1536 | 1744 | ||
1537 | /* We only have this one interface to user space, through usbfs. | 1745 | /* We only have this one interface to user space, through usbfs. |
@@ -1557,10 +1765,10 @@ fail: | |||
1557 | 1765 | ||
1558 | /* No BKL needed */ | 1766 | /* No BKL needed */ |
1559 | static int | 1767 | static int |
1560 | usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | 1768 | usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf) |
1561 | { | 1769 | { |
1562 | struct usbtest_dev *dev = usb_get_intfdata (intf); | 1770 | struct usbtest_dev *dev = usb_get_intfdata(intf); |
1563 | struct usb_device *udev = testdev_to_usbdev (dev); | 1771 | struct usb_device *udev = testdev_to_usbdev(dev); |
1564 | struct usbtest_param *param = buf; | 1772 | struct usbtest_param *param = buf; |
1565 | int retval = -EOPNOTSUPP; | 1773 | int retval = -EOPNOTSUPP; |
1566 | struct urb *urb; | 1774 | struct urb *urb; |
@@ -1569,7 +1777,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1569 | struct timeval start; | 1777 | struct timeval start; |
1570 | unsigned i; | 1778 | unsigned i; |
1571 | 1779 | ||
1572 | // FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. | 1780 | /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */ |
1573 | 1781 | ||
1574 | pattern = mod_pattern; | 1782 | pattern = mod_pattern; |
1575 | 1783 | ||
@@ -1595,9 +1803,9 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1595 | mutex_unlock(&dev->lock); | 1803 | mutex_unlock(&dev->lock); |
1596 | return -ENODEV; | 1804 | return -ENODEV; |
1597 | } | 1805 | } |
1598 | res = set_altsetting (dev, dev->info->alt); | 1806 | res = set_altsetting(dev, dev->info->alt); |
1599 | if (res) { | 1807 | if (res) { |
1600 | dev_err (&intf->dev, | 1808 | dev_err(&intf->dev, |
1601 | "set altsetting to %d failed, %d\n", | 1809 | "set altsetting to %d failed, %d\n", |
1602 | dev->info->alt, res); | 1810 | dev->info->alt, res); |
1603 | mutex_unlock(&dev->lock); | 1811 | mutex_unlock(&dev->lock); |
@@ -1614,7 +1822,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1614 | * FIXME add more tests! cancel requests, verify the data, control | 1822 | * FIXME add more tests! cancel requests, verify the data, control |
1615 | * queueing, concurrent read+write threads, and so on. | 1823 | * queueing, concurrent read+write threads, and so on. |
1616 | */ | 1824 | */ |
1617 | do_gettimeofday (&start); | 1825 | do_gettimeofday(&start); |
1618 | switch (param->test_num) { | 1826 | switch (param->test_num) { |
1619 | 1827 | ||
1620 | case 0: | 1828 | case 0: |
@@ -1629,14 +1837,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1629 | dev_info(&intf->dev, | 1837 | dev_info(&intf->dev, |
1630 | "TEST 1: write %d bytes %u times\n", | 1838 | "TEST 1: write %d bytes %u times\n", |
1631 | param->length, param->iterations); | 1839 | param->length, param->iterations); |
1632 | urb = simple_alloc_urb (udev, dev->out_pipe, param->length); | 1840 | urb = simple_alloc_urb(udev, dev->out_pipe, param->length); |
1633 | if (!urb) { | 1841 | if (!urb) { |
1634 | retval = -ENOMEM; | 1842 | retval = -ENOMEM; |
1635 | break; | 1843 | break; |
1636 | } | 1844 | } |
1637 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1845 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
1638 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); | 1846 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); |
1639 | simple_free_urb (urb); | 1847 | simple_free_urb(urb); |
1640 | break; | 1848 | break; |
1641 | case 2: | 1849 | case 2: |
1642 | if (dev->in_pipe == 0) | 1850 | if (dev->in_pipe == 0) |
@@ -1644,14 +1852,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1644 | dev_info(&intf->dev, | 1852 | dev_info(&intf->dev, |
1645 | "TEST 2: read %d bytes %u times\n", | 1853 | "TEST 2: read %d bytes %u times\n", |
1646 | param->length, param->iterations); | 1854 | param->length, param->iterations); |
1647 | urb = simple_alloc_urb (udev, dev->in_pipe, param->length); | 1855 | urb = simple_alloc_urb(udev, dev->in_pipe, param->length); |
1648 | if (!urb) { | 1856 | if (!urb) { |
1649 | retval = -ENOMEM; | 1857 | retval = -ENOMEM; |
1650 | break; | 1858 | break; |
1651 | } | 1859 | } |
1652 | // FIRMWARE: bulk source (maybe generates short writes) | 1860 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
1653 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); | 1861 | retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); |
1654 | simple_free_urb (urb); | 1862 | simple_free_urb(urb); |
1655 | break; | 1863 | break; |
1656 | case 3: | 1864 | case 3: |
1657 | if (dev->out_pipe == 0 || param->vary == 0) | 1865 | if (dev->out_pipe == 0 || param->vary == 0) |
@@ -1659,15 +1867,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1659 | dev_info(&intf->dev, | 1867 | dev_info(&intf->dev, |
1660 | "TEST 3: write/%d 0..%d bytes %u times\n", | 1868 | "TEST 3: write/%d 0..%d bytes %u times\n", |
1661 | param->vary, param->length, param->iterations); | 1869 | param->vary, param->length, param->iterations); |
1662 | urb = simple_alloc_urb (udev, dev->out_pipe, param->length); | 1870 | urb = simple_alloc_urb(udev, dev->out_pipe, param->length); |
1663 | if (!urb) { | 1871 | if (!urb) { |
1664 | retval = -ENOMEM; | 1872 | retval = -ENOMEM; |
1665 | break; | 1873 | break; |
1666 | } | 1874 | } |
1667 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1875 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
1668 | retval = simple_io(dev, urb, param->iterations, param->vary, | 1876 | retval = simple_io(dev, urb, param->iterations, param->vary, |
1669 | 0, "test3"); | 1877 | 0, "test3"); |
1670 | simple_free_urb (urb); | 1878 | simple_free_urb(urb); |
1671 | break; | 1879 | break; |
1672 | case 4: | 1880 | case 4: |
1673 | if (dev->in_pipe == 0 || param->vary == 0) | 1881 | if (dev->in_pipe == 0 || param->vary == 0) |
@@ -1675,15 +1883,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1675 | dev_info(&intf->dev, | 1883 | dev_info(&intf->dev, |
1676 | "TEST 4: read/%d 0..%d bytes %u times\n", | 1884 | "TEST 4: read/%d 0..%d bytes %u times\n", |
1677 | param->vary, param->length, param->iterations); | 1885 | param->vary, param->length, param->iterations); |
1678 | urb = simple_alloc_urb (udev, dev->in_pipe, param->length); | 1886 | urb = simple_alloc_urb(udev, dev->in_pipe, param->length); |
1679 | if (!urb) { | 1887 | if (!urb) { |
1680 | retval = -ENOMEM; | 1888 | retval = -ENOMEM; |
1681 | break; | 1889 | break; |
1682 | } | 1890 | } |
1683 | // FIRMWARE: bulk source (maybe generates short writes) | 1891 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
1684 | retval = simple_io(dev, urb, param->iterations, param->vary, | 1892 | retval = simple_io(dev, urb, param->iterations, param->vary, |
1685 | 0, "test4"); | 1893 | 0, "test4"); |
1686 | simple_free_urb (urb); | 1894 | simple_free_urb(urb); |
1687 | break; | 1895 | break; |
1688 | 1896 | ||
1689 | /* Queued bulk I/O tests */ | 1897 | /* Queued bulk I/O tests */ |
@@ -1694,15 +1902,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1694 | "TEST 5: write %d sglists %d entries of %d bytes\n", | 1902 | "TEST 5: write %d sglists %d entries of %d bytes\n", |
1695 | param->iterations, | 1903 | param->iterations, |
1696 | param->sglen, param->length); | 1904 | param->sglen, param->length); |
1697 | sg = alloc_sglist (param->sglen, param->length, 0); | 1905 | sg = alloc_sglist(param->sglen, param->length, 0); |
1698 | if (!sg) { | 1906 | if (!sg) { |
1699 | retval = -ENOMEM; | 1907 | retval = -ENOMEM; |
1700 | break; | 1908 | break; |
1701 | } | 1909 | } |
1702 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1910 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
1703 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, | 1911 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, |
1704 | &req, sg, param->sglen); | 1912 | &req, sg, param->sglen); |
1705 | free_sglist (sg, param->sglen); | 1913 | free_sglist(sg, param->sglen); |
1706 | break; | 1914 | break; |
1707 | 1915 | ||
1708 | case 6: | 1916 | case 6: |
@@ -1712,15 +1920,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1712 | "TEST 6: read %d sglists %d entries of %d bytes\n", | 1920 | "TEST 6: read %d sglists %d entries of %d bytes\n", |
1713 | param->iterations, | 1921 | param->iterations, |
1714 | param->sglen, param->length); | 1922 | param->sglen, param->length); |
1715 | sg = alloc_sglist (param->sglen, param->length, 0); | 1923 | sg = alloc_sglist(param->sglen, param->length, 0); |
1716 | if (!sg) { | 1924 | if (!sg) { |
1717 | retval = -ENOMEM; | 1925 | retval = -ENOMEM; |
1718 | break; | 1926 | break; |
1719 | } | 1927 | } |
1720 | // FIRMWARE: bulk source (maybe generates short writes) | 1928 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
1721 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, | 1929 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, |
1722 | &req, sg, param->sglen); | 1930 | &req, sg, param->sglen); |
1723 | free_sglist (sg, param->sglen); | 1931 | free_sglist(sg, param->sglen); |
1724 | break; | 1932 | break; |
1725 | case 7: | 1933 | case 7: |
1726 | if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) | 1934 | if (dev->out_pipe == 0 || param->sglen == 0 || param->vary == 0) |
@@ -1729,15 +1937,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1729 | "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n", | 1937 | "TEST 7: write/%d %d sglists %d entries 0..%d bytes\n", |
1730 | param->vary, param->iterations, | 1938 | param->vary, param->iterations, |
1731 | param->sglen, param->length); | 1939 | param->sglen, param->length); |
1732 | sg = alloc_sglist (param->sglen, param->length, param->vary); | 1940 | sg = alloc_sglist(param->sglen, param->length, param->vary); |
1733 | if (!sg) { | 1941 | if (!sg) { |
1734 | retval = -ENOMEM; | 1942 | retval = -ENOMEM; |
1735 | break; | 1943 | break; |
1736 | } | 1944 | } |
1737 | // FIRMWARE: bulk sink (maybe accepts short writes) | 1945 | /* FIRMWARE: bulk sink (maybe accepts short writes) */ |
1738 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, | 1946 | retval = perform_sglist(dev, param->iterations, dev->out_pipe, |
1739 | &req, sg, param->sglen); | 1947 | &req, sg, param->sglen); |
1740 | free_sglist (sg, param->sglen); | 1948 | free_sglist(sg, param->sglen); |
1741 | break; | 1949 | break; |
1742 | case 8: | 1950 | case 8: |
1743 | if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) | 1951 | if (dev->in_pipe == 0 || param->sglen == 0 || param->vary == 0) |
@@ -1746,15 +1954,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1746 | "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n", | 1954 | "TEST 8: read/%d %d sglists %d entries 0..%d bytes\n", |
1747 | param->vary, param->iterations, | 1955 | param->vary, param->iterations, |
1748 | param->sglen, param->length); | 1956 | param->sglen, param->length); |
1749 | sg = alloc_sglist (param->sglen, param->length, param->vary); | 1957 | sg = alloc_sglist(param->sglen, param->length, param->vary); |
1750 | if (!sg) { | 1958 | if (!sg) { |
1751 | retval = -ENOMEM; | 1959 | retval = -ENOMEM; |
1752 | break; | 1960 | break; |
1753 | } | 1961 | } |
1754 | // FIRMWARE: bulk source (maybe generates short writes) | 1962 | /* FIRMWARE: bulk source (maybe generates short writes) */ |
1755 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, | 1963 | retval = perform_sglist(dev, param->iterations, dev->in_pipe, |
1756 | &req, sg, param->sglen); | 1964 | &req, sg, param->sglen); |
1757 | free_sglist (sg, param->sglen); | 1965 | free_sglist(sg, param->sglen); |
1758 | break; | 1966 | break; |
1759 | 1967 | ||
1760 | /* non-queued sanity tests for control (chapter 9 subset) */ | 1968 | /* non-queued sanity tests for control (chapter 9 subset) */ |
@@ -1764,7 +1972,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1764 | "TEST 9: ch9 (subset) control tests, %d times\n", | 1972 | "TEST 9: ch9 (subset) control tests, %d times\n", |
1765 | param->iterations); | 1973 | param->iterations); |
1766 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 1974 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1767 | retval = ch9_postconfig (dev); | 1975 | retval = ch9_postconfig(dev); |
1768 | if (retval) | 1976 | if (retval) |
1769 | dev_err(&intf->dev, "ch9 subset failed, " | 1977 | dev_err(&intf->dev, "ch9 subset failed, " |
1770 | "iterations left %d\n", i); | 1978 | "iterations left %d\n", i); |
@@ -1779,7 +1987,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1779 | "TEST 10: queue %d control calls, %d times\n", | 1987 | "TEST 10: queue %d control calls, %d times\n", |
1780 | param->sglen, | 1988 | param->sglen, |
1781 | param->iterations); | 1989 | param->iterations); |
1782 | retval = test_ctrl_queue (dev, param); | 1990 | retval = test_ctrl_queue(dev, param); |
1783 | break; | 1991 | break; |
1784 | 1992 | ||
1785 | /* simple non-queued unlinks (ring with one urb) */ | 1993 | /* simple non-queued unlinks (ring with one urb) */ |
@@ -1790,7 +1998,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1790 | dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n", | 1998 | dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n", |
1791 | param->iterations, param->length); | 1999 | param->iterations, param->length); |
1792 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 2000 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1793 | retval = unlink_simple (dev, dev->in_pipe, | 2001 | retval = unlink_simple(dev, dev->in_pipe, |
1794 | param->length); | 2002 | param->length); |
1795 | if (retval) | 2003 | if (retval) |
1796 | dev_err(&intf->dev, "unlink reads failed %d, " | 2004 | dev_err(&intf->dev, "unlink reads failed %d, " |
@@ -1803,7 +2011,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1803 | dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n", | 2011 | dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n", |
1804 | param->iterations, param->length); | 2012 | param->iterations, param->length); |
1805 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 2013 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1806 | retval = unlink_simple (dev, dev->out_pipe, | 2014 | retval = unlink_simple(dev, dev->out_pipe, |
1807 | param->length); | 2015 | param->length); |
1808 | if (retval) | 2016 | if (retval) |
1809 | dev_err(&intf->dev, "unlink writes failed %d, " | 2017 | dev_err(&intf->dev, "unlink writes failed %d, " |
@@ -1818,7 +2026,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1818 | dev_info(&intf->dev, "TEST 13: set/clear %d halts\n", | 2026 | dev_info(&intf->dev, "TEST 13: set/clear %d halts\n", |
1819 | param->iterations); | 2027 | param->iterations); |
1820 | for (i = param->iterations; retval == 0 && i--; /* NOP */) | 2028 | for (i = param->iterations; retval == 0 && i--; /* NOP */) |
1821 | retval = halt_simple (dev); | 2029 | retval = halt_simple(dev); |
1822 | 2030 | ||
1823 | if (retval) | 2031 | if (retval) |
1824 | ERROR(dev, "halts failed, iterations left %d\n", i); | 2032 | ERROR(dev, "halts failed, iterations left %d\n", i); |
@@ -1833,7 +2041,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1833 | realworld ? 1 : 0, param->length, | 2041 | realworld ? 1 : 0, param->length, |
1834 | param->vary); | 2042 | param->vary); |
1835 | retval = ctrl_out(dev, param->iterations, | 2043 | retval = ctrl_out(dev, param->iterations, |
1836 | param->length, param->vary); | 2044 | param->length, param->vary, 0); |
1837 | break; | 2045 | break; |
1838 | 2046 | ||
1839 | /* iso write tests */ | 2047 | /* iso write tests */ |
@@ -1844,9 +2052,9 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1844 | "TEST 15: write %d iso, %d entries of %d bytes\n", | 2052 | "TEST 15: write %d iso, %d entries of %d bytes\n", |
1845 | param->iterations, | 2053 | param->iterations, |
1846 | param->sglen, param->length); | 2054 | param->sglen, param->length); |
1847 | // FIRMWARE: iso sink | 2055 | /* FIRMWARE: iso sink */ |
1848 | retval = test_iso_queue (dev, param, | 2056 | retval = test_iso_queue(dev, param, |
1849 | dev->out_iso_pipe, dev->iso_out); | 2057 | dev->out_iso_pipe, dev->iso_out, 0); |
1850 | break; | 2058 | break; |
1851 | 2059 | ||
1852 | /* iso read tests */ | 2060 | /* iso read tests */ |
@@ -1857,17 +2065,125 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1857 | "TEST 16: read %d iso, %d entries of %d bytes\n", | 2065 | "TEST 16: read %d iso, %d entries of %d bytes\n", |
1858 | param->iterations, | 2066 | param->iterations, |
1859 | param->sglen, param->length); | 2067 | param->sglen, param->length); |
1860 | // FIRMWARE: iso source | 2068 | /* FIRMWARE: iso source */ |
1861 | retval = test_iso_queue (dev, param, | 2069 | retval = test_iso_queue(dev, param, |
1862 | dev->in_iso_pipe, dev->iso_in); | 2070 | dev->in_iso_pipe, dev->iso_in, 0); |
2071 | break; | ||
2072 | |||
2073 | /* FIXME scatterlist cancel (needs helper thread) */ | ||
2074 | |||
2075 | /* Tests for bulk I/O using DMA mapping by core and odd address */ | ||
2076 | case 17: | ||
2077 | if (dev->out_pipe == 0) | ||
2078 | break; | ||
2079 | dev_info(&intf->dev, | ||
2080 | "TEST 17: write odd addr %d bytes %u times core map\n", | ||
2081 | param->length, param->iterations); | ||
2082 | |||
2083 | retval = test_unaligned_bulk( | ||
2084 | dev, dev->out_pipe, | ||
2085 | param->length, param->iterations, | ||
2086 | 0, "test17"); | ||
2087 | break; | ||
2088 | |||
2089 | case 18: | ||
2090 | if (dev->in_pipe == 0) | ||
2091 | break; | ||
2092 | dev_info(&intf->dev, | ||
2093 | "TEST 18: read odd addr %d bytes %u times core map\n", | ||
2094 | param->length, param->iterations); | ||
2095 | |||
2096 | retval = test_unaligned_bulk( | ||
2097 | dev, dev->in_pipe, | ||
2098 | param->length, param->iterations, | ||
2099 | 0, "test18"); | ||
2100 | break; | ||
2101 | |||
2102 | /* Tests for bulk I/O using premapped coherent buffer and odd address */ | ||
2103 | case 19: | ||
2104 | if (dev->out_pipe == 0) | ||
2105 | break; | ||
2106 | dev_info(&intf->dev, | ||
2107 | "TEST 19: write odd addr %d bytes %u times premapped\n", | ||
2108 | param->length, param->iterations); | ||
2109 | |||
2110 | retval = test_unaligned_bulk( | ||
2111 | dev, dev->out_pipe, | ||
2112 | param->length, param->iterations, | ||
2113 | URB_NO_TRANSFER_DMA_MAP, "test19"); | ||
2114 | break; | ||
2115 | |||
2116 | case 20: | ||
2117 | if (dev->in_pipe == 0) | ||
2118 | break; | ||
2119 | dev_info(&intf->dev, | ||
2120 | "TEST 20: read odd addr %d bytes %u times premapped\n", | ||
2121 | param->length, param->iterations); | ||
2122 | |||
2123 | retval = test_unaligned_bulk( | ||
2124 | dev, dev->in_pipe, | ||
2125 | param->length, param->iterations, | ||
2126 | URB_NO_TRANSFER_DMA_MAP, "test20"); | ||
2127 | break; | ||
2128 | |||
2129 | /* control write tests with unaligned buffer */ | ||
2130 | case 21: | ||
2131 | if (!dev->info->ctrl_out) | ||
2132 | break; | ||
2133 | dev_info(&intf->dev, | ||
2134 | "TEST 21: %d ep0out odd addr, %d..%d vary %d\n", | ||
2135 | param->iterations, | ||
2136 | realworld ? 1 : 0, param->length, | ||
2137 | param->vary); | ||
2138 | retval = ctrl_out(dev, param->iterations, | ||
2139 | param->length, param->vary, 1); | ||
2140 | break; | ||
2141 | |||
2142 | /* unaligned iso tests */ | ||
2143 | case 22: | ||
2144 | if (dev->out_iso_pipe == 0 || param->sglen == 0) | ||
2145 | break; | ||
2146 | dev_info(&intf->dev, | ||
2147 | "TEST 22: write %d iso odd, %d entries of %d bytes\n", | ||
2148 | param->iterations, | ||
2149 | param->sglen, param->length); | ||
2150 | retval = test_iso_queue(dev, param, | ||
2151 | dev->out_iso_pipe, dev->iso_out, 1); | ||
1863 | break; | 2152 | break; |
1864 | 2153 | ||
1865 | // FIXME unlink from queue (ring with N urbs) | 2154 | case 23: |
2155 | if (dev->in_iso_pipe == 0 || param->sglen == 0) | ||
2156 | break; | ||
2157 | dev_info(&intf->dev, | ||
2158 | "TEST 23: read %d iso odd, %d entries of %d bytes\n", | ||
2159 | param->iterations, | ||
2160 | param->sglen, param->length); | ||
2161 | retval = test_iso_queue(dev, param, | ||
2162 | dev->in_iso_pipe, dev->iso_in, 1); | ||
2163 | break; | ||
1866 | 2164 | ||
1867 | // FIXME scatterlist cancel (needs helper thread) | 2165 | /* unlink URBs from a bulk-OUT queue */ |
2166 | case 24: | ||
2167 | if (dev->out_pipe == 0 || !param->length || param->sglen < 4) | ||
2168 | break; | ||
2169 | retval = 0; | ||
2170 | dev_info(&intf->dev, "TEST 17: unlink from %d queues of " | ||
2171 | "%d %d-byte writes\n", | ||
2172 | param->iterations, param->sglen, param->length); | ||
2173 | for (i = param->iterations; retval == 0 && i > 0; --i) { | ||
2174 | retval = unlink_queued(dev, dev->out_pipe, | ||
2175 | param->sglen, param->length); | ||
2176 | if (retval) { | ||
2177 | dev_err(&intf->dev, | ||
2178 | "unlink queued writes failed %d, " | ||
2179 | "iterations left %d\n", retval, i); | ||
2180 | break; | ||
2181 | } | ||
2182 | } | ||
2183 | break; | ||
1868 | 2184 | ||
1869 | } | 2185 | } |
1870 | do_gettimeofday (¶m->duration); | 2186 | do_gettimeofday(¶m->duration); |
1871 | param->duration.tv_sec -= start.tv_sec; | 2187 | param->duration.tv_sec -= start.tv_sec; |
1872 | param->duration.tv_usec -= start.tv_usec; | 2188 | param->duration.tv_usec -= start.tv_usec; |
1873 | if (param->duration.tv_usec < 0) { | 2189 | if (param->duration.tv_usec < 0) { |
@@ -1880,22 +2196,22 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1880 | 2196 | ||
1881 | /*-------------------------------------------------------------------------*/ | 2197 | /*-------------------------------------------------------------------------*/ |
1882 | 2198 | ||
1883 | static unsigned force_interrupt = 0; | 2199 | static unsigned force_interrupt; |
1884 | module_param (force_interrupt, uint, 0); | 2200 | module_param(force_interrupt, uint, 0); |
1885 | MODULE_PARM_DESC (force_interrupt, "0 = test default; else interrupt"); | 2201 | MODULE_PARM_DESC(force_interrupt, "0 = test default; else interrupt"); |
1886 | 2202 | ||
1887 | #ifdef GENERIC | 2203 | #ifdef GENERIC |
1888 | static unsigned short vendor; | 2204 | static unsigned short vendor; |
1889 | module_param(vendor, ushort, 0); | 2205 | module_param(vendor, ushort, 0); |
1890 | MODULE_PARM_DESC (vendor, "vendor code (from usb-if)"); | 2206 | MODULE_PARM_DESC(vendor, "vendor code (from usb-if)"); |
1891 | 2207 | ||
1892 | static unsigned short product; | 2208 | static unsigned short product; |
1893 | module_param(product, ushort, 0); | 2209 | module_param(product, ushort, 0); |
1894 | MODULE_PARM_DESC (product, "product code (from vendor)"); | 2210 | MODULE_PARM_DESC(product, "product code (from vendor)"); |
1895 | #endif | 2211 | #endif |
1896 | 2212 | ||
1897 | static int | 2213 | static int |
1898 | usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | 2214 | usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id) |
1899 | { | 2215 | { |
1900 | struct usb_device *udev; | 2216 | struct usb_device *udev; |
1901 | struct usbtest_dev *dev; | 2217 | struct usbtest_dev *dev; |
@@ -1903,7 +2219,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1903 | char *rtest, *wtest; | 2219 | char *rtest, *wtest; |
1904 | char *irtest, *iwtest; | 2220 | char *irtest, *iwtest; |
1905 | 2221 | ||
1906 | udev = interface_to_usbdev (intf); | 2222 | udev = interface_to_usbdev(intf); |
1907 | 2223 | ||
1908 | #ifdef GENERIC | 2224 | #ifdef GENERIC |
1909 | /* specify devices by module parameters? */ | 2225 | /* specify devices by module parameters? */ |
@@ -1930,8 +2246,9 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1930 | dev->intf = intf; | 2246 | dev->intf = intf; |
1931 | 2247 | ||
1932 | /* cacheline-aligned scratch for i/o */ | 2248 | /* cacheline-aligned scratch for i/o */ |
1933 | if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) { | 2249 | dev->buf = kmalloc(TBUF_SIZE, GFP_KERNEL); |
1934 | kfree (dev); | 2250 | if (dev->buf == NULL) { |
2251 | kfree(dev); | ||
1935 | return -ENOMEM; | 2252 | return -ENOMEM; |
1936 | } | 2253 | } |
1937 | 2254 | ||
@@ -1943,18 +2260,18 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1943 | irtest = iwtest = ""; | 2260 | irtest = iwtest = ""; |
1944 | if (force_interrupt || udev->speed == USB_SPEED_LOW) { | 2261 | if (force_interrupt || udev->speed == USB_SPEED_LOW) { |
1945 | if (info->ep_in) { | 2262 | if (info->ep_in) { |
1946 | dev->in_pipe = usb_rcvintpipe (udev, info->ep_in); | 2263 | dev->in_pipe = usb_rcvintpipe(udev, info->ep_in); |
1947 | rtest = " intr-in"; | 2264 | rtest = " intr-in"; |
1948 | } | 2265 | } |
1949 | if (info->ep_out) { | 2266 | if (info->ep_out) { |
1950 | dev->out_pipe = usb_sndintpipe (udev, info->ep_out); | 2267 | dev->out_pipe = usb_sndintpipe(udev, info->ep_out); |
1951 | wtest = " intr-out"; | 2268 | wtest = " intr-out"; |
1952 | } | 2269 | } |
1953 | } else { | 2270 | } else { |
1954 | if (info->autoconf) { | 2271 | if (info->autoconf) { |
1955 | int status; | 2272 | int status; |
1956 | 2273 | ||
1957 | status = get_endpoints (dev, intf); | 2274 | status = get_endpoints(dev, intf); |
1958 | if (status < 0) { | 2275 | if (status < 0) { |
1959 | WARNING(dev, "couldn't get endpoints, %d\n", | 2276 | WARNING(dev, "couldn't get endpoints, %d\n", |
1960 | status); | 2277 | status); |
@@ -1963,10 +2280,10 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1963 | /* may find bulk or ISO pipes */ | 2280 | /* may find bulk or ISO pipes */ |
1964 | } else { | 2281 | } else { |
1965 | if (info->ep_in) | 2282 | if (info->ep_in) |
1966 | dev->in_pipe = usb_rcvbulkpipe (udev, | 2283 | dev->in_pipe = usb_rcvbulkpipe(udev, |
1967 | info->ep_in); | 2284 | info->ep_in); |
1968 | if (info->ep_out) | 2285 | if (info->ep_out) |
1969 | dev->out_pipe = usb_sndbulkpipe (udev, | 2286 | dev->out_pipe = usb_sndbulkpipe(udev, |
1970 | info->ep_out); | 2287 | info->ep_out); |
1971 | } | 2288 | } |
1972 | if (dev->in_pipe) | 2289 | if (dev->in_pipe) |
@@ -1979,15 +2296,26 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1979 | iwtest = " iso-out"; | 2296 | iwtest = " iso-out"; |
1980 | } | 2297 | } |
1981 | 2298 | ||
1982 | usb_set_intfdata (intf, dev); | 2299 | usb_set_intfdata(intf, dev); |
1983 | dev_info (&intf->dev, "%s\n", info->name); | 2300 | dev_info(&intf->dev, "%s\n", info->name); |
1984 | dev_info (&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", | 2301 | dev_info(&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", |
1985 | ({ char *tmp; | 2302 | ({ char *tmp; |
1986 | switch (udev->speed) { | 2303 | switch (udev->speed) { |
1987 | case USB_SPEED_LOW: tmp = "low"; break; | 2304 | case USB_SPEED_LOW: |
1988 | case USB_SPEED_FULL: tmp = "full"; break; | 2305 | tmp = "low"; |
1989 | case USB_SPEED_HIGH: tmp = "high"; break; | 2306 | break; |
1990 | default: tmp = "unknown"; break; | 2307 | case USB_SPEED_FULL: |
2308 | tmp = "full"; | ||
2309 | break; | ||
2310 | case USB_SPEED_HIGH: | ||
2311 | tmp = "high"; | ||
2312 | break; | ||
2313 | case USB_SPEED_SUPER: | ||
2314 | tmp = "super"; | ||
2315 | break; | ||
2316 | default: | ||
2317 | tmp = "unknown"; | ||
2318 | break; | ||
1991 | }; tmp; }), | 2319 | }; tmp; }), |
1992 | info->ctrl_out ? " in/out" : "", | 2320 | info->ctrl_out ? " in/out" : "", |
1993 | rtest, wtest, | 2321 | rtest, wtest, |
@@ -1996,24 +2324,24 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1996 | return 0; | 2324 | return 0; |
1997 | } | 2325 | } |
1998 | 2326 | ||
1999 | static int usbtest_suspend (struct usb_interface *intf, pm_message_t message) | 2327 | static int usbtest_suspend(struct usb_interface *intf, pm_message_t message) |
2000 | { | 2328 | { |
2001 | return 0; | 2329 | return 0; |
2002 | } | 2330 | } |
2003 | 2331 | ||
2004 | static int usbtest_resume (struct usb_interface *intf) | 2332 | static int usbtest_resume(struct usb_interface *intf) |
2005 | { | 2333 | { |
2006 | return 0; | 2334 | return 0; |
2007 | } | 2335 | } |
2008 | 2336 | ||
2009 | 2337 | ||
2010 | static void usbtest_disconnect (struct usb_interface *intf) | 2338 | static void usbtest_disconnect(struct usb_interface *intf) |
2011 | { | 2339 | { |
2012 | struct usbtest_dev *dev = usb_get_intfdata (intf); | 2340 | struct usbtest_dev *dev = usb_get_intfdata(intf); |
2013 | 2341 | ||
2014 | usb_set_intfdata (intf, NULL); | 2342 | usb_set_intfdata(intf, NULL); |
2015 | dev_dbg (&intf->dev, "disconnect\n"); | 2343 | dev_dbg(&intf->dev, "disconnect\n"); |
2016 | kfree (dev); | 2344 | kfree(dev); |
2017 | } | 2345 | } |
2018 | 2346 | ||
2019 | /* Basic testing only needs a device that can source or sink bulk traffic. | 2347 | /* Basic testing only needs a device that can source or sink bulk traffic. |
@@ -2050,9 +2378,9 @@ static struct usbtest_info fw_info = { | |||
2050 | .ep_in = 2, | 2378 | .ep_in = 2, |
2051 | .ep_out = 2, | 2379 | .ep_out = 2, |
2052 | .alt = 1, | 2380 | .alt = 1, |
2053 | .autoconf = 1, // iso and ctrl_out need autoconf | 2381 | .autoconf = 1, /* iso and ctrl_out need autoconf */ |
2054 | .ctrl_out = 1, | 2382 | .ctrl_out = 1, |
2055 | .iso = 1, // iso_ep's are #8 in/out | 2383 | .iso = 1, /* iso_ep's are #8 in/out */ |
2056 | }; | 2384 | }; |
2057 | 2385 | ||
2058 | /* peripheral running Linux and 'zero.c' test firmware, or | 2386 | /* peripheral running Linux and 'zero.c' test firmware, or |
@@ -2109,56 +2437,56 @@ static const struct usb_device_id id_table[] = { | |||
2109 | */ | 2437 | */ |
2110 | 2438 | ||
2111 | /* generic EZ-USB FX controller */ | 2439 | /* generic EZ-USB FX controller */ |
2112 | { USB_DEVICE (0x0547, 0x2235), | 2440 | { USB_DEVICE(0x0547, 0x2235), |
2113 | .driver_info = (unsigned long) &ez1_info, | 2441 | .driver_info = (unsigned long) &ez1_info, |
2114 | }, | 2442 | }, |
2115 | 2443 | ||
2116 | /* CY3671 development board with EZ-USB FX */ | 2444 | /* CY3671 development board with EZ-USB FX */ |
2117 | { USB_DEVICE (0x0547, 0x0080), | 2445 | { USB_DEVICE(0x0547, 0x0080), |
2118 | .driver_info = (unsigned long) &ez1_info, | 2446 | .driver_info = (unsigned long) &ez1_info, |
2119 | }, | 2447 | }, |
2120 | 2448 | ||
2121 | /* generic EZ-USB FX2 controller (or development board) */ | 2449 | /* generic EZ-USB FX2 controller (or development board) */ |
2122 | { USB_DEVICE (0x04b4, 0x8613), | 2450 | { USB_DEVICE(0x04b4, 0x8613), |
2123 | .driver_info = (unsigned long) &ez2_info, | 2451 | .driver_info = (unsigned long) &ez2_info, |
2124 | }, | 2452 | }, |
2125 | 2453 | ||
2126 | /* re-enumerated usb test device firmware */ | 2454 | /* re-enumerated usb test device firmware */ |
2127 | { USB_DEVICE (0xfff0, 0xfff0), | 2455 | { USB_DEVICE(0xfff0, 0xfff0), |
2128 | .driver_info = (unsigned long) &fw_info, | 2456 | .driver_info = (unsigned long) &fw_info, |
2129 | }, | 2457 | }, |
2130 | 2458 | ||
2131 | /* "Gadget Zero" firmware runs under Linux */ | 2459 | /* "Gadget Zero" firmware runs under Linux */ |
2132 | { USB_DEVICE (0x0525, 0xa4a0), | 2460 | { USB_DEVICE(0x0525, 0xa4a0), |
2133 | .driver_info = (unsigned long) &gz_info, | 2461 | .driver_info = (unsigned long) &gz_info, |
2134 | }, | 2462 | }, |
2135 | 2463 | ||
2136 | /* so does a user-mode variant */ | 2464 | /* so does a user-mode variant */ |
2137 | { USB_DEVICE (0x0525, 0xa4a4), | 2465 | { USB_DEVICE(0x0525, 0xa4a4), |
2138 | .driver_info = (unsigned long) &um_info, | 2466 | .driver_info = (unsigned long) &um_info, |
2139 | }, | 2467 | }, |
2140 | 2468 | ||
2141 | /* ... and a user-mode variant that talks iso */ | 2469 | /* ... and a user-mode variant that talks iso */ |
2142 | { USB_DEVICE (0x0525, 0xa4a3), | 2470 | { USB_DEVICE(0x0525, 0xa4a3), |
2143 | .driver_info = (unsigned long) &um2_info, | 2471 | .driver_info = (unsigned long) &um2_info, |
2144 | }, | 2472 | }, |
2145 | 2473 | ||
2146 | #ifdef KEYSPAN_19Qi | 2474 | #ifdef KEYSPAN_19Qi |
2147 | /* Keyspan 19qi uses an21xx (original EZ-USB) */ | 2475 | /* Keyspan 19qi uses an21xx (original EZ-USB) */ |
2148 | // this does not coexist with the real Keyspan 19qi driver! | 2476 | /* this does not coexist with the real Keyspan 19qi driver! */ |
2149 | { USB_DEVICE (0x06cd, 0x010b), | 2477 | { USB_DEVICE(0x06cd, 0x010b), |
2150 | .driver_info = (unsigned long) &ez1_info, | 2478 | .driver_info = (unsigned long) &ez1_info, |
2151 | }, | 2479 | }, |
2152 | #endif | 2480 | #endif |
2153 | 2481 | ||
2154 | /*-------------------------------------------------------------*/ | 2482 | /*-------------------------------------------------------------*/ |
2155 | 2483 | ||
2156 | #ifdef IBOT2 | 2484 | #ifdef IBOT2 |
2157 | /* iBOT2 makes a nice source of high speed bulk-in data */ | 2485 | /* iBOT2 makes a nice source of high speed bulk-in data */ |
2158 | // this does not coexist with a real iBOT2 driver! | 2486 | /* this does not coexist with a real iBOT2 driver! */ |
2159 | { USB_DEVICE (0x0b62, 0x0059), | 2487 | { USB_DEVICE(0x0b62, 0x0059), |
2160 | .driver_info = (unsigned long) &ibot2_info, | 2488 | .driver_info = (unsigned long) &ibot2_info, |
2161 | }, | 2489 | }, |
2162 | #endif | 2490 | #endif |
2163 | 2491 | ||
2164 | /*-------------------------------------------------------------*/ | 2492 | /*-------------------------------------------------------------*/ |
@@ -2172,7 +2500,7 @@ static const struct usb_device_id id_table[] = { | |||
2172 | 2500 | ||
2173 | { } | 2501 | { } |
2174 | }; | 2502 | }; |
2175 | MODULE_DEVICE_TABLE (usb, id_table); | 2503 | MODULE_DEVICE_TABLE(usb, id_table); |
2176 | 2504 | ||
2177 | static struct usb_driver usbtest_driver = { | 2505 | static struct usb_driver usbtest_driver = { |
2178 | .name = "usbtest", | 2506 | .name = "usbtest", |
@@ -2186,22 +2514,22 @@ static struct usb_driver usbtest_driver = { | |||
2186 | 2514 | ||
2187 | /*-------------------------------------------------------------------------*/ | 2515 | /*-------------------------------------------------------------------------*/ |
2188 | 2516 | ||
2189 | static int __init usbtest_init (void) | 2517 | static int __init usbtest_init(void) |
2190 | { | 2518 | { |
2191 | #ifdef GENERIC | 2519 | #ifdef GENERIC |
2192 | if (vendor) | 2520 | if (vendor) |
2193 | pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product); | 2521 | pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product); |
2194 | #endif | 2522 | #endif |
2195 | return usb_register (&usbtest_driver); | 2523 | return usb_register(&usbtest_driver); |
2196 | } | 2524 | } |
2197 | module_init (usbtest_init); | 2525 | module_init(usbtest_init); |
2198 | 2526 | ||
2199 | static void __exit usbtest_exit (void) | 2527 | static void __exit usbtest_exit(void) |
2200 | { | 2528 | { |
2201 | usb_deregister (&usbtest_driver); | 2529 | usb_deregister(&usbtest_driver); |
2202 | } | 2530 | } |
2203 | module_exit (usbtest_exit); | 2531 | module_exit(usbtest_exit); |
2204 | 2532 | ||
2205 | MODULE_DESCRIPTION ("USB Core/HCD Testing Driver"); | 2533 | MODULE_DESCRIPTION("USB Core/HCD Testing Driver"); |
2206 | MODULE_LICENSE ("GPL"); | 2534 | MODULE_LICENSE("GPL"); |
2207 | 2535 | ||
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index 796e2f68f749..8b1d94a76914 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c | |||
@@ -3,7 +3,7 @@ | |||
3 | /* | 3 | /* |
4 | * uss720.c -- USS720 USB Parport Cable. | 4 | * uss720.c -- USS720 USB Parport Cable. |
5 | * | 5 | * |
6 | * Copyright (C) 1999, 2005 | 6 | * Copyright (C) 1999, 2005, 2010 |
7 | * Thomas Sailer (t.sailer@alumni.ethz.ch) | 7 | * Thomas Sailer (t.sailer@alumni.ethz.ch) |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
@@ -177,12 +177,11 @@ static struct uss720_async_request *submit_async_request(struct parport_uss720_p | |||
177 | spin_lock_irqsave(&priv->asynclock, flags); | 177 | spin_lock_irqsave(&priv->asynclock, flags); |
178 | list_add_tail(&rq->asynclist, &priv->asynclist); | 178 | list_add_tail(&rq->asynclist, &priv->asynclist); |
179 | spin_unlock_irqrestore(&priv->asynclock, flags); | 179 | spin_unlock_irqrestore(&priv->asynclock, flags); |
180 | kref_get(&rq->ref_count); | ||
180 | ret = usb_submit_urb(rq->urb, mem_flags); | 181 | ret = usb_submit_urb(rq->urb, mem_flags); |
181 | if (!ret) { | 182 | if (!ret) |
182 | kref_get(&rq->ref_count); | ||
183 | return rq; | 183 | return rq; |
184 | } | 184 | destroy_async(&rq->ref_count); |
185 | kref_put(&rq->ref_count, destroy_async); | ||
186 | err("submit_async_request submit_urb failed with %d", ret); | 185 | err("submit_async_request submit_urb failed with %d", ret); |
187 | return NULL; | 186 | return NULL; |
188 | } | 187 | } |
@@ -776,6 +775,7 @@ static const struct usb_device_id uss720_table[] = { | |||
776 | { USB_DEVICE(0x0557, 0x2001) }, | 775 | { USB_DEVICE(0x0557, 0x2001) }, |
777 | { USB_DEVICE(0x0729, 0x1284) }, | 776 | { USB_DEVICE(0x0729, 0x1284) }, |
778 | { USB_DEVICE(0x1293, 0x0002) }, | 777 | { USB_DEVICE(0x1293, 0x0002) }, |
778 | { USB_DEVICE(0x050d, 0x0002) }, | ||
779 | { } /* Terminating entry */ | 779 | { } /* Terminating entry */ |
780 | }; | 780 | }; |
781 | 781 | ||
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c new file mode 100644 index 000000000000..ac5bfd619e62 --- /dev/null +++ b/drivers/usb/misc/yurex.c | |||
@@ -0,0 +1,564 @@ | |||
1 | /* | ||
2 | * Driver for Meywa-Denki & KAYAC YUREX | ||
3 | * | ||
4 | * Copyright (C) 2010 Tomoki Sekiyama (tomoki.sekiyama@gmail.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License as | ||
8 | * published by the Free Software Foundation, version 2. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/errno.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/slab.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/kref.h> | ||
18 | #include <linux/mutex.h> | ||
19 | #include <linux/uaccess.h> | ||
20 | #include <linux/usb.h> | ||
21 | #include <linux/hid.h> | ||
22 | |||
23 | #define DRIVER_AUTHOR "Tomoki Sekiyama" | ||
24 | #define DRIVER_DESC "Driver for Meywa-Denki & KAYAC YUREX" | ||
25 | |||
26 | #define YUREX_VENDOR_ID 0x0c45 | ||
27 | #define YUREX_PRODUCT_ID 0x1010 | ||
28 | |||
29 | #define CMD_ACK '!' | ||
30 | #define CMD_ANIMATE 'A' | ||
31 | #define CMD_COUNT 'C' | ||
32 | #define CMD_LED 'L' | ||
33 | #define CMD_READ 'R' | ||
34 | #define CMD_SET 'S' | ||
35 | #define CMD_VERSION 'V' | ||
36 | #define CMD_EOF 0x0d | ||
37 | #define CMD_PADDING 0xff | ||
38 | |||
39 | #define YUREX_BUF_SIZE 8 | ||
40 | #define YUREX_WRITE_TIMEOUT (HZ*2) | ||
41 | |||
42 | /* table of devices that work with this driver */ | ||
43 | static struct usb_device_id yurex_table[] = { | ||
44 | { USB_DEVICE(YUREX_VENDOR_ID, YUREX_PRODUCT_ID) }, | ||
45 | { } /* Terminating entry */ | ||
46 | }; | ||
47 | MODULE_DEVICE_TABLE(usb, yurex_table); | ||
48 | |||
49 | #ifdef CONFIG_USB_DYNAMIC_MINORS | ||
50 | #define YUREX_MINOR_BASE 0 | ||
51 | #else | ||
52 | #define YUREX_MINOR_BASE 192 | ||
53 | #endif | ||
54 | |||
55 | /* Structure to hold all of our device specific stuff */ | ||
56 | struct usb_yurex { | ||
57 | struct usb_device *udev; | ||
58 | struct usb_interface *interface; | ||
59 | __u8 int_in_endpointAddr; | ||
60 | struct urb *urb; /* URB for interrupt in */ | ||
61 | unsigned char *int_buffer; /* buffer for intterupt in */ | ||
62 | struct urb *cntl_urb; /* URB for control msg */ | ||
63 | struct usb_ctrlrequest *cntl_req; /* req for control msg */ | ||
64 | unsigned char *cntl_buffer; /* buffer for control msg */ | ||
65 | |||
66 | struct kref kref; | ||
67 | struct mutex io_mutex; | ||
68 | struct fasync_struct *async_queue; | ||
69 | wait_queue_head_t waitq; | ||
70 | |||
71 | spinlock_t lock; | ||
72 | __s64 bbu; /* BBU from device */ | ||
73 | }; | ||
74 | #define to_yurex_dev(d) container_of(d, struct usb_yurex, kref) | ||
75 | |||
76 | static struct usb_driver yurex_driver; | ||
77 | static const struct file_operations yurex_fops; | ||
78 | |||
79 | |||
80 | static void yurex_control_callback(struct urb *urb) | ||
81 | { | ||
82 | struct usb_yurex *dev = urb->context; | ||
83 | int status = urb->status; | ||
84 | |||
85 | if (status) { | ||
86 | err("%s - control failed: %d\n", __func__, status); | ||
87 | wake_up_interruptible(&dev->waitq); | ||
88 | return; | ||
89 | } | ||
90 | /* on success, sender woken up by CMD_ACK int in, or timeout */ | ||
91 | } | ||
92 | |||
93 | static void yurex_delete(struct kref *kref) | ||
94 | { | ||
95 | struct usb_yurex *dev = to_yurex_dev(kref); | ||
96 | |||
97 | dbg("yurex_delete"); | ||
98 | |||
99 | usb_put_dev(dev->udev); | ||
100 | if (dev->cntl_urb) { | ||
101 | usb_kill_urb(dev->cntl_urb); | ||
102 | if (dev->cntl_req) | ||
103 | usb_free_coherent(dev->udev, YUREX_BUF_SIZE, | ||
104 | dev->cntl_req, dev->cntl_urb->setup_dma); | ||
105 | if (dev->cntl_buffer) | ||
106 | usb_free_coherent(dev->udev, YUREX_BUF_SIZE, | ||
107 | dev->cntl_buffer, dev->cntl_urb->transfer_dma); | ||
108 | usb_free_urb(dev->cntl_urb); | ||
109 | } | ||
110 | if (dev->urb) { | ||
111 | usb_kill_urb(dev->urb); | ||
112 | if (dev->int_buffer) | ||
113 | usb_free_coherent(dev->udev, YUREX_BUF_SIZE, | ||
114 | dev->int_buffer, dev->urb->transfer_dma); | ||
115 | usb_free_urb(dev->urb); | ||
116 | } | ||
117 | kfree(dev); | ||
118 | } | ||
119 | |||
120 | /* | ||
121 | * usb class driver info in order to get a minor number from the usb core, | ||
122 | * and to have the device registered with the driver core | ||
123 | */ | ||
124 | static struct usb_class_driver yurex_class = { | ||
125 | .name = "yurex%d", | ||
126 | .fops = &yurex_fops, | ||
127 | .minor_base = YUREX_MINOR_BASE, | ||
128 | }; | ||
129 | |||
130 | static void yurex_interrupt(struct urb *urb) | ||
131 | { | ||
132 | struct usb_yurex *dev = urb->context; | ||
133 | unsigned char *buf = dev->int_buffer; | ||
134 | int status = urb->status; | ||
135 | unsigned long flags; | ||
136 | int retval, i; | ||
137 | |||
138 | switch (status) { | ||
139 | case 0: /*success*/ | ||
140 | break; | ||
141 | case -EOVERFLOW: | ||
142 | err("%s - overflow with length %d, actual length is %d", | ||
143 | __func__, YUREX_BUF_SIZE, dev->urb->actual_length); | ||
144 | case -ECONNRESET: | ||
145 | case -ENOENT: | ||
146 | case -ESHUTDOWN: | ||
147 | case -EILSEQ: | ||
148 | /* The device is terminated, clean up */ | ||
149 | return; | ||
150 | default: | ||
151 | err("%s - unknown status received: %d", __func__, status); | ||
152 | goto exit; | ||
153 | } | ||
154 | |||
155 | /* handle received message */ | ||
156 | switch (buf[0]) { | ||
157 | case CMD_COUNT: | ||
158 | case CMD_READ: | ||
159 | if (buf[6] == CMD_EOF) { | ||
160 | spin_lock_irqsave(&dev->lock, flags); | ||
161 | dev->bbu = 0; | ||
162 | for (i = 1; i < 6; i++) { | ||
163 | dev->bbu += buf[i]; | ||
164 | if (i != 5) | ||
165 | dev->bbu <<= 8; | ||
166 | } | ||
167 | dbg("%s count: %lld", __func__, dev->bbu); | ||
168 | spin_unlock_irqrestore(&dev->lock, flags); | ||
169 | |||
170 | kill_fasync(&dev->async_queue, SIGIO, POLL_IN); | ||
171 | } | ||
172 | else | ||
173 | dbg("data format error - no EOF"); | ||
174 | break; | ||
175 | case CMD_ACK: | ||
176 | dbg("%s ack: %c", __func__, buf[1]); | ||
177 | wake_up_interruptible(&dev->waitq); | ||
178 | break; | ||
179 | } | ||
180 | |||
181 | exit: | ||
182 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | ||
183 | if (retval) { | ||
184 | err("%s - usb_submit_urb failed: %d", | ||
185 | __func__, retval); | ||
186 | } | ||
187 | } | ||
188 | |||
189 | static int yurex_probe(struct usb_interface *interface, const struct usb_device_id *id) | ||
190 | { | ||
191 | struct usb_yurex *dev; | ||
192 | struct usb_host_interface *iface_desc; | ||
193 | struct usb_endpoint_descriptor *endpoint; | ||
194 | int retval = -ENOMEM; | ||
195 | int i; | ||
196 | DEFINE_WAIT(wait); | ||
197 | |||
198 | /* allocate memory for our device state and initialize it */ | ||
199 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
200 | if (!dev) { | ||
201 | err("Out of memory"); | ||
202 | goto error; | ||
203 | } | ||
204 | kref_init(&dev->kref); | ||
205 | mutex_init(&dev->io_mutex); | ||
206 | spin_lock_init(&dev->lock); | ||
207 | init_waitqueue_head(&dev->waitq); | ||
208 | |||
209 | dev->udev = usb_get_dev(interface_to_usbdev(interface)); | ||
210 | dev->interface = interface; | ||
211 | |||
212 | /* set up the endpoint information */ | ||
213 | iface_desc = interface->cur_altsetting; | ||
214 | for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { | ||
215 | endpoint = &iface_desc->endpoint[i].desc; | ||
216 | |||
217 | if (usb_endpoint_is_int_in(endpoint)) { | ||
218 | dev->int_in_endpointAddr = endpoint->bEndpointAddress; | ||
219 | break; | ||
220 | } | ||
221 | } | ||
222 | if (!dev->int_in_endpointAddr) { | ||
223 | retval = -ENODEV; | ||
224 | err("Could not find endpoints"); | ||
225 | goto error; | ||
226 | } | ||
227 | |||
228 | |||
229 | /* allocate control URB */ | ||
230 | dev->cntl_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
231 | if (!dev->cntl_urb) { | ||
232 | err("Could not allocate control URB"); | ||
233 | goto error; | ||
234 | } | ||
235 | |||
236 | /* allocate buffer for control req */ | ||
237 | dev->cntl_req = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE, | ||
238 | GFP_KERNEL, | ||
239 | &dev->cntl_urb->setup_dma); | ||
240 | if (!dev->cntl_req) { | ||
241 | err("Could not allocate cntl_req"); | ||
242 | goto error; | ||
243 | } | ||
244 | |||
245 | /* allocate buffer for control msg */ | ||
246 | dev->cntl_buffer = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE, | ||
247 | GFP_KERNEL, | ||
248 | &dev->cntl_urb->transfer_dma); | ||
249 | if (!dev->cntl_buffer) { | ||
250 | err("Could not allocate cntl_buffer"); | ||
251 | goto error; | ||
252 | } | ||
253 | |||
254 | /* configure control URB */ | ||
255 | dev->cntl_req->bRequestType = USB_DIR_OUT | USB_TYPE_CLASS | | ||
256 | USB_RECIP_INTERFACE; | ||
257 | dev->cntl_req->bRequest = HID_REQ_SET_REPORT; | ||
258 | dev->cntl_req->wValue = cpu_to_le16((HID_OUTPUT_REPORT + 1) << 8); | ||
259 | dev->cntl_req->wIndex = cpu_to_le16(iface_desc->desc.bInterfaceNumber); | ||
260 | dev->cntl_req->wLength = cpu_to_le16(YUREX_BUF_SIZE); | ||
261 | |||
262 | usb_fill_control_urb(dev->cntl_urb, dev->udev, | ||
263 | usb_sndctrlpipe(dev->udev, 0), | ||
264 | (void *)dev->cntl_req, dev->cntl_buffer, | ||
265 | YUREX_BUF_SIZE, yurex_control_callback, dev); | ||
266 | dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
267 | |||
268 | |||
269 | /* allocate interrupt URB */ | ||
270 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); | ||
271 | if (!dev->urb) { | ||
272 | err("Could not allocate URB"); | ||
273 | goto error; | ||
274 | } | ||
275 | |||
276 | /* allocate buffer for interrupt in */ | ||
277 | dev->int_buffer = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE, | ||
278 | GFP_KERNEL, &dev->urb->transfer_dma); | ||
279 | if (!dev->int_buffer) { | ||
280 | err("Could not allocate int_buffer"); | ||
281 | goto error; | ||
282 | } | ||
283 | |||
284 | /* configure interrupt URB */ | ||
285 | usb_fill_int_urb(dev->urb, dev->udev, | ||
286 | usb_rcvintpipe(dev->udev, dev->int_in_endpointAddr), | ||
287 | dev->int_buffer, YUREX_BUF_SIZE, yurex_interrupt, | ||
288 | dev, 1); | ||
289 | dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
290 | if (usb_submit_urb(dev->urb, GFP_KERNEL)) { | ||
291 | retval = -EIO; | ||
292 | err("Could not submitting URB"); | ||
293 | goto error; | ||
294 | } | ||
295 | |||
296 | /* save our data pointer in this interface device */ | ||
297 | usb_set_intfdata(interface, dev); | ||
298 | |||
299 | /* we can register the device now, as it is ready */ | ||
300 | retval = usb_register_dev(interface, &yurex_class); | ||
301 | if (retval) { | ||
302 | err("Not able to get a minor for this device."); | ||
303 | usb_set_intfdata(interface, NULL); | ||
304 | goto error; | ||
305 | } | ||
306 | |||
307 | dev->bbu = -1; | ||
308 | |||
309 | dev_info(&interface->dev, | ||
310 | "USB YUREX device now attached to Yurex #%d\n", | ||
311 | interface->minor); | ||
312 | |||
313 | return 0; | ||
314 | |||
315 | error: | ||
316 | if (dev) | ||
317 | /* this frees allocated memory */ | ||
318 | kref_put(&dev->kref, yurex_delete); | ||
319 | return retval; | ||
320 | } | ||
321 | |||
322 | static void yurex_disconnect(struct usb_interface *interface) | ||
323 | { | ||
324 | struct usb_yurex *dev; | ||
325 | int minor = interface->minor; | ||
326 | |||
327 | dev = usb_get_intfdata(interface); | ||
328 | usb_set_intfdata(interface, NULL); | ||
329 | |||
330 | /* give back our minor */ | ||
331 | usb_deregister_dev(interface, &yurex_class); | ||
332 | |||
333 | /* prevent more I/O from starting */ | ||
334 | mutex_lock(&dev->io_mutex); | ||
335 | dev->interface = NULL; | ||
336 | mutex_unlock(&dev->io_mutex); | ||
337 | |||
338 | /* wakeup waiters */ | ||
339 | kill_fasync(&dev->async_queue, SIGIO, POLL_IN); | ||
340 | wake_up_interruptible(&dev->waitq); | ||
341 | |||
342 | /* decrement our usage count */ | ||
343 | kref_put(&dev->kref, yurex_delete); | ||
344 | |||
345 | dev_info(&interface->dev, "USB YUREX #%d now disconnected\n", minor); | ||
346 | } | ||
347 | |||
348 | static struct usb_driver yurex_driver = { | ||
349 | .name = "yurex", | ||
350 | .probe = yurex_probe, | ||
351 | .disconnect = yurex_disconnect, | ||
352 | .id_table = yurex_table, | ||
353 | }; | ||
354 | |||
355 | |||
356 | static int yurex_fasync(int fd, struct file *file, int on) | ||
357 | { | ||
358 | struct usb_yurex *dev; | ||
359 | |||
360 | dev = (struct usb_yurex *)file->private_data; | ||
361 | return fasync_helper(fd, file, on, &dev->async_queue); | ||
362 | } | ||
363 | |||
364 | static int yurex_open(struct inode *inode, struct file *file) | ||
365 | { | ||
366 | struct usb_yurex *dev; | ||
367 | struct usb_interface *interface; | ||
368 | int subminor; | ||
369 | int retval = 0; | ||
370 | |||
371 | subminor = iminor(inode); | ||
372 | |||
373 | interface = usb_find_interface(&yurex_driver, subminor); | ||
374 | if (!interface) { | ||
375 | err("%s - error, can't find device for minor %d", | ||
376 | __func__, subminor); | ||
377 | retval = -ENODEV; | ||
378 | goto exit; | ||
379 | } | ||
380 | |||
381 | dev = usb_get_intfdata(interface); | ||
382 | if (!dev) { | ||
383 | retval = -ENODEV; | ||
384 | goto exit; | ||
385 | } | ||
386 | |||
387 | /* increment our usage count for the device */ | ||
388 | kref_get(&dev->kref); | ||
389 | |||
390 | /* save our object in the file's private structure */ | ||
391 | mutex_lock(&dev->io_mutex); | ||
392 | file->private_data = dev; | ||
393 | mutex_unlock(&dev->io_mutex); | ||
394 | |||
395 | exit: | ||
396 | return retval; | ||
397 | } | ||
398 | |||
399 | static int yurex_release(struct inode *inode, struct file *file) | ||
400 | { | ||
401 | struct usb_yurex *dev; | ||
402 | |||
403 | dev = (struct usb_yurex *)file->private_data; | ||
404 | if (dev == NULL) | ||
405 | return -ENODEV; | ||
406 | |||
407 | yurex_fasync(-1, file, 0); | ||
408 | |||
409 | /* decrement the count on our device */ | ||
410 | kref_put(&dev->kref, yurex_delete); | ||
411 | return 0; | ||
412 | } | ||
413 | |||
414 | static ssize_t yurex_read(struct file *file, char *buffer, size_t count, loff_t *ppos) | ||
415 | { | ||
416 | struct usb_yurex *dev; | ||
417 | int retval = 0; | ||
418 | int bytes_read = 0; | ||
419 | char in_buffer[20]; | ||
420 | unsigned long flags; | ||
421 | |||
422 | dev = (struct usb_yurex *)file->private_data; | ||
423 | |||
424 | mutex_lock(&dev->io_mutex); | ||
425 | if (!dev->interface) { /* already disconnected */ | ||
426 | retval = -ENODEV; | ||
427 | goto exit; | ||
428 | } | ||
429 | |||
430 | spin_lock_irqsave(&dev->lock, flags); | ||
431 | bytes_read = snprintf(in_buffer, 20, "%lld\n", dev->bbu); | ||
432 | spin_unlock_irqrestore(&dev->lock, flags); | ||
433 | |||
434 | if (*ppos < bytes_read) { | ||
435 | if (copy_to_user(buffer, in_buffer + *ppos, bytes_read - *ppos)) | ||
436 | retval = -EFAULT; | ||
437 | else { | ||
438 | retval = bytes_read - *ppos; | ||
439 | *ppos += bytes_read; | ||
440 | } | ||
441 | } | ||
442 | |||
443 | exit: | ||
444 | mutex_unlock(&dev->io_mutex); | ||
445 | return retval; | ||
446 | } | ||
447 | |||
448 | static ssize_t yurex_write(struct file *file, const char *user_buffer, size_t count, loff_t *ppos) | ||
449 | { | ||
450 | struct usb_yurex *dev; | ||
451 | int i, set = 0, retval = 0; | ||
452 | char buffer[16]; | ||
453 | char *data = buffer; | ||
454 | unsigned long long c, c2 = 0; | ||
455 | signed long timeout = 0; | ||
456 | DEFINE_WAIT(wait); | ||
457 | |||
458 | count = min(sizeof(buffer), count); | ||
459 | dev = (struct usb_yurex *)file->private_data; | ||
460 | |||
461 | /* verify that we actually have some data to write */ | ||
462 | if (count == 0) | ||
463 | goto error; | ||
464 | |||
465 | mutex_lock(&dev->io_mutex); | ||
466 | if (!dev->interface) { /* alreaday disconnected */ | ||
467 | mutex_unlock(&dev->io_mutex); | ||
468 | retval = -ENODEV; | ||
469 | goto error; | ||
470 | } | ||
471 | |||
472 | if (copy_from_user(buffer, user_buffer, count)) { | ||
473 | mutex_unlock(&dev->io_mutex); | ||
474 | retval = -EFAULT; | ||
475 | goto error; | ||
476 | } | ||
477 | memset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE); | ||
478 | |||
479 | switch (buffer[0]) { | ||
480 | case CMD_ANIMATE: | ||
481 | case CMD_LED: | ||
482 | dev->cntl_buffer[0] = buffer[0]; | ||
483 | dev->cntl_buffer[1] = buffer[1]; | ||
484 | dev->cntl_buffer[2] = CMD_EOF; | ||
485 | break; | ||
486 | case CMD_READ: | ||
487 | case CMD_VERSION: | ||
488 | dev->cntl_buffer[0] = buffer[0]; | ||
489 | dev->cntl_buffer[1] = 0x00; | ||
490 | dev->cntl_buffer[2] = CMD_EOF; | ||
491 | break; | ||
492 | case CMD_SET: | ||
493 | data++; | ||
494 | /* FALL THROUGH */ | ||
495 | case '0' ... '9': | ||
496 | set = 1; | ||
497 | c = c2 = simple_strtoull(data, NULL, 0); | ||
498 | dev->cntl_buffer[0] = CMD_SET; | ||
499 | for (i = 1; i < 6; i++) { | ||
500 | dev->cntl_buffer[i] = (c>>32) & 0xff; | ||
501 | c <<= 8; | ||
502 | } | ||
503 | buffer[6] = CMD_EOF; | ||
504 | break; | ||
505 | default: | ||
506 | mutex_unlock(&dev->io_mutex); | ||
507 | return -EINVAL; | ||
508 | } | ||
509 | |||
510 | /* send the data as the control msg */ | ||
511 | prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE); | ||
512 | dbg("%s - submit %c", __func__, dev->cntl_buffer[0]); | ||
513 | retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL); | ||
514 | if (retval >= 0) | ||
515 | timeout = schedule_timeout(YUREX_WRITE_TIMEOUT); | ||
516 | finish_wait(&dev->waitq, &wait); | ||
517 | |||
518 | mutex_unlock(&dev->io_mutex); | ||
519 | |||
520 | if (retval < 0) { | ||
521 | err("%s - failed to send bulk msg, error %d", __func__, retval); | ||
522 | goto error; | ||
523 | } | ||
524 | if (set && timeout) | ||
525 | dev->bbu = c2; | ||
526 | return timeout ? count : -EIO; | ||
527 | |||
528 | error: | ||
529 | return retval; | ||
530 | } | ||
531 | |||
532 | static const struct file_operations yurex_fops = { | ||
533 | .owner = THIS_MODULE, | ||
534 | .read = yurex_read, | ||
535 | .write = yurex_write, | ||
536 | .open = yurex_open, | ||
537 | .release = yurex_release, | ||
538 | .fasync = yurex_fasync, | ||
539 | .llseek = default_llseek, | ||
540 | }; | ||
541 | |||
542 | |||
543 | static int __init usb_yurex_init(void) | ||
544 | { | ||
545 | int result; | ||
546 | |||
547 | /* register this driver with the USB subsystem */ | ||
548 | result = usb_register(&yurex_driver); | ||
549 | if (result) | ||
550 | err("usb_register failed. Error number %d", result); | ||
551 | |||
552 | return result; | ||
553 | } | ||
554 | |||
555 | static void __exit usb_yurex_exit(void) | ||
556 | { | ||
557 | /* deregister this driver with the USB subsystem */ | ||
558 | usb_deregister(&yurex_driver); | ||
559 | } | ||
560 | |||
561 | module_init(usb_yurex_init); | ||
562 | module_exit(usb_yurex_exit); | ||
563 | |||
564 | MODULE_LICENSE("GPL"); | ||