diff options
Diffstat (limited to 'drivers/usb/misc')
| -rw-r--r-- | drivers/usb/misc/adutux.c | 14 | ||||
| -rw-r--r-- | drivers/usb/misc/ftdi-elan.c | 2 | ||||
| -rw-r--r-- | drivers/usb/misc/idmouse.c | 2 | ||||
| -rw-r--r-- | drivers/usb/misc/iowarrior.c | 2 | ||||
| -rw-r--r-- | drivers/usb/misc/ldusb.c | 4 | ||||
| -rw-r--r-- | drivers/usb/misc/legousbtower.c | 4 | ||||
| -rw-r--r-- | drivers/usb/misc/usblcd.c | 129 | ||||
| -rw-r--r-- | drivers/usb/misc/usbled.c | 25 | ||||
| -rw-r--r-- | drivers/usb/misc/usbtest.c | 31 |
9 files changed, 108 insertions, 105 deletions
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index a6afd15f6a46..fe858711651c 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c | |||
| @@ -213,7 +213,7 @@ static void adu_interrupt_in_callback(struct urb *urb) | |||
| 213 | 213 | ||
| 214 | if (urb->actual_length > 0 && dev->interrupt_in_buffer[0] != 0x00) { | 214 | if (urb->actual_length > 0 && dev->interrupt_in_buffer[0] != 0x00) { |
| 215 | if (dev->read_buffer_length < | 215 | if (dev->read_buffer_length < |
| 216 | (4 * le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize)) - | 216 | (4 * usb_endpoint_maxp(dev->interrupt_in_endpoint)) - |
| 217 | (urb->actual_length)) { | 217 | (urb->actual_length)) { |
| 218 | memcpy (dev->read_buffer_primary + | 218 | memcpy (dev->read_buffer_primary + |
| 219 | dev->read_buffer_length, | 219 | dev->read_buffer_length, |
| @@ -315,7 +315,7 @@ static int adu_open(struct inode *inode, struct file *file) | |||
| 315 | usb_rcvintpipe(dev->udev, | 315 | usb_rcvintpipe(dev->udev, |
| 316 | dev->interrupt_in_endpoint->bEndpointAddress), | 316 | dev->interrupt_in_endpoint->bEndpointAddress), |
| 317 | dev->interrupt_in_buffer, | 317 | dev->interrupt_in_buffer, |
| 318 | le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), | 318 | usb_endpoint_maxp(dev->interrupt_in_endpoint), |
| 319 | adu_interrupt_in_callback, dev, | 319 | adu_interrupt_in_callback, dev, |
| 320 | dev->interrupt_in_endpoint->bInterval); | 320 | dev->interrupt_in_endpoint->bInterval); |
| 321 | dev->read_urb_finished = 0; | 321 | dev->read_urb_finished = 0; |
| @@ -483,7 +483,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, | |||
| 483 | usb_rcvintpipe(dev->udev, | 483 | usb_rcvintpipe(dev->udev, |
| 484 | dev->interrupt_in_endpoint->bEndpointAddress), | 484 | dev->interrupt_in_endpoint->bEndpointAddress), |
| 485 | dev->interrupt_in_buffer, | 485 | dev->interrupt_in_buffer, |
| 486 | le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), | 486 | usb_endpoint_maxp(dev->interrupt_in_endpoint), |
| 487 | adu_interrupt_in_callback, | 487 | adu_interrupt_in_callback, |
| 488 | dev, | 488 | dev, |
| 489 | dev->interrupt_in_endpoint->bInterval); | 489 | dev->interrupt_in_endpoint->bInterval); |
| @@ -536,7 +536,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, | |||
| 536 | usb_rcvintpipe(dev->udev, | 536 | usb_rcvintpipe(dev->udev, |
| 537 | dev->interrupt_in_endpoint->bEndpointAddress), | 537 | dev->interrupt_in_endpoint->bEndpointAddress), |
| 538 | dev->interrupt_in_buffer, | 538 | dev->interrupt_in_buffer, |
| 539 | le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), | 539 | usb_endpoint_maxp(dev->interrupt_in_endpoint), |
| 540 | adu_interrupt_in_callback, | 540 | adu_interrupt_in_callback, |
| 541 | dev, | 541 | dev, |
| 542 | dev->interrupt_in_endpoint->bInterval); | 542 | dev->interrupt_in_endpoint->bInterval); |
| @@ -622,7 +622,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, | |||
| 622 | dbg(4," %s : sending, count = %Zd", __func__, count); | 622 | dbg(4," %s : sending, count = %Zd", __func__, count); |
| 623 | 623 | ||
| 624 | /* write the data into interrupt_out_buffer from userspace */ | 624 | /* write the data into interrupt_out_buffer from userspace */ |
| 625 | buffer_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize); | 625 | buffer_size = usb_endpoint_maxp(dev->interrupt_out_endpoint); |
| 626 | bytes_to_write = count > buffer_size ? buffer_size : count; | 626 | bytes_to_write = count > buffer_size ? buffer_size : count; |
| 627 | dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd", | 627 | dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd", |
| 628 | __func__, buffer_size, count, bytes_to_write); | 628 | __func__, buffer_size, count, bytes_to_write); |
| @@ -752,8 +752,8 @@ static int adu_probe(struct usb_interface *interface, | |||
| 752 | goto error; | 752 | goto error; |
| 753 | } | 753 | } |
| 754 | 754 | ||
| 755 | in_end_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize); | 755 | in_end_size = usb_endpoint_maxp(dev->interrupt_in_endpoint); |
| 756 | out_end_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize); | 756 | out_end_size = usb_endpoint_maxp(dev->interrupt_out_endpoint); |
| 757 | 757 | ||
| 758 | dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL); | 758 | dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL); |
| 759 | if (!dev->read_buffer_primary) { | 759 | if (!dev->read_buffer_primary) { |
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index 2f41089cd854..2dbe600fbc11 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
| @@ -2777,7 +2777,7 @@ static int ftdi_elan_probe(struct usb_interface *interface, | |||
| 2777 | endpoint = &iface_desc->endpoint[i].desc; | 2777 | endpoint = &iface_desc->endpoint[i].desc; |
| 2778 | if (!ftdi->bulk_in_endpointAddr && | 2778 | if (!ftdi->bulk_in_endpointAddr && |
| 2779 | usb_endpoint_is_bulk_in(endpoint)) { | 2779 | usb_endpoint_is_bulk_in(endpoint)) { |
| 2780 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | 2780 | buffer_size = usb_endpoint_maxp(endpoint); |
| 2781 | ftdi->bulk_in_size = buffer_size; | 2781 | ftdi->bulk_in_size = buffer_size; |
| 2782 | ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress; | 2782 | ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress; |
| 2783 | ftdi->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); | 2783 | ftdi->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index c6184b4d1695..515b67fffab1 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
| @@ -359,7 +359,7 @@ static int idmouse_probe(struct usb_interface *interface, | |||
| 359 | endpoint = &iface_desc->endpoint[0].desc; | 359 | endpoint = &iface_desc->endpoint[0].desc; |
| 360 | if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) { | 360 | if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) { |
| 361 | /* we found a bulk in endpoint */ | 361 | /* we found a bulk in endpoint */ |
| 362 | dev->orig_bi_size = le16_to_cpu(endpoint->wMaxPacketSize); | 362 | dev->orig_bi_size = usb_endpoint_maxp(endpoint); |
| 363 | dev->bulk_in_size = 0x200; /* works _much_ faster */ | 363 | dev->bulk_in_size = 0x200; /* works _much_ faster */ |
| 364 | dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; | 364 | dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; |
| 365 | dev->bulk_in_buffer = | 365 | dev->bulk_in_buffer = |
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index a2190b983f52..81457904d6ba 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
| @@ -803,7 +803,7 @@ static int iowarrior_probe(struct usb_interface *interface, | |||
| 803 | dev->int_out_endpoint = endpoint; | 803 | dev->int_out_endpoint = endpoint; |
| 804 | } | 804 | } |
| 805 | /* we have to check the report_size often, so remember it in the endianess suitable for our machine */ | 805 | /* we have to check the report_size often, so remember it in the endianess suitable for our machine */ |
| 806 | dev->report_size = le16_to_cpu(dev->int_in_endpoint->wMaxPacketSize); | 806 | dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint); |
| 807 | if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) && | 807 | if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) && |
| 808 | (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56)) | 808 | (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56)) |
| 809 | /* IOWarrior56 has wMaxPacketSize different from report size */ | 809 | /* IOWarrior56 has wMaxPacketSize different from report size */ |
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index cb4096201e29..48c166f0d764 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
| @@ -721,7 +721,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * | |||
| 721 | if (dev->interrupt_out_endpoint == NULL) | 721 | if (dev->interrupt_out_endpoint == NULL) |
| 722 | dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n"); | 722 | dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n"); |
| 723 | 723 | ||
| 724 | dev->interrupt_in_endpoint_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize); | 724 | dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint); |
| 725 | dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL); | 725 | dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL); |
| 726 | if (!dev->ring_buffer) { | 726 | if (!dev->ring_buffer) { |
| 727 | dev_err(&intf->dev, "Couldn't allocate ring_buffer\n"); | 727 | dev_err(&intf->dev, "Couldn't allocate ring_buffer\n"); |
| @@ -737,7 +737,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * | |||
| 737 | dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n"); | 737 | dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n"); |
| 738 | goto error; | 738 | goto error; |
| 739 | } | 739 | } |
| 740 | dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize) : | 740 | dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? usb_endpoint_maxp(dev->interrupt_out_endpoint) : |
| 741 | udev->descriptor.bMaxPacketSize0; | 741 | udev->descriptor.bMaxPacketSize0; |
| 742 | dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL); | 742 | dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL); |
| 743 | if (!dev->interrupt_out_buffer) { | 743 | if (!dev->interrupt_out_buffer) { |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 6482c6e2e6bd..a989356f693e 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
| @@ -409,7 +409,7 @@ static int tower_open (struct inode *inode, struct file *file) | |||
| 409 | dev->udev, | 409 | dev->udev, |
| 410 | usb_rcvintpipe(dev->udev, dev->interrupt_in_endpoint->bEndpointAddress), | 410 | usb_rcvintpipe(dev->udev, dev->interrupt_in_endpoint->bEndpointAddress), |
| 411 | dev->interrupt_in_buffer, | 411 | dev->interrupt_in_buffer, |
| 412 | le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), | 412 | usb_endpoint_maxp(dev->interrupt_in_endpoint), |
| 413 | tower_interrupt_in_callback, | 413 | tower_interrupt_in_callback, |
| 414 | dev, | 414 | dev, |
| 415 | dev->interrupt_in_interval); | 415 | dev->interrupt_in_interval); |
| @@ -928,7 +928,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
| 928 | err("Couldn't allocate read_buffer"); | 928 | err("Couldn't allocate read_buffer"); |
| 929 | goto error; | 929 | goto error; |
| 930 | } | 930 | } |
| 931 | dev->interrupt_in_buffer = kmalloc (le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), GFP_KERNEL); | 931 | dev->interrupt_in_buffer = kmalloc (usb_endpoint_maxp(dev->interrupt_in_endpoint), GFP_KERNEL); |
| 932 | if (!dev->interrupt_in_buffer) { | 932 | if (!dev->interrupt_in_buffer) { |
| 933 | err("Couldn't allocate interrupt_in_buffer"); | 933 | err("Couldn't allocate interrupt_in_buffer"); |
| 934 | goto error; | 934 | goto error; |
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 51648154bb44..1871cdf10da3 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
| 19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
| 20 | #include <linux/mutex.h> | 20 | #include <linux/mutex.h> |
| 21 | #include <asm/uaccess.h> | 21 | #include <linux/uaccess.h> |
| 22 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
| 23 | 23 | ||
| 24 | #define DRIVER_VERSION "USBLCD Driver Version 1.05" | 24 | #define DRIVER_VERSION "USBLCD Driver Version 1.05" |
| @@ -34,22 +34,29 @@ static const struct usb_device_id id_table[] = { | |||
| 34 | { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, | 34 | { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, |
| 35 | { }, | 35 | { }, |
| 36 | }; | 36 | }; |
| 37 | MODULE_DEVICE_TABLE (usb, id_table); | 37 | MODULE_DEVICE_TABLE(usb, id_table); |
| 38 | 38 | ||
| 39 | static DEFINE_MUTEX(open_disc_mutex); | 39 | static DEFINE_MUTEX(open_disc_mutex); |
| 40 | 40 | ||
| 41 | 41 | ||
| 42 | struct usb_lcd { | 42 | struct usb_lcd { |
| 43 | struct usb_device * udev; /* init: probe_lcd */ | 43 | struct usb_device *udev; /* init: probe_lcd */ |
| 44 | struct usb_interface * interface; /* the interface for this device */ | 44 | struct usb_interface *interface; /* the interface for |
| 45 | unsigned char * bulk_in_buffer; /* the buffer to receive data */ | 45 | this device */ |
| 46 | size_t bulk_in_size; /* the size of the receive buffer */ | 46 | unsigned char *bulk_in_buffer; /* the buffer to receive |
| 47 | __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */ | 47 | data */ |
| 48 | __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */ | 48 | size_t bulk_in_size; /* the size of the |
| 49 | receive buffer */ | ||
| 50 | __u8 bulk_in_endpointAddr; /* the address of the | ||
| 51 | bulk in endpoint */ | ||
| 52 | __u8 bulk_out_endpointAddr; /* the address of the | ||
| 53 | bulk out endpoint */ | ||
| 49 | struct kref kref; | 54 | struct kref kref; |
| 50 | struct semaphore limit_sem; /* to stop writes at full throttle from | 55 | struct semaphore limit_sem; /* to stop writes at |
| 51 | * using up all RAM */ | 56 | full throttle from |
| 52 | struct usb_anchor submitted; /* URBs to wait for before suspend */ | 57 | using up all RAM */ |
| 58 | struct usb_anchor submitted; /* URBs to wait for | ||
| 59 | before suspend */ | ||
| 53 | }; | 60 | }; |
| 54 | #define to_lcd_dev(d) container_of(d, struct usb_lcd, kref) | 61 | #define to_lcd_dev(d) container_of(d, struct usb_lcd, kref) |
| 55 | 62 | ||
| @@ -63,8 +70,8 @@ static void lcd_delete(struct kref *kref) | |||
| 63 | struct usb_lcd *dev = to_lcd_dev(kref); | 70 | struct usb_lcd *dev = to_lcd_dev(kref); |
| 64 | 71 | ||
| 65 | usb_put_dev(dev->udev); | 72 | usb_put_dev(dev->udev); |
| 66 | kfree (dev->bulk_in_buffer); | 73 | kfree(dev->bulk_in_buffer); |
| 67 | kfree (dev); | 74 | kfree(dev); |
| 68 | } | 75 | } |
| 69 | 76 | ||
| 70 | 77 | ||
| @@ -80,7 +87,7 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
| 80 | interface = usb_find_interface(&lcd_driver, subminor); | 87 | interface = usb_find_interface(&lcd_driver, subminor); |
| 81 | if (!interface) { | 88 | if (!interface) { |
| 82 | mutex_unlock(&lcd_mutex); | 89 | mutex_unlock(&lcd_mutex); |
| 83 | err ("USBLCD: %s - error, can't find device for minor %d", | 90 | err("USBLCD: %s - error, can't find device for minor %d", |
| 84 | __func__, subminor); | 91 | __func__, subminor); |
| 85 | return -ENODEV; | 92 | return -ENODEV; |
| 86 | } | 93 | } |
| @@ -126,7 +133,8 @@ static int lcd_release(struct inode *inode, struct file *file) | |||
| 126 | return 0; | 133 | return 0; |
| 127 | } | 134 | } |
| 128 | 135 | ||
| 129 | static ssize_t lcd_read(struct file *file, char __user * buffer, size_t count, loff_t *ppos) | 136 | static ssize_t lcd_read(struct file *file, char __user * buffer, |
| 137 | size_t count, loff_t *ppos) | ||
| 130 | { | 138 | { |
| 131 | struct usb_lcd *dev; | 139 | struct usb_lcd *dev; |
| 132 | int retval = 0; | 140 | int retval = 0; |
| @@ -135,8 +143,9 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, size_t count, l | |||
| 135 | dev = file->private_data; | 143 | dev = file->private_data; |
| 136 | 144 | ||
| 137 | /* do a blocking bulk read to get data from the device */ | 145 | /* do a blocking bulk read to get data from the device */ |
| 138 | retval = usb_bulk_msg(dev->udev, | 146 | retval = usb_bulk_msg(dev->udev, |
| 139 | usb_rcvbulkpipe(dev->udev, dev->bulk_in_endpointAddr), | 147 | usb_rcvbulkpipe(dev->udev, |
| 148 | dev->bulk_in_endpointAddr), | ||
| 140 | dev->bulk_in_buffer, | 149 | dev->bulk_in_buffer, |
| 141 | min(dev->bulk_in_size, count), | 150 | min(dev->bulk_in_size, count), |
| 142 | &bytes_read, 10000); | 151 | &bytes_read, 10000); |
| @@ -161,23 +170,23 @@ static long lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 161 | dev = file->private_data; | 170 | dev = file->private_data; |
| 162 | if (dev == NULL) | 171 | if (dev == NULL) |
| 163 | return -ENODEV; | 172 | return -ENODEV; |
| 164 | 173 | ||
| 165 | switch (cmd) { | 174 | switch (cmd) { |
| 166 | case IOCTL_GET_HARD_VERSION: | 175 | case IOCTL_GET_HARD_VERSION: |
| 167 | mutex_lock(&lcd_mutex); | 176 | mutex_lock(&lcd_mutex); |
| 168 | bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice); | 177 | bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice); |
| 169 | sprintf(buf,"%1d%1d.%1d%1d", | 178 | sprintf(buf, "%1d%1d.%1d%1d", |
| 170 | (bcdDevice & 0xF000)>>12, | 179 | (bcdDevice & 0xF000)>>12, |
| 171 | (bcdDevice & 0xF00)>>8, | 180 | (bcdDevice & 0xF00)>>8, |
| 172 | (bcdDevice & 0xF0)>>4, | 181 | (bcdDevice & 0xF0)>>4, |
| 173 | (bcdDevice & 0xF)); | 182 | (bcdDevice & 0xF)); |
| 174 | mutex_unlock(&lcd_mutex); | 183 | mutex_unlock(&lcd_mutex); |
| 175 | if (copy_to_user((void __user *)arg,buf,strlen(buf))!=0) | 184 | if (copy_to_user((void __user *)arg, buf, strlen(buf)) != 0) |
| 176 | return -EFAULT; | 185 | return -EFAULT; |
| 177 | break; | 186 | break; |
| 178 | case IOCTL_GET_DRV_VERSION: | 187 | case IOCTL_GET_DRV_VERSION: |
| 179 | sprintf(buf,DRIVER_VERSION); | 188 | sprintf(buf, DRIVER_VERSION); |
| 180 | if (copy_to_user((void __user *)arg,buf,strlen(buf))!=0) | 189 | if (copy_to_user((void __user *)arg, buf, strlen(buf)) != 0) |
| 181 | return -EFAULT; | 190 | return -EFAULT; |
| 182 | break; | 191 | break; |
| 183 | default: | 192 | default: |
| @@ -199,7 +208,7 @@ static void lcd_write_bulk_callback(struct urb *urb) | |||
| 199 | if (status && | 208 | if (status && |
| 200 | !(status == -ENOENT || | 209 | !(status == -ENOENT || |
| 201 | status == -ECONNRESET || | 210 | status == -ECONNRESET || |
| 202 | status == -ESHUTDOWN)) { | 211 | status == -ESHUTDOWN)) { |
| 203 | dbg("USBLCD: %s - nonzero write bulk status received: %d", | 212 | dbg("USBLCD: %s - nonzero write bulk status received: %d", |
| 204 | __func__, status); | 213 | __func__, status); |
| 205 | } | 214 | } |
| @@ -210,15 +219,16 @@ static void lcd_write_bulk_callback(struct urb *urb) | |||
| 210 | up(&dev->limit_sem); | 219 | up(&dev->limit_sem); |
| 211 | } | 220 | } |
| 212 | 221 | ||
| 213 | static ssize_t lcd_write(struct file *file, const char __user * user_buffer, size_t count, loff_t *ppos) | 222 | static ssize_t lcd_write(struct file *file, const char __user * user_buffer, |
| 223 | size_t count, loff_t *ppos) | ||
| 214 | { | 224 | { |
| 215 | struct usb_lcd *dev; | 225 | struct usb_lcd *dev; |
| 216 | int retval = 0, r; | 226 | int retval = 0, r; |
| 217 | struct urb *urb = NULL; | 227 | struct urb *urb = NULL; |
| 218 | char *buf = NULL; | 228 | char *buf = NULL; |
| 219 | 229 | ||
| 220 | dev = file->private_data; | 230 | dev = file->private_data; |
| 221 | 231 | ||
| 222 | /* verify that we actually have some data to write */ | 232 | /* verify that we actually have some data to write */ |
| 223 | if (count == 0) | 233 | if (count == 0) |
| 224 | goto exit; | 234 | goto exit; |
| @@ -233,34 +243,38 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, siz | |||
| 233 | retval = -ENOMEM; | 243 | retval = -ENOMEM; |
| 234 | goto err_no_buf; | 244 | goto err_no_buf; |
| 235 | } | 245 | } |
| 236 | 246 | ||
| 237 | buf = usb_alloc_coherent(dev->udev, count, GFP_KERNEL, &urb->transfer_dma); | 247 | buf = usb_alloc_coherent(dev->udev, count, GFP_KERNEL, |
| 248 | &urb->transfer_dma); | ||
| 238 | if (!buf) { | 249 | if (!buf) { |
| 239 | retval = -ENOMEM; | 250 | retval = -ENOMEM; |
| 240 | goto error; | 251 | goto error; |
| 241 | } | 252 | } |
| 242 | 253 | ||
| 243 | if (copy_from_user(buf, user_buffer, count)) { | 254 | if (copy_from_user(buf, user_buffer, count)) { |
| 244 | retval = -EFAULT; | 255 | retval = -EFAULT; |
| 245 | goto error; | 256 | goto error; |
| 246 | } | 257 | } |
| 247 | 258 | ||
| 248 | /* initialize the urb properly */ | 259 | /* initialize the urb properly */ |
| 249 | usb_fill_bulk_urb(urb, dev->udev, | 260 | usb_fill_bulk_urb(urb, dev->udev, |
| 250 | usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr), | 261 | usb_sndbulkpipe(dev->udev, |
| 262 | dev->bulk_out_endpointAddr), | ||
| 251 | buf, count, lcd_write_bulk_callback, dev); | 263 | buf, count, lcd_write_bulk_callback, dev); |
| 252 | urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 264 | urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 253 | 265 | ||
| 254 | usb_anchor_urb(urb, &dev->submitted); | 266 | usb_anchor_urb(urb, &dev->submitted); |
| 255 | 267 | ||
| 256 | /* send the data out the bulk port */ | 268 | /* send the data out the bulk port */ |
| 257 | retval = usb_submit_urb(urb, GFP_KERNEL); | 269 | retval = usb_submit_urb(urb, GFP_KERNEL); |
| 258 | if (retval) { | 270 | if (retval) { |
| 259 | err("USBLCD: %s - failed submitting write urb, error %d", __func__, retval); | 271 | err("USBLCD: %s - failed submitting write urb, error %d", |
| 272 | __func__, retval); | ||
| 260 | goto error_unanchor; | 273 | goto error_unanchor; |
| 261 | } | 274 | } |
| 262 | 275 | ||
| 263 | /* release our reference to this urb, the USB core will eventually free it entirely */ | 276 | /* release our reference to this urb, |
| 277 | the USB core will eventually free it entirely */ | ||
| 264 | usb_free_urb(urb); | 278 | usb_free_urb(urb); |
| 265 | 279 | ||
| 266 | exit: | 280 | exit: |
| @@ -276,13 +290,13 @@ err_no_buf: | |||
| 276 | } | 290 | } |
| 277 | 291 | ||
| 278 | static const struct file_operations lcd_fops = { | 292 | static const struct file_operations lcd_fops = { |
| 279 | .owner = THIS_MODULE, | 293 | .owner = THIS_MODULE, |
| 280 | .read = lcd_read, | 294 | .read = lcd_read, |
| 281 | .write = lcd_write, | 295 | .write = lcd_write, |
| 282 | .open = lcd_open, | 296 | .open = lcd_open, |
| 283 | .unlocked_ioctl = lcd_ioctl, | 297 | .unlocked_ioctl = lcd_ioctl, |
| 284 | .release = lcd_release, | 298 | .release = lcd_release, |
| 285 | .llseek = noop_llseek, | 299 | .llseek = noop_llseek, |
| 286 | }; | 300 | }; |
| 287 | 301 | ||
| 288 | /* | 302 | /* |
| @@ -290,12 +304,13 @@ static const struct file_operations lcd_fops = { | |||
| 290 | * and to have the device registered with the driver core | 304 | * and to have the device registered with the driver core |
| 291 | */ | 305 | */ |
| 292 | static struct usb_class_driver lcd_class = { | 306 | static struct usb_class_driver lcd_class = { |
| 293 | .name = "lcd%d", | 307 | .name = "lcd%d", |
| 294 | .fops = &lcd_fops, | 308 | .fops = &lcd_fops, |
| 295 | .minor_base = USBLCD_MINOR, | 309 | .minor_base = USBLCD_MINOR, |
| 296 | }; | 310 | }; |
| 297 | 311 | ||
| 298 | static int lcd_probe(struct usb_interface *interface, const struct usb_device_id *id) | 312 | static int lcd_probe(struct usb_interface *interface, |
| 313 | const struct usb_device_id *id) | ||
| 299 | { | 314 | { |
| 300 | struct usb_lcd *dev = NULL; | 315 | struct usb_lcd *dev = NULL; |
| 301 | struct usb_host_interface *iface_desc; | 316 | struct usb_host_interface *iface_desc; |
| @@ -322,7 +337,7 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id | |||
| 322 | retval = -ENODEV; | 337 | retval = -ENODEV; |
| 323 | goto error; | 338 | goto error; |
| 324 | } | 339 | } |
| 325 | 340 | ||
| 326 | /* set up the endpoint information */ | 341 | /* set up the endpoint information */ |
| 327 | /* use only the first bulk-in and bulk-out endpoints */ | 342 | /* use only the first bulk-in and bulk-out endpoints */ |
| 328 | iface_desc = interface->cur_altsetting; | 343 | iface_desc = interface->cur_altsetting; |
| @@ -332,7 +347,7 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id | |||
| 332 | if (!dev->bulk_in_endpointAddr && | 347 | if (!dev->bulk_in_endpointAddr && |
| 333 | usb_endpoint_is_bulk_in(endpoint)) { | 348 | usb_endpoint_is_bulk_in(endpoint)) { |
| 334 | /* we found a bulk in endpoint */ | 349 | /* we found a bulk in endpoint */ |
| 335 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | 350 | buffer_size = usb_endpoint_maxp(endpoint); |
| 336 | dev->bulk_in_size = buffer_size; | 351 | dev->bulk_in_size = buffer_size; |
| 337 | dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; | 352 | dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; |
| 338 | dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); | 353 | dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); |
| @@ -369,7 +384,7 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id | |||
| 369 | 384 | ||
| 370 | dev_info(&interface->dev, "USBLCD Version %1d%1d.%1d%1d found " | 385 | dev_info(&interface->dev, "USBLCD Version %1d%1d.%1d%1d found " |
| 371 | "at address %d\n", (i & 0xF000)>>12, (i & 0xF00)>>8, | 386 | "at address %d\n", (i & 0xF000)>>12, (i & 0xF00)>>8, |
| 372 | (i & 0xF0)>>4,(i & 0xF), dev->udev->devnum); | 387 | (i & 0xF0)>>4, (i & 0xF), dev->udev->devnum); |
| 373 | 388 | ||
| 374 | /* let the user know what node this device is now attached to */ | 389 | /* let the user know what node this device is now attached to */ |
| 375 | dev_info(&interface->dev, "USB LCD device now attached to USBLCD-%d\n", | 390 | dev_info(&interface->dev, "USB LCD device now attached to USBLCD-%d\n", |
| @@ -401,7 +416,7 @@ static int lcd_suspend(struct usb_interface *intf, pm_message_t message) | |||
| 401 | return 0; | 416 | return 0; |
| 402 | } | 417 | } |
| 403 | 418 | ||
| 404 | static int lcd_resume (struct usb_interface *intf) | 419 | static int lcd_resume(struct usb_interface *intf) |
| 405 | { | 420 | { |
| 406 | return 0; | 421 | return 0; |
| 407 | } | 422 | } |
| @@ -409,16 +424,16 @@ static int lcd_resume (struct usb_interface *intf) | |||
| 409 | static void lcd_disconnect(struct usb_interface *interface) | 424 | static void lcd_disconnect(struct usb_interface *interface) |
| 410 | { | 425 | { |
| 411 | struct usb_lcd *dev; | 426 | struct usb_lcd *dev; |
| 412 | int minor = interface->minor; | 427 | int minor = interface->minor; |
| 413 | 428 | ||
| 414 | mutex_lock(&open_disc_mutex); | 429 | mutex_lock(&open_disc_mutex); |
| 415 | dev = usb_get_intfdata(interface); | 430 | dev = usb_get_intfdata(interface); |
| 416 | usb_set_intfdata(interface, NULL); | 431 | usb_set_intfdata(interface, NULL); |
| 417 | mutex_unlock(&open_disc_mutex); | 432 | mutex_unlock(&open_disc_mutex); |
| 418 | 433 | ||
| 419 | /* give back our minor */ | 434 | /* give back our minor */ |
| 420 | usb_deregister_dev(interface, &lcd_class); | 435 | usb_deregister_dev(interface, &lcd_class); |
| 421 | 436 | ||
| 422 | /* decrement our usage count */ | 437 | /* decrement our usage count */ |
| 423 | kref_put(&dev->kref, lcd_delete); | 438 | kref_put(&dev->kref, lcd_delete); |
| 424 | 439 | ||
| @@ -438,7 +453,7 @@ static struct usb_driver lcd_driver = { | |||
| 438 | static int __init usb_lcd_init(void) | 453 | static int __init usb_lcd_init(void) |
| 439 | { | 454 | { |
| 440 | int result; | 455 | int result; |
| 441 | 456 | ||
| 442 | result = usb_register(&lcd_driver); | 457 | result = usb_register(&lcd_driver); |
| 443 | if (result) | 458 | if (result) |
| 444 | err("usb_register failed. Error number %d", result); | 459 | err("usb_register failed. Error number %d", result); |
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c index 1616ad1793a4..43f84e50d514 100644 --- a/drivers/usb/misc/usbled.c +++ b/drivers/usb/misc/usbled.c | |||
| @@ -33,10 +33,10 @@ static const struct usb_device_id id_table[] = { | |||
| 33 | .driver_info = DREAM_CHEEKY_WEBMAIL_NOTIFIER }, | 33 | .driver_info = DREAM_CHEEKY_WEBMAIL_NOTIFIER }, |
| 34 | { }, | 34 | { }, |
| 35 | }; | 35 | }; |
| 36 | MODULE_DEVICE_TABLE (usb, id_table); | 36 | MODULE_DEVICE_TABLE(usb, id_table); |
| 37 | 37 | ||
| 38 | struct usb_led { | 38 | struct usb_led { |
| 39 | struct usb_device * udev; | 39 | struct usb_device *udev; |
| 40 | unsigned char blue; | 40 | unsigned char blue; |
| 41 | unsigned char red; | 41 | unsigned char red; |
| 42 | unsigned char green; | 42 | unsigned char green; |
| @@ -113,14 +113,16 @@ static void change_color(struct usb_led *led) | |||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | #define show_set(value) \ | 115 | #define show_set(value) \ |
| 116 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | 116 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr,\ |
| 117 | char *buf) \ | ||
| 117 | { \ | 118 | { \ |
| 118 | struct usb_interface *intf = to_usb_interface(dev); \ | 119 | struct usb_interface *intf = to_usb_interface(dev); \ |
| 119 | struct usb_led *led = usb_get_intfdata(intf); \ | 120 | struct usb_led *led = usb_get_intfdata(intf); \ |
| 120 | \ | 121 | \ |
| 121 | return sprintf(buf, "%d\n", led->value); \ | 122 | return sprintf(buf, "%d\n", led->value); \ |
| 122 | } \ | 123 | } \ |
| 123 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ | 124 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr,\ |
| 125 | const char *buf, size_t count) \ | ||
| 124 | { \ | 126 | { \ |
| 125 | struct usb_interface *intf = to_usb_interface(dev); \ | 127 | struct usb_interface *intf = to_usb_interface(dev); \ |
| 126 | struct usb_led *led = usb_get_intfdata(intf); \ | 128 | struct usb_led *led = usb_get_intfdata(intf); \ |
| @@ -135,7 +137,8 @@ show_set(blue); | |||
| 135 | show_set(red); | 137 | show_set(red); |
| 136 | show_set(green); | 138 | show_set(green); |
| 137 | 139 | ||
| 138 | static int led_probe(struct usb_interface *interface, const struct usb_device_id *id) | 140 | static int led_probe(struct usb_interface *interface, |
| 141 | const struct usb_device_id *id) | ||
| 139 | { | 142 | { |
| 140 | struct usb_device *udev = interface_to_usbdev(interface); | 143 | struct usb_device *udev = interface_to_usbdev(interface); |
| 141 | struct usb_led *dev = NULL; | 144 | struct usb_led *dev = NULL; |
| @@ -150,7 +153,7 @@ static int led_probe(struct usb_interface *interface, const struct usb_device_id | |||
| 150 | dev->udev = usb_get_dev(udev); | 153 | dev->udev = usb_get_dev(udev); |
| 151 | dev->type = id->driver_info; | 154 | dev->type = id->driver_info; |
| 152 | 155 | ||
| 153 | usb_set_intfdata (interface, dev); | 156 | usb_set_intfdata(interface, dev); |
| 154 | 157 | ||
| 155 | retval = device_create_file(&interface->dev, &dev_attr_blue); | 158 | retval = device_create_file(&interface->dev, &dev_attr_blue); |
| 156 | if (retval) | 159 | if (retval) |
| @@ -194,7 +197,7 @@ error: | |||
| 194 | device_remove_file(&interface->dev, &dev_attr_blue); | 197 | device_remove_file(&interface->dev, &dev_attr_blue); |
| 195 | device_remove_file(&interface->dev, &dev_attr_red); | 198 | device_remove_file(&interface->dev, &dev_attr_red); |
| 196 | device_remove_file(&interface->dev, &dev_attr_green); | 199 | device_remove_file(&interface->dev, &dev_attr_green); |
| 197 | usb_set_intfdata (interface, NULL); | 200 | usb_set_intfdata(interface, NULL); |
| 198 | usb_put_dev(dev->udev); | 201 | usb_put_dev(dev->udev); |
| 199 | kfree(dev); | 202 | kfree(dev); |
| 200 | error_mem: | 203 | error_mem: |
| @@ -205,14 +208,14 @@ static void led_disconnect(struct usb_interface *interface) | |||
| 205 | { | 208 | { |
| 206 | struct usb_led *dev; | 209 | struct usb_led *dev; |
| 207 | 210 | ||
| 208 | dev = usb_get_intfdata (interface); | 211 | dev = usb_get_intfdata(interface); |
| 209 | 212 | ||
| 210 | device_remove_file(&interface->dev, &dev_attr_blue); | 213 | device_remove_file(&interface->dev, &dev_attr_blue); |
| 211 | device_remove_file(&interface->dev, &dev_attr_red); | 214 | device_remove_file(&interface->dev, &dev_attr_red); |
| 212 | device_remove_file(&interface->dev, &dev_attr_green); | 215 | device_remove_file(&interface->dev, &dev_attr_green); |
| 213 | 216 | ||
| 214 | /* first remove the files, then set the pointer to NULL */ | 217 | /* first remove the files, then set the pointer to NULL */ |
| 215 | usb_set_intfdata (interface, NULL); | 218 | usb_set_intfdata(interface, NULL); |
| 216 | 219 | ||
| 217 | usb_put_dev(dev->udev); | 220 | usb_put_dev(dev->udev); |
| 218 | 221 | ||
| @@ -243,8 +246,8 @@ static void __exit usb_led_exit(void) | |||
| 243 | usb_deregister(&led_driver); | 246 | usb_deregister(&led_driver); |
| 244 | } | 247 | } |
| 245 | 248 | ||
| 246 | module_init (usb_led_init); | 249 | module_init(usb_led_init); |
| 247 | module_exit (usb_led_exit); | 250 | module_exit(usb_led_exit); |
| 248 | 251 | ||
| 249 | MODULE_AUTHOR(DRIVER_AUTHOR); | 252 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 250 | MODULE_DESCRIPTION(DRIVER_DESC); | 253 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index bb10846affc3..bd6d00802eab 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
| @@ -359,8 +359,10 @@ static int simple_io( | |||
| 359 | urb->context = &completion; | 359 | urb->context = &completion; |
| 360 | while (retval == 0 && iterations-- > 0) { | 360 | while (retval == 0 && iterations-- > 0) { |
| 361 | init_completion(&completion); | 361 | init_completion(&completion); |
| 362 | if (usb_pipeout(urb->pipe)) | 362 | if (usb_pipeout(urb->pipe)) { |
| 363 | simple_fill_buf(urb); | 363 | simple_fill_buf(urb); |
| 364 | urb->transfer_flags |= URB_ZERO_PACKET; | ||
| 365 | } | ||
| 364 | retval = usb_submit_urb(urb, GFP_KERNEL); | 366 | retval = usb_submit_urb(urb, GFP_KERNEL); |
| 365 | if (retval != 0) | 367 | if (retval != 0) |
| 366 | break; | 368 | break; |
| @@ -1583,8 +1585,8 @@ static struct urb *iso_alloc_urb( | |||
| 1583 | 1585 | ||
| 1584 | if (bytes < 0 || !desc) | 1586 | if (bytes < 0 || !desc) |
| 1585 | return NULL; | 1587 | return NULL; |
| 1586 | maxp = 0x7ff & le16_to_cpu(desc->wMaxPacketSize); | 1588 | maxp = 0x7ff & usb_endpoint_maxp(desc); |
| 1587 | maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); | 1589 | maxp *= 1 + (0x3 & (usb_endpoint_maxp(desc) >> 11)); |
| 1588 | packets = DIV_ROUND_UP(bytes, maxp); | 1590 | packets = DIV_ROUND_UP(bytes, maxp); |
| 1589 | 1591 | ||
| 1590 | urb = usb_alloc_urb(packets, GFP_KERNEL); | 1592 | urb = usb_alloc_urb(packets, GFP_KERNEL); |
| @@ -1654,7 +1656,7 @@ test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param, | |||
| 1654 | "... iso period %d %sframes, wMaxPacket %04x\n", | 1656 | "... iso period %d %sframes, wMaxPacket %04x\n", |
| 1655 | 1 << (desc->bInterval - 1), | 1657 | 1 << (desc->bInterval - 1), |
| 1656 | (udev->speed == USB_SPEED_HIGH) ? "micro" : "", | 1658 | (udev->speed == USB_SPEED_HIGH) ? "micro" : "", |
| 1657 | le16_to_cpu(desc->wMaxPacketSize)); | 1659 | usb_endpoint_maxp(desc)); |
| 1658 | 1660 | ||
| 1659 | for (i = 0; i < param->sglen; i++) { | 1661 | for (i = 0; i < param->sglen; i++) { |
| 1660 | urbs[i] = iso_alloc_urb(udev, pipe, desc, | 1662 | urbs[i] = iso_alloc_urb(udev, pipe, desc, |
| @@ -2298,25 +2300,8 @@ usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 2298 | 2300 | ||
| 2299 | usb_set_intfdata(intf, dev); | 2301 | usb_set_intfdata(intf, dev); |
| 2300 | dev_info(&intf->dev, "%s\n", info->name); | 2302 | dev_info(&intf->dev, "%s\n", info->name); |
| 2301 | dev_info(&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", | 2303 | dev_info(&intf->dev, "%s {control%s%s%s%s%s} tests%s\n", |
| 2302 | ({ char *tmp; | 2304 | usb_speed_string(udev->speed), |
| 2303 | switch (udev->speed) { | ||
| 2304 | case USB_SPEED_LOW: | ||
| 2305 | tmp = "low"; | ||
| 2306 | 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; | ||
| 2319 | }; tmp; }), | ||
| 2320 | info->ctrl_out ? " in/out" : "", | 2305 | info->ctrl_out ? " in/out" : "", |
| 2321 | rtest, wtest, | 2306 | rtest, wtest, |
| 2322 | irtest, iwtest, | 2307 | irtest, iwtest, |
