summaryrefslogtreecommitdiffstats
path: root/kernel/drivers/usb/misc
diff options
context:
space:
mode:
authorJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-04-11 10:41:07 +0300
committerJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-04-13 08:17:18 +0300
commite09b41010ba33a20a87472ee821fa407a5b8da36 (patch)
treed10dc367189862e7ca5c592f033dc3726e1df4e3 /kernel/drivers/usb/misc
parentf93b97fd65072de626c074dbe099a1fff05ce060 (diff)
These changes are the raw update to linux-4.4.6-rt14. Kernel sources
are taken from kernel.org, and rt patch from the rt wiki download page. During the rebasing, the following patch collided: Force tick interrupt and get rid of softirq magic(I70131fb85). Collisions have been removed because its logic was found on the source already. Change-Id: I7f57a4081d9deaa0d9ccfc41a6c8daccdee3b769 Signed-off-by: José Pekkarinen <jose.pekkarinen@nokia.com>
Diffstat (limited to 'kernel/drivers/usb/misc')
-rw-r--r--kernel/drivers/usb/misc/chaoskey.c2
-rw-r--r--kernel/drivers/usb/misc/ftdi-elan.c12
-rw-r--r--kernel/drivers/usb/misc/ldusb.c10
-rw-r--r--kernel/drivers/usb/misc/lvstest.c2
-rw-r--r--kernel/drivers/usb/misc/sisusbvga/sisusb.c39
-rw-r--r--kernel/drivers/usb/misc/sisusbvga/sisusb_con.c54
-rw-r--r--kernel/drivers/usb/misc/usb3503.c2
-rw-r--r--kernel/drivers/usb/misc/usbtest.c155
-rw-r--r--kernel/drivers/usb/misc/uss720.c6
9 files changed, 179 insertions, 103 deletions
diff --git a/kernel/drivers/usb/misc/chaoskey.c b/kernel/drivers/usb/misc/chaoskey.c
index 3ad5d19e4..23c794813 100644
--- a/kernel/drivers/usb/misc/chaoskey.c
+++ b/kernel/drivers/usb/misc/chaoskey.c
@@ -472,7 +472,7 @@ static int chaoskey_rng_read(struct hwrng *rng, void *data,
if (this_time > max)
this_time = max;
- memcpy(data, dev->buf, this_time);
+ memcpy(data, dev->buf + dev->used, this_time);
dev->used += this_time;
diff --git a/kernel/drivers/usb/misc/ftdi-elan.c b/kernel/drivers/usb/misc/ftdi-elan.c
index 8ab1f8f3c..52c27cab7 100644
--- a/kernel/drivers/usb/misc/ftdi-elan.c
+++ b/kernel/drivers/usb/misc/ftdi-elan.c
@@ -2568,11 +2568,7 @@ static int ftdi_elan_close_controller(struct usb_ftdi *ftdi, int fn)
0x00);
if (UxxxStatus)
return UxxxStatus;
- UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
- &pcidata);
- if (UxxxStatus)
- return UxxxStatus;
- return 0;
+ return ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, &pcidata);
}
static int ftdi_elan_found_controller(struct usb_ftdi *ftdi, int fn, int quirk)
@@ -2695,11 +2691,7 @@ static int ftdi_elan_setupOHCI(struct usb_ftdi *ftdi)
}
}
if (ftdi->function > 0) {
- UxxxStatus = ftdi_elan_setup_controller(ftdi,
- ftdi->function - 1);
- if (UxxxStatus)
- return UxxxStatus;
- return 0;
+ return ftdi_elan_setup_controller(ftdi, ftdi->function - 1);
} else if (controllers > 0) {
return -ENXIO;
} else if (unrecognized > 0) {
diff --git a/kernel/drivers/usb/misc/ldusb.c b/kernel/drivers/usb/misc/ldusb.c
index 82503a7ff..cce22ff1c 100644
--- a/kernel/drivers/usb/misc/ldusb.c
+++ b/kernel/drivers/usb/misc/ldusb.c
@@ -69,12 +69,6 @@
#define USB_DEVICE_ID_LD_HYBRID 0x2090 /* USB Product ID of Automotive Hybrid */
#define USB_DEVICE_ID_LD_HEATCONTROL 0x20A0 /* USB Product ID of Heat control */
-#define USB_VENDOR_ID_VERNIER 0x08f7
-#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
-#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
-#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
-#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
-
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define USB_LD_MINOR_BASE 0
#else
@@ -115,10 +109,6 @@ static const struct usb_device_id ld_usb_table[] = {
{ USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) },
{ USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) },
{ USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) },
- { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
- { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
- { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
- { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, ld_usb_table);
diff --git a/kernel/drivers/usb/misc/lvstest.c b/kernel/drivers/usb/misc/lvstest.c
index 62cb8cd08..86b4e4b2a 100644
--- a/kernel/drivers/usb/misc/lvstest.c
+++ b/kernel/drivers/usb/misc/lvstest.c
@@ -4,7 +4,7 @@
* Test pattern generation for Link Layer Validation System Tests
*
* Copyright (C) 2014 ST Microelectronics
- * Pratyush Anand <pratyush.anand@st.com>
+ * Pratyush Anand <pratyush.anand@gmail.com>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
diff --git a/kernel/drivers/usb/misc/sisusbvga/sisusb.c b/kernel/drivers/usb/misc/sisusbvga/sisusb.c
index 022dc0008..306d6852e 100644
--- a/kernel/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/kernel/drivers/usb/misc/sisusbvga/sisusb.c
@@ -2316,10 +2316,12 @@ sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init)
/* Set mode 0x03 */
SiSUSBSetMode(sisusb->SiS_Pr, 0x03);
- if (!(myfont = find_font("VGA8x16")))
+ myfont = find_font("VGA8x16");
+ if (!myfont)
return 1;
- if (!(tempbuf = vmalloc(8192)))
+ tempbuf = vmalloc(8192);
+ if (!tempbuf)
return 1;
for (i = 0; i < 256; i++)
@@ -2342,7 +2344,8 @@ sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init)
if (init && !sisusb->scrbuf) {
- if ((tempbuf = vmalloc(8192))) {
+ tempbuf = vmalloc(8192);
+ if (tempbuf) {
i = 4096;
tempbufb = (u16 *)tempbuf;
@@ -2417,11 +2420,13 @@ sisusb_open(struct inode *inode, struct file *file)
struct usb_interface *interface;
int subminor = iminor(inode);
- if (!(interface = usb_find_interface(&sisusb_driver, subminor))) {
+ interface = usb_find_interface(&sisusb_driver, subminor);
+ if (!interface) {
return -ENODEV;
}
- if (!(sisusb = usb_get_intfdata(interface))) {
+ sisusb = usb_get_intfdata(interface);
+ if (!sisusb) {
return -ENODEV;
}
@@ -2488,7 +2493,8 @@ sisusb_release(struct inode *inode, struct file *file)
{
struct sisusb_usb_data *sisusb;
- if (!(sisusb = file->private_data))
+ sisusb = file->private_data;
+ if (!sisusb)
return -ENODEV;
mutex_lock(&sisusb->lock);
@@ -2520,7 +2526,8 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
u16 buf16;
u32 buf32, address;
- if (!(sisusb = file->private_data))
+ sisusb = file->private_data;
+ if (!sisusb)
return -ENODEV;
mutex_lock(&sisusb->lock);
@@ -2662,7 +2669,8 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,
u16 buf16;
u32 buf32, address;
- if (!(sisusb = file->private_data))
+ sisusb = file->private_data;
+ if (!sisusb)
return -ENODEV;
mutex_lock(&sisusb->lock);
@@ -2805,7 +2813,8 @@ sisusb_lseek(struct file *file, loff_t offset, int orig)
struct sisusb_usb_data *sisusb;
loff_t ret;
- if (!(sisusb = file->private_data))
+ sisusb = file->private_data;
+ if (!sisusb)
return -ENODEV;
mutex_lock(&sisusb->lock);
@@ -2970,7 +2979,8 @@ sisusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
long retval = 0;
u32 __user *argp = (u32 __user *)arg;
- if (!(sisusb = file->private_data))
+ sisusb = file->private_data;
+ if (!sisusb)
return -ENODEV;
mutex_lock(&sisusb->lock);
@@ -3084,7 +3094,8 @@ static int sisusb_probe(struct usb_interface *intf,
dev->devnum);
/* Allocate memory for our private */
- if (!(sisusb = kzalloc(sizeof(*sisusb), GFP_KERNEL))) {
+ sisusb = kzalloc(sizeof(*sisusb), GFP_KERNEL);
+ if (!sisusb) {
dev_err(&dev->dev, "Failed to allocate memory for private data\n");
return -ENOMEM;
}
@@ -3093,7 +3104,8 @@ static int sisusb_probe(struct usb_interface *intf,
mutex_init(&(sisusb->lock));
/* Register device */
- if ((retval = usb_register_dev(intf, &usb_sisusb_class))) {
+ retval = usb_register_dev(intf, &usb_sisusb_class);
+ if (retval) {
dev_err(&sisusb->sisusb_dev->dev, "Failed to get a minor for device %d\n",
dev->devnum);
retval = -ENODEV;
@@ -3214,7 +3226,8 @@ static void sisusb_disconnect(struct usb_interface *intf)
struct sisusb_usb_data *sisusb;
/* This should *not* happen */
- if (!(sisusb = usb_get_intfdata(intf)))
+ sisusb = usb_get_intfdata(intf);
+ if (!sisusb)
return;
#ifdef INCL_SISUSB_CON
diff --git a/kernel/drivers/usb/misc/sisusbvga/sisusb_con.c b/kernel/drivers/usb/misc/sisusbvga/sisusb_con.c
index a638c4e9a..ace343088 100644
--- a/kernel/drivers/usb/misc/sisusbvga/sisusb_con.c
+++ b/kernel/drivers/usb/misc/sisusbvga/sisusb_con.c
@@ -169,7 +169,8 @@ sisusb_get_sisusb_lock_and_check(unsigned short console)
if (in_atomic())
return NULL;
- if (!(sisusb = sisusb_get_sisusb(console)))
+ sisusb = sisusb_get_sisusb(console);
+ if (!sisusb)
return NULL;
mutex_lock(&sisusb->lock);
@@ -214,7 +215,8 @@ sisusbcon_init(struct vc_data *c, int init)
* are set up/restored.
*/
- if (!(sisusb = sisusb_get_sisusb(c->vc_num)))
+ sisusb = sisusb_get_sisusb(c->vc_num);
+ if (!sisusb)
return;
mutex_lock(&sisusb->lock);
@@ -277,7 +279,8 @@ sisusbcon_deinit(struct vc_data *c)
* and others, ie not under our control.
*/
- if (!(sisusb = sisusb_get_sisusb(c->vc_num)))
+ sisusb = sisusb_get_sisusb(c->vc_num);
+ if (!sisusb)
return;
mutex_lock(&sisusb->lock);
@@ -369,7 +372,8 @@ sisusbcon_putc(struct vc_data *c, int ch, int y, int x)
struct sisusb_usb_data *sisusb;
ssize_t written;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return;
/* sisusb->lock is down */
@@ -395,7 +399,8 @@ sisusbcon_putcs(struct vc_data *c, const unsigned short *s,
u16 *dest;
int i;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return;
/* sisusb->lock is down */
@@ -433,7 +438,8 @@ sisusbcon_clear(struct vc_data *c, int y, int x, int height, int width)
if (width <= 0 || height <= 0)
return;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return;
/* sisusb->lock is down */
@@ -486,7 +492,8 @@ sisusbcon_bmove(struct vc_data *c, int sy, int sx,
if (width <= 0 || height <= 0)
return;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return;
/* sisusb->lock is down */
@@ -520,7 +527,8 @@ sisusbcon_switch(struct vc_data *c)
* Returnvalue != 0 naturally means the opposite.
*/
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return 0;
/* sisusb->lock is down */
@@ -569,7 +577,8 @@ sisusbcon_save_screen(struct vc_data *c)
* buffer.
*/
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return;
/* sisusb->lock is down */
@@ -602,7 +611,8 @@ sisusbcon_set_palette(struct vc_data *c, unsigned char *table)
if (!CON_IS_VISIBLE(c))
return -EINVAL;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return -EINVAL;
/* sisusb->lock is down */
@@ -637,7 +647,8 @@ sisusbcon_blank(struct vc_data *c, int blank, int mode_switch)
ssize_t written;
int ret = 0;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return 0;
/* sisusb->lock is down */
@@ -721,7 +732,8 @@ sisusbcon_scrolldelta(struct vc_data *c, int lines)
/* The return value does not seem to be used */
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return 0;
/* sisusb->lock is down */
@@ -779,7 +791,8 @@ sisusbcon_cursor(struct vc_data *c, int mode)
struct sisusb_usb_data *sisusb;
int from, to, baseline;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return;
/* sisusb->lock is down */
@@ -906,7 +919,8 @@ sisusbcon_scroll(struct vc_data *c, int t, int b, int dir, int lines)
if (!lines)
return 1;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return 0;
/* sisusb->lock is down */
@@ -1018,7 +1032,8 @@ sisusbcon_set_origin(struct vc_data *c)
* screenbuffer as the origin.
*/
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return 0;
/* sisusb->lock is down */
@@ -1047,7 +1062,8 @@ sisusbcon_resize(struct vc_data *c, unsigned int newcols, unsigned int newrows,
struct sisusb_usb_data *sisusb;
int fh;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return -ENODEV;
fh = sisusb->current_font_height;
@@ -1286,7 +1302,8 @@ sisusbcon_font_set(struct vc_data *c, struct console_font *font,
if (font->width != 8 || (charcount != 256 && charcount != 512))
return -EINVAL;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return -ENODEV;
/* sisusb->lock is down */
@@ -1326,7 +1343,8 @@ sisusbcon_font_get(struct vc_data *c, struct console_font *font)
{
struct sisusb_usb_data *sisusb;
- if (!(sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num)))
+ sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
+ if (!sisusb)
return -ENODEV;
/* sisusb->lock is down */
diff --git a/kernel/drivers/usb/misc/usb3503.c b/kernel/drivers/usb/misc/usb3503.c
index 64ff5b917..b45cb77c0 100644
--- a/kernel/drivers/usb/misc/usb3503.c
+++ b/kernel/drivers/usb/misc/usb3503.c
@@ -410,7 +410,7 @@ static int __init usb3503_init(void)
{
int err;
- err = i2c_register_driver(THIS_MODULE, &usb3503_i2c_driver);
+ err = i2c_add_driver(&usb3503_i2c_driver);
if (err != 0)
pr_err("usb3503: Failed to register I2C driver: %d\n", err);
diff --git a/kernel/drivers/usb/misc/usbtest.c b/kernel/drivers/usb/misc/usbtest.c
index 0bbafe795..637f3f7cf 100644
--- a/kernel/drivers/usb/misc/usbtest.c
+++ b/kernel/drivers/usb/misc/usbtest.c
@@ -17,6 +17,7 @@
static int override_alt = -1;
module_param_named(alt, override_alt, int, 0644);
MODULE_PARM_DESC(alt, ">= 0 to override altsetting selection");
+static void complicated_callback(struct urb *urb);
/*-------------------------------------------------------------------------*/
@@ -95,6 +96,7 @@ static struct usb_device *testdev_to_usbdev(struct usbtest_dev *test)
dev_warn(&(tdev)->intf->dev , fmt , ## args)
#define GUARD_BYTE 0xA5
+#define MAX_SGLEN 128
/*-------------------------------------------------------------------------*/
@@ -238,7 +240,8 @@ static struct urb *usbtest_alloc_urb(
unsigned long bytes,
unsigned transfer_flags,
unsigned offset,
- u8 bInterval)
+ u8 bInterval,
+ usb_complete_t complete_fn)
{
struct urb *urb;
@@ -247,10 +250,10 @@ static struct urb *usbtest_alloc_urb(
return urb;
if (bInterval)
- usb_fill_int_urb(urb, udev, pipe, NULL, bytes, simple_callback,
+ usb_fill_int_urb(urb, udev, pipe, NULL, bytes, complete_fn,
NULL, bInterval);
else
- usb_fill_bulk_urb(urb, udev, pipe, NULL, bytes, simple_callback,
+ usb_fill_bulk_urb(urb, udev, pipe, NULL, bytes, complete_fn,
NULL);
urb->interval = (udev->speed == USB_SPEED_HIGH)
@@ -295,7 +298,17 @@ static struct urb *simple_alloc_urb(
u8 bInterval)
{
return usbtest_alloc_urb(udev, pipe, bytes, URB_NO_TRANSFER_DMA_MAP, 0,
- bInterval);
+ bInterval, simple_callback);
+}
+
+static struct urb *complicated_alloc_urb(
+ struct usb_device *udev,
+ int pipe,
+ unsigned long bytes,
+ u8 bInterval)
+{
+ return usbtest_alloc_urb(udev, pipe, bytes, URB_NO_TRANSFER_DMA_MAP, 0,
+ bInterval, complicated_callback);
}
static unsigned pattern;
@@ -303,11 +316,20 @@ static unsigned mod_pattern;
module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)");
-static inline void simple_fill_buf(struct urb *urb)
+static unsigned get_maxpacket(struct usb_device *udev, int pipe)
+{
+ struct usb_host_endpoint *ep;
+
+ ep = usb_pipe_endpoint(udev, pipe);
+ return le16_to_cpup(&ep->desc.wMaxPacketSize);
+}
+
+static void simple_fill_buf(struct urb *urb)
{
unsigned i;
u8 *buf = urb->transfer_buffer;
unsigned len = urb->transfer_buffer_length;
+ unsigned maxpacket;
switch (pattern) {
default:
@@ -316,8 +338,9 @@ static inline void simple_fill_buf(struct urb *urb)
memset(buf, 0, len);
break;
case 1: /* mod63 */
+ maxpacket = get_maxpacket(urb->dev, urb->pipe);
for (i = 0; i < len; i++)
- *buf++ = (u8) (i % 63);
+ *buf++ = (u8) ((i % maxpacket) % 63);
break;
}
}
@@ -349,6 +372,7 @@ static int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb)
u8 expected;
u8 *buf = urb->transfer_buffer;
unsigned len = urb->actual_length;
+ unsigned maxpacket = get_maxpacket(urb->dev, urb->pipe);
int ret = check_guard_bytes(tdev, urb);
if (ret)
@@ -366,7 +390,7 @@ static int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb)
* with set_interface or set_config.
*/
case 1: /* mod63 */
- expected = i % 63;
+ expected = (i % maxpacket) % 63;
break;
/* always fail unsupported patterns */
default:
@@ -478,11 +502,13 @@ static void free_sglist(struct scatterlist *sg, int nents)
}
static struct scatterlist *
-alloc_sglist(int nents, int max, int vary)
+alloc_sglist(int nents, int max, int vary, struct usbtest_dev *dev, int pipe)
{
struct scatterlist *sg;
unsigned i;
unsigned size = max;
+ unsigned maxpacket =
+ get_maxpacket(interface_to_usbdev(dev->intf), pipe);
if (max == 0)
return NULL;
@@ -511,7 +537,7 @@ alloc_sglist(int nents, int max, int vary)
break;
case 1:
for (j = 0; j < size; j++)
- *buf++ = (u8) (j % 63);
+ *buf++ = (u8) ((j % maxpacket) % 63);
break;
}
@@ -1719,7 +1745,7 @@ static int ctrl_out(struct usbtest_dev *dev,
for (i = 0; i < count; i++) {
/* write patterned data */
for (j = 0; j < len; j++)
- buf[j] = i + j;
+ buf[j] = (u8)(i + j);
retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
0x5b, USB_DIR_OUT|USB_TYPE_VENDOR,
0, 0, buf, len, USB_CTRL_SET_TIMEOUT);
@@ -1749,9 +1775,9 @@ static int ctrl_out(struct usbtest_dev *dev,
/* fail if we can't verify */
for (j = 0; j < len; j++) {
- if (buf[j] != (u8) (i + j)) {
+ if (buf[j] != (u8)(i + j)) {
ERROR(dev, "ctrl_out, byte %d is %d not %d\n",
- j, buf[j], (u8) i + j);
+ j, buf[j], (u8)(i + j));
retval = -EBADMSG;
break;
}
@@ -1781,12 +1807,12 @@ static int ctrl_out(struct usbtest_dev *dev,
/*-------------------------------------------------------------------------*/
-/* ISO tests ... mimics common usage
+/* ISO/BULK tests ... mimics common usage
* - buffer length is split into N packets (mostly maxpacket sized)
* - multi-buffers according to sglen
*/
-struct iso_context {
+struct transfer_context {
unsigned count;
unsigned pending;
spinlock_t lock;
@@ -1795,11 +1821,12 @@ struct iso_context {
unsigned long errors;
unsigned long packet_count;
struct usbtest_dev *dev;
+ bool is_iso;
};
-static void iso_callback(struct urb *urb)
+static void complicated_callback(struct urb *urb)
{
- struct iso_context *ctx = urb->context;
+ struct transfer_context *ctx = urb->context;
spin_lock(&ctx->lock);
ctx->count--;
@@ -1808,7 +1835,7 @@ static void iso_callback(struct urb *urb)
if (urb->error_count > 0)
ctx->errors += urb->error_count;
else if (urb->status != 0)
- ctx->errors += urb->number_of_packets;
+ ctx->errors += (ctx->is_iso ? urb->number_of_packets : 1);
else if (urb->actual_length != urb->transfer_buffer_length)
ctx->errors++;
else if (check_guard_bytes(ctx->dev, urb) != 0)
@@ -1895,7 +1922,7 @@ static struct urb *iso_alloc_urb(
urb->iso_frame_desc[i].offset = maxp * i;
}
- urb->complete = iso_callback;
+ urb->complete = complicated_callback;
/* urb->context = SET BY CALLER */
urb->interval = 1 << (desc->bInterval - 1);
urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
@@ -1903,36 +1930,33 @@ static struct urb *iso_alloc_urb(
}
static int
-test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param,
+test_queue(struct usbtest_dev *dev, struct usbtest_param *param,
int pipe, struct usb_endpoint_descriptor *desc, unsigned offset)
{
- struct iso_context context;
+ struct transfer_context context;
struct usb_device *udev;
unsigned i;
unsigned long packets = 0;
int status = 0;
- struct urb *urbs[10]; /* FIXME no limit */
-
- if (param->sglen > 10)
- return -EDOM;
+ struct urb *urbs[param->sglen];
memset(&context, 0, sizeof(context));
context.count = param->iterations * param->sglen;
context.dev = dev;
+ context.is_iso = !!desc;
init_completion(&context.done);
spin_lock_init(&context.lock);
- memset(urbs, 0, sizeof(urbs));
udev = testdev_to_usbdev(dev);
- dev_info(&dev->intf->dev,
- "... iso period %d %sframes, wMaxPacket %04x\n",
- 1 << (desc->bInterval - 1),
- (udev->speed == USB_SPEED_HIGH) ? "micro" : "",
- usb_endpoint_maxp(desc));
for (i = 0; i < param->sglen; i++) {
- urbs[i] = iso_alloc_urb(udev, pipe, desc,
+ if (context.is_iso)
+ urbs[i] = iso_alloc_urb(udev, pipe, desc,
param->length, offset);
+ else
+ urbs[i] = complicated_alloc_urb(udev, pipe,
+ param->length, 0);
+
if (!urbs[i]) {
status = -ENOMEM;
goto fail;
@@ -1941,11 +1965,21 @@ test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param,
urbs[i]->context = &context;
}
packets *= param->iterations;
- dev_info(&dev->intf->dev,
- "... total %lu msec (%lu packets)\n",
- (packets * (1 << (desc->bInterval - 1)))
- / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1),
- packets);
+
+ if (context.is_iso) {
+ dev_info(&dev->intf->dev,
+ "iso period %d %sframes, wMaxPacket %d, transactions: %d\n",
+ 1 << (desc->bInterval - 1),
+ (udev->speed == USB_SPEED_HIGH) ? "micro" : "",
+ usb_endpoint_maxp(desc) & 0x7ff,
+ 1 + (0x3 & (usb_endpoint_maxp(desc) >> 11)));
+
+ dev_info(&dev->intf->dev,
+ "total %lu msec (%lu packets)\n",
+ (packets * (1 << (desc->bInterval - 1)))
+ / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1),
+ packets);
+ }
spin_lock_irq(&context.lock);
for (i = 0; i < param->sglen; i++) {
@@ -1982,7 +2016,8 @@ test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param,
;
else if (context.submit_error)
status = -EACCES;
- else if (context.errors > context.packet_count / 10)
+ else if (context.errors >
+ (context.is_iso ? context.packet_count / 10 : 0))
status = -EIO;
return status;
@@ -2003,8 +2038,8 @@ static int test_unaligned_bulk(
const char *label)
{
int retval;
- struct urb *urb = usbtest_alloc_urb(
- testdev_to_usbdev(tdev), pipe, length, transfer_flags, 1, 0);
+ struct urb *urb = usbtest_alloc_urb(testdev_to_usbdev(tdev),
+ pipe, length, transfer_flags, 1, 0, simple_callback);
if (!urb)
return -ENOMEM;
@@ -2060,6 +2095,9 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
if (param->iterations <= 0)
return -EINVAL;
+ if (param->sglen > MAX_SGLEN)
+ return -EINVAL;
+
if (mutex_lock_interruptible(&dev->lock))
return -ERESTARTSYS;
@@ -2175,7 +2213,8 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
"TEST 5: write %d sglists %d entries of %d bytes\n",
param->iterations,
param->sglen, param->length);
- sg = alloc_sglist(param->sglen, param->length, 0);
+ sg = alloc_sglist(param->sglen, param->length,
+ 0, dev, dev->out_pipe);
if (!sg) {
retval = -ENOMEM;
break;
@@ -2193,7 +2232,8 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
"TEST 6: read %d sglists %d entries of %d bytes\n",
param->iterations,
param->sglen, param->length);
- sg = alloc_sglist(param->sglen, param->length, 0);
+ sg = alloc_sglist(param->sglen, param->length,
+ 0, dev, dev->in_pipe);
if (!sg) {
retval = -ENOMEM;
break;
@@ -2210,7 +2250,8 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
"TEST 7: write/%d %d sglists %d entries 0..%d bytes\n",
param->vary, param->iterations,
param->sglen, param->length);
- sg = alloc_sglist(param->sglen, param->length, param->vary);
+ sg = alloc_sglist(param->sglen, param->length,
+ param->vary, dev, dev->out_pipe);
if (!sg) {
retval = -ENOMEM;
break;
@@ -2227,7 +2268,8 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
"TEST 8: read/%d %d sglists %d entries 0..%d bytes\n",
param->vary, param->iterations,
param->sglen, param->length);
- sg = alloc_sglist(param->sglen, param->length, param->vary);
+ sg = alloc_sglist(param->sglen, param->length,
+ param->vary, dev, dev->in_pipe);
if (!sg) {
retval = -ENOMEM;
break;
@@ -2324,7 +2366,7 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
param->iterations,
param->sglen, param->length);
/* FIRMWARE: iso sink */
- retval = test_iso_queue(dev, param,
+ retval = test_queue(dev, param,
dev->out_iso_pipe, dev->iso_out, 0);
break;
@@ -2337,7 +2379,7 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
param->iterations,
param->sglen, param->length);
/* FIRMWARE: iso source */
- retval = test_iso_queue(dev, param,
+ retval = test_queue(dev, param,
dev->in_iso_pipe, dev->iso_in, 0);
break;
@@ -2418,7 +2460,7 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
"TEST 22: write %d iso odd, %d entries of %d bytes\n",
param->iterations,
param->sglen, param->length);
- retval = test_iso_queue(dev, param,
+ retval = test_queue(dev, param,
dev->out_iso_pipe, dev->iso_out, 1);
break;
@@ -2429,7 +2471,7 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
"TEST 23: read %d iso odd, %d entries of %d bytes\n",
param->iterations,
param->sglen, param->length);
- retval = test_iso_queue(dev, param,
+ retval = test_queue(dev, param,
dev->in_iso_pipe, dev->iso_in, 1);
break;
@@ -2486,6 +2528,25 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
retval = simple_io(dev, urb, param->iterations, 0, 0, "test26");
simple_free_urb(urb);
break;
+ case 27:
+ /* We do performance test, so ignore data compare */
+ if (dev->out_pipe == 0 || param->sglen == 0 || pattern != 0)
+ break;
+ dev_info(&intf->dev,
+ "TEST 27: bulk write %dMbytes\n", (param->iterations *
+ param->sglen * param->length) / (1024 * 1024));
+ retval = test_queue(dev, param,
+ dev->out_pipe, NULL, 0);
+ break;
+ case 28:
+ if (dev->in_pipe == 0 || param->sglen == 0 || pattern != 0)
+ break;
+ dev_info(&intf->dev,
+ "TEST 28: bulk read %dMbytes\n", (param->iterations *
+ param->sglen * param->length) / (1024 * 1024));
+ retval = test_queue(dev, param,
+ dev->in_pipe, NULL, 0);
+ break;
}
do_gettimeofday(&param->duration);
param->duration.tv_sec -= start.tv_sec;
diff --git a/kernel/drivers/usb/misc/uss720.c b/kernel/drivers/usb/misc/uss720.c
index 588d62a73..bbd029c9c 100644
--- a/kernel/drivers/usb/misc/uss720.c
+++ b/kernel/drivers/usb/misc/uss720.c
@@ -714,7 +714,8 @@ static int uss720_probe(struct usb_interface *intf,
/*
* Allocate parport interface
*/
- if (!(priv = kzalloc(sizeof(struct parport_uss720_private), GFP_KERNEL))) {
+ priv = kzalloc(sizeof(struct parport_uss720_private), GFP_KERNEL);
+ if (!priv) {
usb_put_dev(usbdev);
return -ENOMEM;
}
@@ -723,7 +724,8 @@ static int uss720_probe(struct usb_interface *intf,
kref_init(&priv->ref_count);
spin_lock_init(&priv->asynclock);
INIT_LIST_HEAD(&priv->asynclist);
- if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) {
+ pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops);
+ if (!pp) {
printk(KERN_WARNING "uss720: could not register parport\n");
goto probe_abort;
}