History log of /linux-master/drivers/usb/misc/usbtest.c
Revision Date Author Comments
# 0f5aa1b0 05-Oct-2023 Dan Carpenter <dan.carpenter@linaro.org>

usb: usbtest: fix a type promotion bug

The "len" here is sometimes negative error codes from
usb_get_descriptor(), so we don't want to type promote them to unsigned
long.

This bug pre-dates the invention of git.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/506f7935-2cba-41d9-ab5d-ddb6ad6320bd@moroto.mountain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 676cb83b 16-Jul-2022 Jilin Yuan <yuanjilin@cdjrlc.com>

usb/misc: fix repeated words in comments

Delete the redundant word 'with'.

Signed-off-by: Jilin Yuan <yuanjilin@cdjrlc.com>
Link: https://lore.kernel.org/r/20220716134105.44710-1-yuanjilin@cdjrlc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a482766d 16-Jul-2020 Bixuan Cui <cuibixuan@huawei.com>

usb: usbtest: reduce stack usage in test_queue

Fix the warning: [-Werror=-Wframe-larger-than=]

drivers/usb/misc/usbtest.c: In function 'test_queue':
drivers/usb/misc/usbtest.c:2148:1:
warning: the frame size of 1232 bytes is larger than 1024 bytes

Reported-by: kbuild test robot <lkp@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
Link: https://lore.kernel.org/r/ffa85702-86ab-48d7-4da2-2efcc94b05d3@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0d9b6d49 07-Jul-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

usb: Use fallthrough pseudo-keyword

Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20200707195607.GA4198@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 28ebeb8d 11-Jun-2020 Zqiang <qiang.zhang@windriver.com>

usb: usbtest: fix missing kfree(dev->buf) in usbtest_disconnect

BUG: memory leak
unreferenced object 0xffff888055046e00 (size 256):
comm "kworker/2:9", pid 2570, jiffies 4294942129 (age 1095.500s)
hex dump (first 32 bytes):
00 70 04 55 80 88 ff ff 18 bb 5a 81 ff ff ff ff .p.U......Z.....
f5 96 78 81 ff ff ff ff 37 de 8e 81 ff ff ff ff ..x.....7.......
backtrace:
[<00000000d121dccf>] kmemleak_alloc_recursive
include/linux/kmemleak.h:43 [inline]
[<00000000d121dccf>] slab_post_alloc_hook mm/slab.h:586 [inline]
[<00000000d121dccf>] slab_alloc_node mm/slub.c:2786 [inline]
[<00000000d121dccf>] slab_alloc mm/slub.c:2794 [inline]
[<00000000d121dccf>] kmem_cache_alloc_trace+0x15e/0x2d0 mm/slub.c:2811
[<000000005c3c3381>] kmalloc include/linux/slab.h:555 [inline]
[<000000005c3c3381>] usbtest_probe+0x286/0x19d0
drivers/usb/misc/usbtest.c:2790
[<000000001cec6910>] usb_probe_interface+0x2bd/0x870
drivers/usb/core/driver.c:361
[<000000007806c118>] really_probe+0x48d/0x8f0 drivers/base/dd.c:551
[<00000000a3308c3e>] driver_probe_device+0xfc/0x2a0 drivers/base/dd.c:724
[<000000003ef66004>] __device_attach_driver+0x1b6/0x240
drivers/base/dd.c:831
[<00000000eee53e97>] bus_for_each_drv+0x14e/0x1e0 drivers/base/bus.c:431
[<00000000bb0648d0>] __device_attach+0x1f9/0x350 drivers/base/dd.c:897
[<00000000838b324a>] device_initial_probe+0x1a/0x20 drivers/base/dd.c:944
[<0000000030d501c1>] bus_probe_device+0x1e1/0x280 drivers/base/bus.c:491
[<000000005bd7adef>] device_add+0x131d/0x1c40 drivers/base/core.c:2504
[<00000000a0937814>] usb_set_configuration+0xe84/0x1ab0
drivers/usb/core/message.c:2030
[<00000000e3934741>] generic_probe+0x6a/0xe0 drivers/usb/core/generic.c:210
[<0000000098ade0f1>] usb_probe_device+0x90/0xd0
drivers/usb/core/driver.c:266
[<000000007806c118>] really_probe+0x48d/0x8f0 drivers/base/dd.c:551
[<00000000a3308c3e>] driver_probe_device+0xfc/0x2a0 drivers/base/dd.c:724

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Kyungtae Kim <kt0755@gmail.com>
Signed-off-by: Zqiang <qiang.zhang@windriver.com>
Link: https://lore.kernel.org/r/20200612035210.20494-1-qiang.zhang@windriver.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0d1ec194 12-Feb-2019 Peter Chen <peter.chen@nxp.com>

usb: misc: usbtest: add super-speed isoc support

The calculation of packet number within microframe is different between
high-speed and super-speed endpoint, we add support for super-speed
in this patch.

Cc: Pawel Laszczak <pawell@cadence.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# ee9a4ae7 01-Jul-2018 Sebastian Andrzej Siewior <bigeasy@linutronix.de>

usb: usbtest: use irqsave() in USB's complete callback

The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 6f3fde68 01-Jul-2018 Sebastian Andrzej Siewior <bigeasy@linutronix.de>

usb: usbtest: use irqsave() in USB's complete callback

The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c53439fb 08-Mar-2018 Tobin C. Harding <me@tobin.cc>

usb: usbtest: Remove stack VLA usage

The kernel would like to have all stack VLA usage removed[1]. We
already have a pre-processor constant defined MAX_SGLEN. We can use
this instead of the variable param-sglen.

[1]: https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# cc2e60df 15-Dec-2017 Mathias Nyman <mathias.nyman@linux.intel.com>

usb: usbtest: Add TEST 29, toggle sync, Clear toggle between bulk writes

Clear Feature Endpoint Halt should reset the data toggle even if the
endpoint isn't halted. Host should manage to clear the host side data
toggle to keep in sync with the device.

Test by sending a "3 data packet URB" before and after clearing the halt.
this should create a toggle sequence with two consecutive DATA0 packets.

A successful test sequence looks like this
ClearFeature(ENDPOINT_HALT) - initial toggle clear
DATA0 (max packet sized)
DATA1 (max packet sized)
DATA0 (zero length packet)
ClearFeature(ENDPOINT_HALT) - resets toggle
DATA0 (max packet sized), if clear halt fails then toggle is DATA1
DATA1 (max packet sized)
DATA0 (zero length packet)

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d9e1e148 02-Nov-2017 Felipe Balbi <felipe.balbi@linux.intel.com>

usb: core: introduce a new usb_get_std_status() helper

This new helper is a simple wrapper around usb_get_status(). This
patch is in preparation to adding support for fetching PTM_STATUS
types. No functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5fd54ace 03-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: add SPDX identifiers to all remaining files in drivers/usb/

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/usb/ and include/linux/usb* files with the correct
SPDX license identifier based on the license text in the file itself.
The SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7d221856 22-Oct-2017 Kees Cook <keescook@chromium.org>

usb: usbtest: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. Also adds missing call to
destroy_timer_on_stack();

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9f8e32df 20-Oct-2017 Jaejoong Kim <climbbb.kim@gmail.com>

usb: misc: usbtest: remove duplicate & operation

usb_endpoint_maxp() has an inline keyword and searches for bits[10:0]
by & operation with 0x7ff. So, we can remove the duplicate & operation
with 0x7ff.

Signed-off-by: Jaejoong Kim <climbbb.kim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1c236d41 20-Oct-2017 Jaejoong Kim <climbbb.kim@gmail.com>

usb: misc: usbtest: remove duplicate & operation

usb_endpoint_maxp() has an inline keyword and searches for bits[10:0]
by & operation with 0x7ff. So, we can remove the duplicate & operation
with 0x7ff.

Signed-off-by: Jaejoong Kim <climbbb.kim@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 7c80f9e4 29-Sep-2017 Alan Stern <stern@rowland.harvard.edu>

usb: usbtest: fix NULL pointer dereference

If the usbtest driver encounters a device with an IN bulk endpoint but
no OUT bulk endpoint, it will try to dereference a NULL pointer
(out->desc.bEndpointAddress). The problem can be solved by adding a
missing test.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# cb84f568 30-Sep-2017 Dan Carpenter <dan.carpenter@oracle.com>

usb: misc: usbtest: Fix overflow in usbtest_do_ioctl()

There used to be a test against "if (param->sglen > MAX_SGLEN)" but it
was removed during a refactor. It leads to an integer overflow and a
stack overflow in test_queue() if we try to create a too large urbs[]
array on the stack.

There is a second integer overflow in test_queue() as well if
"param->iterations" is too high. I don't immediately see that it's
harmful but I've added a check to prevent it and silence the static
checker warning.

Fixes: 18fc4ebdc705 ("usb: misc: usbtest: Remove timeval usage")
Acked-by: Deepa Dinamani <deepa.kernel@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 65c7843c 03-Apr-2017 Gustavo A. R. Silva <garsilva@embeddedor.com>

usb: misc: refactor code

Code refactoring to make the flow easier to follow.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2c930e3d 03-Apr-2017 Gustavo A. R. Silva <garsilva@embeddedor.com>

usb: misc: add missing continue in switch

Add missing continue in switch.

Addresses-Coverity-ID: 1248733
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ef5ec7f0 12-Feb-2017 Colin Ian King <colin.king@canonical.com>

usb: misc: usbtest: remove redundant check on retval < 0

The check for retval being less than zero is always true since
retval equal to -EPIPE at that point. Replace the existing
conditional with just return retval.

Detected with CoverityScan, CID#114349 ("Logically dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# efdd17e6 28-Sep-2016 Felipe Balbi <felipe.balbi@linux.intel.com>

usb: misc: usbtest: remove unnecessary & operation

Now that usb_endpoint_maxp() only returns the lowest
11 bits from wMaxPacketSize, we can remove the &
operation from this driver.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 131e19b9 28-Sep-2016 Felipe Balbi <felipe.balbi@linux.intel.com>

usb: misc: usbtest: make use of new usb_endpoint_maxp_mult()

We have introduced a helper to calculate multiplier
value from wMaxPacketSize. Start using it.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 53958751 10-Aug-2016 Lu Baolu <baolu.lu@linux.intel.com>

usb: misc: usbtest: add fix for driver hang

In sg_timeout(), req->status is set to "-ETIMEDOUT" before calling
into usb_sg_cancel(). usb_sg_cancel() will do nothing and return
directly if req->status has been set to a non-zero value. This will
cause driver hang whenever transfer time out is triggered.

This patch fixes this issue. It could be backported to stable kernel
with version later than v3.15.

Cc: stable@vger.kernel.org # 3.15+
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 528d2813 26-Jul-2016 Peter Chen <peter.chen@nxp.com>

usb: misc: usbtest: usbtest_do_ioctl may return positive integer

For case 14 and case 21, their correct return value is the number
of bytes transferred, so it is a positive integer. But in usbtest_ioctl,
it takes non-zero as false return value for usbtest_do_ioctl, so
it will treat the correct test as wrong test, then the time on
tests will be the minus value.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Cc: stable <stable@vger.kernel.org>
Fixes: 18fc4ebdc705 ("usb: misc: usbtest: Remove timeval usage")
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>


# 28324936 26-Jul-2016 Peter Chen <peter.chen@nxp.com>

usb: misc: usbtest: usbtest_do_ioctl may return positive integer

For case 14 and case 21, their correct return value is the number
of bytes transferred, so it is a positive integer. But in usbtest_ioctl,
it takes non-zero as false return value for usbtest_do_ioctl, so
it will treat the correct test as wrong test, then the time on
tests will be the minus value.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Cc: stable <stable@vger.kernel.org>
Fixes: 18fc4ebdc705 ("usb: misc: usbtest: Remove timeval usage")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# cdc77c82 02-May-2016 Mathias Nyman <mathias.nyman@linux.intel.com>

usb: misc: usbtest: fix pattern tests for scatterlists.

The current implemenentation restart the sent pattern for each entry in
the sg list. The receiving end expects a continuous pattern, and test
will fail unless scatterilst entries happen to be aligned with the
pattern

Fix this by calculating the pattern byte based on total sent size
instead of just the current sg entry.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Fixes: 8b5249019352 ("[PATCH] USB: usbtest: scatterlist OUT data pattern testing")
Cc: <stable@vger.kernel.org> # v2.6.18+
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 26186e5f 27-Apr-2016 Chunfeng Yun <chunfeng.yun@mediatek.com>

usb: misc: usbtest: fix error of urb allocation

urb allocation will fail when usbtest_alloc_urb() tries to
allocate zero length buffer, but it doesn't need it in fact,
so just skips buffer allocation in the case.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 75f5c434 04-Nov-2015 Deepa Dinamani <deepa.kernel@gmail.com>

usb: misc: usbtest: Remove timeval usage

timeval is deprecated and not y2038 safe. Its size also changes according
to 32 bit/ 64 bit compilation. Replace it with 32 and 64 bit versions of
its individual fields, giving two ioctls with different code values.
The two ioctls are necessary to maintain the 32 bit and 64 bit userspace
compatibility with a 64/32 bit kernel.

Change unsigned to __u32 types for a definitive userspace interface.
This is in accordance with the psABI that the unsigned type is always
32 bits.

Also use motonic timer instead of real time to ensure positive delta
values.

Refactor usbtest_ioctl for readability to isolate the handling of the
testing timing measurement.

The official testusb userspace tool can be changed in a separate patch
to reflect the __u32 changes as well. It can use the usbtest_param_32
struct, since 32 bit seconds is long enough for test durations.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 4cee4fa5 18-Nov-2015 Peter Chen <peter.chen@freescale.com>

usb: misc: usbtest: improve the description for error message

Now the function of complicated_callback is not only used for iso
transfer, improve the error message to reflect it.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 18fc4ebd 04-Nov-2015 Deepa Dinamani <deepa.kernel@gmail.com>

usb: misc: usbtest: Remove timeval usage

timeval is deprecated and not y2038 safe. Its size also changes according
to 32 bit/ 64 bit compilation. Replace it with 32 and 64 bit versions of
its individual fields, giving two ioctls with different code values.
The two ioctls are necessary to maintain the 32 bit and 64 bit userspace
compatibility with a 64/32 bit kernel.

Change unsigned to __u32 types for a definitive userspace interface.
This is in accordance with the psABI that the unsigned type is always
32 bits.

Also use motonic timer instead of real time to ensure positive delta
values.

Refactor usbtest_ioctl for readability to isolate the handling of the
testing timing measurement.

The official testusb userspace tool can be changed in a separate patch
to reflect the __u32 changes as well. It can use the usbtest_param_32
struct, since 32 bit seconds is long enough for test durations.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c7c78067 18-Nov-2015 Peter Chen <peter.chen@freescale.com>

usb: misc: usbtest: improve the description for error message

Now the function of complicated_callback is not only used for iso
transfer, improve the error message to reflect it.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 145f48c5 13-Oct-2015 Peter Chen <peter.chen@freescale.com>

usb: misc: usbtest: add bulk queue test

The bulk queue tests are used to show 'best performance' for bulk
transfer, we are often asked this question by users. The implementation
is the same with iso test, that is queue request at interrupt completion,
so we reuse the iso structures, and rename them as common one.

It's result should be very close to IC simulation, in order
to get that, the device side should also need to prepare enough
queue.

We have got the 'best performance' (IN: 41MB, OUT: 39MB) at i.mx platform
(USB2, ARM Cortex A9, stream mode need to enable) with below command:

Host side:
modprobe usbtest
./testusb -a -t 27 -g 64 -s 16384
./testusb -a -t 28 -g 64 -s 16384
Gadget side:
modprobe g_zero loopdefault=1 qlen=64 buflen=16384

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# b9a6e8e1 31-Aug-2015 Alan Stern <stern@rowland.harvard.edu>

usb: misc: usbtest: format the data pattern according to max packet size

With this change, the host and gadget doesn't need to agree with transfer
length for comparing the data, since they doesn't know each other's
transfer size, but know max packet size.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
(Fixed the 'line over 80 characters warning' by Peter Chen)
Tested-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 169900f9 31-Aug-2015 Peter Chen <peter.chen@freescale.com>

usb: misc: usbtest: using the same data format among write/compare/output

Using the same data format "buf[j] = (u8)(i + j)" among
write, compare buf, and console output stage.

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# a724ddfb 31-Aug-2015 Peter Chen <peter.chen@freescale.com>

usb: misc: usbtest: delete useless memset for urbs array

The element of urbs array will be initialized at below code
at once.

for (i = 0; i < param->sglen; i++) {
urbs[i] = iso_alloc_urb(udev, pipe, desc,
param->length, offset);

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 41d3c0b8 31-Aug-2015 Peter Chen <peter.chen@freescale.com>

usb: misc: usbtest: allocate size of urb array according to user parameter

Allocate the size of urb pointer array according to testusb's
parameter sglen, and limits the length of sglen as MAX_SGLEN
(128 currently).

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# a0c9d0de 17-Aug-2015 Peter Chen <peter.chen@freescale.com>

usb: misc: usbtest: format max packet size for iso transfer

The current code prints all wMaxPacketSize content at endpoint
descriptor, if there is a high speed, high bandwidth endpoint,
it may confuse the users, eg, if there are 3 transactions during
microframe, it will print "wMaxPacket 1400" for packet content.
This commit splits wMaxpacketSize and transaction numbers for
output messages.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 37ebb549 19-Sep-2014 Petr Mladek <pmladek@suse.cz>

usb: hub: rename khubd to hub_wq in documentation and comments

USB hub has started to use a workqueue instead of kthread. Let's update
the documentation and comments here and there.

This patch mostly just replaces "khubd" with "hub_wq". There are only few
exceptions where the whole sentence was updated. These more complicated
changes can be found in the following files:

Documentation/usb/hotplug.txt
drivers/net/usb/usbnet.c
drivers/usb/core/hcd.c
drivers/usb/host/ohci-hcd.c
drivers/usb/host/xhci.c

Signed-off-by: Petr Mladek <pmladek@suse.cz>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 457a0955 22-Aug-2014 Amit Virdi <amit.virdi@st.com>

usbtest: Add interrupt EP testcases

Two simple test cases for interrupt endpoints are added to the usbtest.c file.
These are simple non-queued interrupt IN and interrupt OUT transfers. Currently,
only gadget zero is capable of executing the interrupt EP test cases. However,
extending the same to other gadgets is extremely simple and can be done
on-demand.

The two new tests added are
- Test 25: To verify Interrupt OUT transfer
- Test 26: To verify Interrupt IN transfer

Since the default value of wMaxPacketSize is set as 1024, so interrupt
IN transfers must be specified with the size parameter = multiple of
1024. Otherwise the default value (512) in the usbtest application fails
the transfer. See [RUN 4] for sample logs

The application logs (usbtest) and corresponding kernel logs are as
following:

[Run 1]
./testusb -a -c 10 -s 2048 -t 26 -v 511
usbtest 7-1:3.0: TEST 26: read 2048 bytes 10 times

[Run 2]
./testusb -a -c 10 -s 1024 -t 25 -v 511
usbtest 7-1:3.0: TEST 25: write 1024 bytes 10 times

[Run 3]
./testusb -a -c 10 -s 1098 -t 25 -v 511
usbtest 7-1:3.0: TEST 25: write 1098 bytes 10 times

[Run 4 - Failure case scenario]
./testusb -a -t 26
unknown speed /dev/bus/usb/007/004 0
/dev/bus/usb/007/004 test 26 --> 75 (Value too large for defined data type)

usbtest 7-1:3.0: TEST 26: read 512 bytes 1000 times
usb 7-1: test26 failed, iterations left 999, status -75 (not 0)

Signed-off-by: Amit Virdi <amit.virdi@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 32b36eea 03-Jun-2014 Alan Stern <stern@rowland.harvard.edu>

USB: usbtest: add a timeout for scatter-gather tests

In usbtest, tests 5 - 8 use the scatter-gather library in usbcore
without any sort of timeout. If there's a problem in the gadget or
host controller being tested, the test can hang.

This patch adds a 10-second timeout to the tests, so that they will
fail gracefully with an ETIMEDOUT error instead of hanging.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Huang Rui <ray.huang@amd.com>
Tested-by: Huang Rui <ray.huang@amd.com>
CC: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a7683eb3 22-May-2014 Huang Rui <ray.huang@amd.com>

usb: usbtest: add pattern check on pipe in phase of unlink read

TEST 11 unlinks the URB read request for N times. When host and gadget
both initialize pattern 1 (mod 63) data series to do IN transfer, the
host side function should check the data buffer if it is as mod 63
series, because the data packet which host receivced will follow
pattern 1. So this patch adds this checking action.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e4d58f5d 25-May-2014 Huang Rui <ray.huang@amd.com>

usb: usbtest: fix unlink write error with pattern 1

TEST 12 and TEST 24 unlinks the URB write request for N times. When
host and gadget both initialize pattern 1 (mod 63) data series to
transfer, the gadget side will complain the wrong data which is not
expected. Because in host side, usbtest doesn't fill the data buffer
as mod 63 and this patch fixed it.

[20285.488974] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Not Ready
[20285.489181] dwc3 dwc3.0.auto: ep1out-bulk: reason Transfer Not Active
[20285.489423] dwc3 dwc3.0.auto: ep1out-bulk: req ffff8800aa6cb480 dma aeb50800 length 512 last
[20285.489727] dwc3 dwc3.0.auto: ep1out-bulk: cmd 'Start Transfer' params 00000000 a9eaf000 00000000
[20285.490055] dwc3 dwc3.0.auto: Command Complete --> 0
[20285.490281] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Not Ready
[20285.490492] dwc3 dwc3.0.auto: ep1out-bulk: reason Transfer Active
[20285.490713] dwc3 dwc3.0.auto: ep1out-bulk: endpoint busy
[20285.490909] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Complete
[20285.491117] dwc3 dwc3.0.auto: request ffff8800aa6cb480 from ep1out-bulk completed 512/512 ===> 0
[20285.491431] zero gadget: bad OUT byte, buf[1] = 0
[20285.491605] dwc3 dwc3.0.auto: ep1out-bulk: cmd 'Set Stall' params 00000000 00000000 00000000
[20285.491915] dwc3 dwc3.0.auto: Command Complete --> 0
[20285.492099] dwc3 dwc3.0.auto: queing request ffff8800aa6cb480 to ep1out-bulk length 512
[20285.492387] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Not Ready
[20285.492595] dwc3 dwc3.0.auto: ep1out-bulk: reason Transfer Not Active
[20285.492830] dwc3 dwc3.0.auto: ep1out-bulk: req ffff8800aa6cb480 dma aeb51000 length 512 last
[20285.493135] dwc3 dwc3.0.auto: ep1out-bulk: cmd 'Start Transfer' params 00000000 a9eaf000 00000000
[20285.493465] dwc3 dwc3.0.auto: Command Complete --> 0

Cc: <stable@vger.kernel.org>
Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 824d752b 18-Dec-2013 Roger Quadros <rogerq@ti.com>

usb: usbtest: Always clear halt else further tests will fail

In test_halt() we set an endpoint halt condition and return on halt verification
failure, then the enpoint will remain halted and all further tests related
to that enpoint will fail. This is because we don't tackle endpoint halt error condition
in any of the tests. To avoid that situation, make sure to clear the
halt condition before exiting test_halt().

Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e5e47465 18-Dec-2013 Roger Quadros <rogerq@ti.com>

usb: usbtest: Add timetout to simple_io()

Without a timetout some tests e.g. test_halt() can remain stuck forever.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8cf43285 13-Dec-2013 Sarah Sharp <sarah.a.sharp@linux.intel.com>

usbtest: Fix BOS control test for USB 2.01 devices.

Commit c952a8ba7136505cd1ca01735cc748ddc08c7d2f "usb: usbtest: add a
test case to support bos for queue control" will cause USB 2.01 and USB
2.10 devices with a BOS descriptor to fail case 15 of the control test.

The Link PM errata (released in 2007, updated in 2011) says:

"The value of the bcdUSB field in the standard USB 2.0 Device Descriptor
is used to indicate that the device supports the request to read the BOS
Descriptor (i.e. GetDescriptor(BOS)). Devices that support the BOS
descriptor must have a bcdUSB value of 0201H or larger."

The current code says that non-SuperSpeed devices *must* return -EPIPE,
as this comment shows:

/* sign of this variable means:
* -: tested code must return this (negative) error code
* +: tested code may return this (negative too) error code
*/
int expected = 0;

This means the test will fail with USB 2.01 and USB 2.10 devices that
provide a BOS descriptor. Change it to only require a stall response if
the USB device bcdUSB is less than 2.01.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Acked-by: Huang Rui <ray.huang@amd.com>


# f625099f 13-Nov-2013 Huang Rui <ray.huang@amd.com>

usb: usbtest: update bos test coverage to usb 2.1 device

The commit "usb: usbtest: support bos descriptor test for usb 3.0"
introduced a test for bos descriptor. And USB 2.1 device also can be
checked. So this patch extends the test coverage to support USB 2.1 device.

Reported-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 875bc23a 13-Nov-2013 Huang Rui <ray.huang@amd.com>

usb: usbtest: fix the bit mask of usb 2.0 extension descriptor

USB 2.1 Link PM adds to use bits[1:15] according to USB 2.0 ECN Errata for
Link Power Management spec.

Bit Encoding
0 Reserved
1 LPM
2 BESL & Altemate HIRD definitions supported
3 Recommended Baseline BESL valid
4 Recommended Deep BESL valid
11:8 Recommended Baseline BESL value
15:12 Recommended Deep BESL value
31:16 Reserved

So fix the bit mask from 0x1e to 0xfffe.

Reported-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c952a8ba 04-Nov-2013 Huang Rui <ray.huang@amd.com>

usb: usbtest: add a test case to support bos for queue control

In Test 10 of usbtest module, it queues multiple control messages and
thereby tests control message queuing, protocol stalls, short reads, and
fault handling. And this patch add a test case to support queue BOS control
request for USB 3.0 SPEC.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8e29217f 29-Oct-2013 Huang Rui <ray.huang@amd.com>

usb: usbtest: support container id descriptor test

In Test 9 of usbtest module, it is used for performing chapter 9 tests N
times.

Container ID descriptor is one of the generic device-level capbility
descriptors which added in section 9.6.2.3 of USB 3.0 spec.

This patch adds to support getting Container ID descriptor test scenario
for USB 3.0.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b8fef795 29-Oct-2013 Huang Rui <ray.huang@amd.com>

usb: usbtest: support superspeed device capbility descriptor test

In Test 9 of usbtest module, it is used for performing chapter 9 tests N
times.

SuperSpeed USB Device Capability descriptor is one of the generic
device-level capbility descriptors which added in section 9.6.2.2 of USB
3.0 spec.

This patch adds to support getting SuperSpeed USB Device Capability
descriptor test scenario for USB 3.0.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 82f92672 29-Oct-2013 Huang Rui <ray.huang@amd.com>

usb: usbtest: support usb2 extension descriptor test

In Test 9 of usbtest module, it is used for performing chapter 9 tests N
times.

USB2.0 Extension descriptor is one of the generic device-level capbility
descriptors which added in section 9.6.2.1 of USB 3.0 spec.

This patch adds to support getting usb2.0 extension descriptor test
scenario for USB 3.0.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9d3bd768 28-Oct-2013 Huang Rui <ray.huang@amd.com>

usb: usbtest: support bos descriptor test for usb 3.0

In Test 9 of usbtest module, it is used for performing chapter 9 tests N
times. This patch adds to support getting bos descriptor test scenario for
USB 3.0.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f55055b4 21-Oct-2013 Huang Rui <ray.huang@amd.com>

usb: usbtest: fix checkpatch warning as sizeof code style

Script checkpatch.pl always complains incorrect code style like below:

WARNING: sizeof *udev->bos->desc should be sizeof(*udev->bos->desc)

This patch fixes the warning for usbtest module.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 77a3a0aa 23-Sep-2013 Huang Rui <ray.huang@amd.com>

usb: usbtest: bmAttributes would better be masked

When transfer type is isochronous, the other bits (bits 5..2) of
bmAttributes in endpoint descriptor might not be set zero. So it's better
to use usb_endpoint_type routine to mask bmAttributes with
USB_ENDPOINT_XFERTYPE_MASK to judge the transfter type later.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 9a37a503 23-Sep-2013 Huang Rui <ray.huang@amd.com>

usb: usbtest: bmAttributes would better be masked

When transfer type is isochronous, the other bits (bits 5..2) of
bmAttributes in endpoint descriptor might not be set zero. So it's better
to use usb_endpoint_type routine to mask bmAttributes with
USB_ENDPOINT_XFERTYPE_MASK to judge the transfter type later.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 15b7336e 30-Jul-2013 Alan Stern <stern@rowland.harvard.edu>

USB: simplify the interface of usb_get_status()

This patch simplifies the interface presented by usb_get_status().
Instead of forcing callers to check for the proper data length and
convert the status value to host byte order, the function will now
do these things itself.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d0b4652f 30-Jan-2013 Alan Stern <stern@rowland.harvard.edu>

USB: altsetting overrides for usbtest

The usbtest driver includes some rather simple-minded logic for
selecting an altsetting to test. It doesn't work well for the g_zero
gadget, because it selects altsetting 0 (which doesn't have
isochronous endpoints) rather than altsetting 1 (which does have them,
if the gadget's hardware supports them). This prevents usbtest's
isochronous tests (15, 16, 22, and 23) from working with g_zero.

Since g_zero is one of the most common gadget drivers used for USB
testing, usbtest should do a better job of supporting it. But since
some programs may rely on the current scheme for selecting
altsettings, I didn't want to change it.

Instead, this patch (as1655) adds a module parameter to usbtest, which
can be used to override the default altsetting. Since usbtest is
never used by normal users (most distributions probably don't even
build it), the new module parameter won't inconvenience anybody. In
any case, it is entirely optional -- leaving it unset preserves the
existing behavior.

The patch also fixes a related bug in usbtest: After selecting an
altsetting, the driver neglects to store its selection.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2cb50000 02-Jan-2013 Alan Stern <stern@rowland.harvard.edu>

USB: usbtest: fix test number in log message

This patch (as1639) fixes a minor bug in the usbtest driver. Due to
concurrent changes, a test originally written as number 17 got changed
to number 24, but the corresponding change was not made in the log
message. This updates the log message.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 564e6989 17-Nov-2012 Dan Carpenter <dan.carpenter@oracle.com>

USB: usbtest: prevent a divide by zero bug

If param->length is zero, then this could lead to a divide by zero bug
later in the function when we do: size %= max;

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4b85c624 12-Nov-2012 Boyan Nedeltchev <boyan@ti.com>

usb: misc: usbtest: send ISO packets for g_zero

since commit b4036cc (usb: gadget: add
isochronous support to gadget zero), g_zero
has learned about isochronous transfers, which
allows us to use usbtest.ko to exercise
isochronous pipes.

All we need to do to enable that functionality
on usbtest.ko, is set the "iso" to 1 on
struct usbtest_info

Signed-off-by: Boyan Nedeltchev <boyan@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6a23ccd2 16-Apr-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com>

usb: usbtest: two super speed fixes for usbtest

bMaxPacketSize0 field for super speed is a power of 2, not a count.
The size itself is always 512.

Max packet size for a super speed bulk endpoint is 1024, so
allocate the urb size in halt_simple() accordingly.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f4a728d0 25-Mar-2012 Julia Lawall <Julia.Lawall@lip6.fr>

drivers/usb/misc/usbtest.c: add kfrees

Free the two previously allocated buffers before exiting the function in an
error case.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8bde9a62 09-Apr-2012 Xi Wang <xi.wang@gmail.com>

usb: usbtest: avoid integer overflow in alloc_sglist()

A large `nents' from userspace could overflow the allocation size,
leading to memory corruption.

| alloc_sglist()
| usbtest_ioctl()

Use kmalloc_array() to avoid the overflow.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e65cdfae 09-Apr-2012 Xi Wang <xi.wang@gmail.com>

usb: usbtest: avoid integer overflow in test_ctrl_queue()

Avoid overflowing context.count = param->sglen * param->iterations,
where both `sglen' and `iterations' are from userspace.

| test_ctrl_queue()
| usbtest_ioctl()

Keep -EOPNOTSUPP for error code.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 56898711 24-Nov-2011 Davidlohr Bueso <dave@gnu.org>

USB: remove BKL comments

The BKL is a gonner.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# e538dfda 30-Aug-2011 Michal Nazarewicz <mina86@mina86.com>

usb: Provide usb_speed_string() function

In a few places in the kernel, the code prints
a human-readable USB device speed (eg. "high speed").
This involves a switch statement sometimes wrapped
around in ({ ... }) block leading to code repetition.

To mitigate this issue, this commit introduces
usb_speed_string() function, which returns
a human-readable name of provided speed.

It also changes a few places switch was used to use
this new function. This changes a bit the way the
speed is printed in few instances at the same time
standardising it.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 29cc8897 23-Aug-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

USB: use usb_endpoint_maxp() instead of le16_to_cpu()

Now ${LINUX}/drivers/usb/* can use usb_endpoint_maxp(desc) to get maximum packet size
instead of le16_to_cpu(desc->wMaxPacketSize).
This patch fix it up

Cc: Armin Fuerst <fuerst@in.tum.de>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Johannes Erdfelt <johannes@erdfelt.com>
Cc: Vojtech Pavlik <vojtech@suse.cz>
Cc: Oliver Neukum <oliver@neukum.name>
Cc: David Kubicek <dave@awk.cz>
Cc: Johan Hovold <jhovold@gmail.com>
Cc: Brad Hards <bhards@bigpond.net.au>
Acked-by: Felipe Balbi <balbi@ti.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Dahlmann <dahlmann.thomas@arcor.de>
Cc: David Brownell <david-b@pacbell.net>
Cc: David Lopo <dlopo@chipidea.mips.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: Xie Xiaobo <X.Xie@freescale.com>
Cc: Li Yang <leoli@freescale.com>
Cc: Jiang Bo <tanya.jiang@freescale.com>
Cc: Yuan-hsin Chen <yhchen@faraday-tech.com>
Cc: Darius Augulis <augulis.darius@gmail.com>
Cc: Xiaochen Shen <xiaochen.shen@intel.com>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: OKI SEMICONDUCTOR, <toshiharu-linux@dsn.okisemi.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Ben Dooks <ben@simtec.co.uk>
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Herbert Pötzl <herbert@13thfloor.at>
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Roman Weissgaerber <weissg@vienna.at>
Acked-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Tony Olech <tony.olech@elandigitalsystems.com>
Cc: Florian Floe Echtler <echtler@fs.tum.de>
Cc: Christian Lucht <lucht@codemercs.com>
Cc: Juergen Stuber <starblue@sourceforge.net>
Cc: Georges Toth <g.toth@e-biz.lu>
Cc: Bill Ryder <bryder@sgi.com>
Cc: Kuba Ober <kuba@mareimbrium.org>
Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 7c79d094 23-Aug-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>

USB: usbtest: use URB_ZERO_PACKET for BULK-OUT transfers

Executing
| testusb -a -c 1 -t 3 -v 421 -s 2048

does not complete on the gadget side.
g_zero enqueues a 4096 bytes long buffer. The host sends 2048bytes which
is a multiple of wMaxPacketSize (either 64 or 512 bytes). The host is
done with sending data but the gadget waits for more.
Since the protocol does not include transfer-length-field sending a
terminating zero packet seems the only way out.

Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 304b0b57 08-May-2011 Greg Dietsche <Gregory.Dietsche@cuw.edu>

usb: fix warning in usbtest module v2

On amd64 unsigned is not as wide as pointer and this causes a compiler
warning. Switching to unsigned long corrects the problem.

Signed-off-by: Greg Dietsche <Gregory.Dietsche@cuw.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 70f23fd6 10-May-2011 Justin P. Mattock <justinmattock@gmail.com>

treewide: fix a few typos in comments

- kenrel -> kernel
- whetehr -> whether
- ttt -> tt
- sss -> ss

Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 67e7d64b 14-Apr-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>

usb/usbtest: fix test10 on superpseed

dummy_hcd + g_zero:

|./testusb -a -s 1024 -v 1024 -t 10
| usbtest 2-1:3.0: subtest 14 error, status 0

with patch:
./testusb -a -t 10
|unknown speed /proc/bus/usb/001/002
| dummy_udc dummy_udc: disabled ep-a
| dummy_udc dummy_udc: disabled ep-b
| dummy_udc dummy_udc: enabled ep-a (ep1in-bulk) maxpacket 1024
| dummy_udc dummy_udc: enabled ep-b (ep2out-bulk) maxpacket 1024
| zero gadget: source/sink enabled
| usbtest 1-1:3.0: TEST 10: queue 32 control calls, 1000 times
| dummy_hcd dummy_hcd: timer fired with no URBs pending?
|/proc/bus/usb/001/002 test 10, 0.022370 secs

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 14b76ed9 14-Apr-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>

usb/usbtest: print super on super speed

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 869410f8 14-Apr-2011 Alan Stern <stern@rowland.harvard.edu>

USB: add queued-unlinks test case to usbtest driver

This patch (as1452b) adds a new test case to the usbtest driver. Test
24 exercises the unlink-from-queue pathways in the host. It queues a
user-specified number of bulk-OUT URBs of user-specified size, unlinks
the fourth- and second-from-last URBs in the queue, and then waits to
see if all the URBs complete in the expected way (except of course
that the unlinked URBs might complete normally, if they weren't
unlinked soon enough).

This new test has confirmed the existence of a bug in the ehci-hcd
driver, to be fixed by a separate patch.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 084fb206 16-Jan-2011 Martin Fuzzey <mfuzzey@gmail.com>

USB: usbtest - Add tests to ensure HCDs can accept byte aligned buffers.

Add a set of new tests similar to the existing ones but using
transfer buffers at an "odd" address [ie offset of +1 from
the buffer obtained by kmalloc() or usb_alloc_coherent()]

The new tests are:
#17 : bulk out (like #1) using kmalloc and DMA mapping by USB core.
#18 : bulk in (like #2) using kmalloc and DMA mapping by USB core.
#19 : bulk out (like #1) using usb_alloc_coherent()
#20 : bulk in (like #2) using usb_alloc_coherent()
#21 : control write (like #14)
#22 : isochonous out (like #15)
#23 : isochonous in (like #16)

Signed-off-by: Martin Fuzzey <mfuzzey@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 40aed524 30-Sep-2010 Martin Fuzzey <mfuzzey@gmail.com>

USB: usbtest - ensure correct isoc data length

Check the data length of isochronous transfers is
as expected.

With this test #16 will now fail if the device side
sends no data.

Signed-off-by: Martin Fuzzey <mfuzzey@gmail.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# fabbf219 30-Sep-2010 Martin Fuzzey <mfuzzey@gmail.com>

USB: usbtest fix coding style

Signed-off-by: Martin Fuzzey <mfuzzey@gmail.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 951fd8ee 02-Aug-2010 Ming Lei <tom.leiming@gmail.com>

USB: usbtest: support test device with only one iso-in or iso-out endpoint

It is very common that one altsetting may include only one iso-in or iso-out
single endpoint, especially for high bandwidth endpoint, so support it.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# e10e1bec 02-Aug-2010 Ming Lei <tom.leiming@gmail.com>

USB: usbtest: avoid to free coherent buffer in atomic context

This patch fixes the warning below:
[30753.755998] ------------[ cut here ]------------
[30753.755998] WARNING: at /home/tom/git/linux-2.6/linux-2.6-next/arch/x86/include/asm/dma-mapping.h:155 hcd_buffer_free+0xb1/0xd4 [usbcore]()
[30753.755998] Hardware name: 6475EK2
[30753.755998] Modules linked in: uvcvideo ehci_hcd usbtest cdc_ether usbnet vfat fat usb_storage nfsd lockd nfs_acl auth_rpcgss exportfs mii tun videodev v4l1_compat v4l2_compat_ioctl32 fuse bridge stp llc sunrpc ipv6 cpufreq_ondemand acpi_cpufreq freq_table mperf kvm_intel kvm arc4 ecb ath5k usbhid mac80211 snd_hda_codec_conexant ch341 usbserial ath cfg80211 thinkpad_acpi snd_hda_intel pcspkr wmi hwmon yenta_socket iTCO_wdt iTCO_vendor_support i2c_i801 e1000e snd_hda_codec snd_hwdep snd_pcm snd_timer snd soundcore snd_page_alloc pata_acpi uhci_hcd ohci_hcd usbcore i915 drm_kms_helper drm i2c_algo_bit i2c_core video output [last unloaded: uvcvideo]
[30753.755998] Pid: 0, comm: swapper Tainted: G W 2.6.35-rc6-gkh-wl+ #49
[30753.755998] Call Trace:
[30753.755998] <IRQ> [<ffffffff8104478a>] warn_slowpath_common+0x80/0x98
[30753.755998] [<ffffffff810447b7>] warn_slowpath_null+0x15/0x17
[30753.755998] [<ffffffffa00ce02d>] hcd_buffer_free+0xb1/0xd4 [usbcore]
[30753.755998] [<ffffffffa00c1345>] usb_free_coherent+0x1c/0x1e [usbcore]
[30753.755998] [<ffffffffa00b13e4>] simple_free_urb+0x23/0x2f [usbtest]
[30753.755998] [<ffffffffa00b210b>] iso_callback+0xbb/0x10f [usbtest]
[30753.755998] [<ffffffffa00c7390>] usb_hcd_giveback_urb+0x8c/0xc0 [usbcore]
[30753.755998] [<ffffffffa0449b35>] ehci_urb_done+0x84/0x95 [ehci_hcd]
[30753.755998] [<ffffffffa044b5a5>] ehci_work+0x41a/0x7dd [ehci_hcd]
[30753.755998] [<ffffffffa044e298>] ehci_irq+0x33b/0x370 [ehci_hcd]
[30753.755998] [<ffffffff8100fb05>] ? sched_clock+0x9/0xd
[30753.755998] [<ffffffff8105e641>] ? sched_clock_local+0x1c/0x82
[30753.755998] [<ffffffff8105e76a>] ? sched_clock_cpu+0xc3/0xce
[30753.755998] [<ffffffff81067c7e>] ? trace_hardirqs_off+0xd/0xf
[30753.755998] [<ffffffff8105e7b8>] ? cpu_clock+0x43/0x5e
[30753.755998] [<ffffffffa00c6999>] usb_hcd_irq+0x45/0xa1 [usbcore]
[30753.755998] [<ffffffff81092e02>] handle_IRQ_event+0x20/0xa5
[30753.755998] [<ffffffff81094cea>] handle_fasteoi_irq+0x92/0xd2
[30753.755998] [<ffffffff8100c0ed>] handle_irq+0x1f/0x2a
[30753.755998] [<ffffffff8100b75d>] do_IRQ+0x57/0xbe
[30753.755998] [<ffffffff8136a693>] ret_from_intr+0x0/0x16
[30753.755998] <EOI> [<ffffffff81223baa>] ? acpi_idle_enter_bm+0x231/0x269
[30753.755998] [<ffffffff81223ba3>] ? acpi_idle_enter_bm+0x22a/0x269
[30753.755998] [<ffffffff812c4b6b>] cpuidle_idle_call+0x99/0xce
[30753.755998] [<ffffffff81008dd5>] cpu_idle+0x61/0xaa
[30753.755998] [<ffffffff8136374b>] start_secondary+0x1c2/0x1c6
[30753.755998] ---[ end trace 904cfaf7ab4cb1a2 ]---

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# c532b29a 01-Jun-2010 Andi Kleen <ak@linux.intel.com>

USB-BKL: Convert usb_driver ioctl to unlocked_ioctl

And audit all the users. None needed the BKL. That was easy
because there was only very few around.

Tested with allmodconfig build on x86-64

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
From: Andi Kleen <ak@linux.intel.com>


# 997ea58e 12-Apr-2010 Daniel Mack <daniel@caiaq.de>

USB: rename usb_buffer_alloc() and usb_buffer_free() users

For more clearance what the functions actually do,

usb_buffer_alloc() is renamed to usb_alloc_coherent()
usb_buffer_free() is renamed to usb_free_coherent()

They should only be used in code which really needs DMA coherency.

All call sites have been changed accordingly, except for staging
drivers.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Pedro Ribeiro <pedrib@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 0ede76fc 05-Mar-2010 Alan Stern <stern@rowland.harvard.edu>

USB: remove uses of URB_NO_SETUP_DMA_MAP

This patch (as1350) removes all usages of coherent buffers for USB
control-request setup-packet buffers. There's no good reason to
reserve coherent memory for these things; control requests are hardly
ever used in large quantity (the major exception is firmware
transfers, and they aren't time-critical). Furthermore, only seven
drivers used it. We might as well always use streaming DMA mappings
for setup-packet buffers, and remove some extra complexity from
usbcore.

The DMA-mapping portion of hcd.c is currently in flux. A separate
patch will be submitted to remove support for URB_NO_SETUP_DMA_MAP
after everything else settles down. The removal should go smoothly,
as by then nobody will be using it.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 33b9e162 10-Jan-2010 Németh Márton <nm127@freemail.hu>

USB misc: make USB device id constant

The id_table field of the struct usb_device_id is constant in <linux/usb.h>
so it is worth to make the initialization data also constant.

The semantic match that finds this kind of pattern is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
disable decl_init,const_decl_init;
identifier I1, I2, x;
@@
struct I1 {
...
const struct I2 *x;
...
};
@s@
identifier r.I1, y;
identifier r.x, E;
@@
struct I1 y = {
.x = E,
};
@c@
identifier r.I2;
identifier s.E;
@@
const struct I2 E[] = ... ;
@depends on !c@
identifier r.I2;
identifier s.E;
@@
+ const
struct I2 E[] = ...;
// </smpl>

Signed-off-by: Németh Márton <nm127@freemail.hu>
Cc: Julia Lawall <julia@diku.dk>
Cc: cocci@diku.dk
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 9bbdf1e0 07-Jan-2010 Alan Stern <stern@rowland.harvard.edu>

USB: convert to the runtime PM framework

This patch (as1329) converts the USB stack over to the PM core's
runtime PM framework. This involves numerous changes throughout
usbcore, especially to hub.c and driver.c. Perhaps the most notable
change is that CONFIG_USB_SUSPEND now depends on CONFIG_PM_RUNTIME
instead of CONFIG_PM.

Several fields in the usb_device and usb_interface structures are no
longer needed. Some code which used to depend on CONFIG_USB_PM now
depends on CONFIG_USB_SUSPEND (requiring some rearrangement of header
files).

The only visible change in behavior should be that following a system
sleep (resume from RAM or resume from hibernation), autosuspended USB
devices will be resumed just like everything else. They won't remain
suspended. But if they aren't in use then they will naturally
autosuspend again in a few seconds.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 7f4e9854 09-Nov-2009 Vikram Pandita <vikram.pandita@ti.com>

usbtest: make module param pattern writeable

Allow module_param to be writeable. This allows us to change
the parameter if usbtest is built-in in the kernel.

Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 3b6c023f 04-Jun-2009 Martin Fuzzey <mfuzzey@gmail.com>

USB: usbtest fix endless loop in unlink tests.

In tests 11 and 12 if the URB completes with an error status (eg babble)
the asynchrous unlink entered an endless loop trying to unlink
a non resubmitted URB.

Signed-off-by: Martin Fuzzey <mfuzzey@gmail.com>
Acked-by: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# e64a5219 20-Oct-2008 roel kluin <roel.kluin@gmail.com>

USB: clean up redundant tests on unsigned

temp, bytes and param->{length,sglen,vary} are unsigned so
these tests do nothing.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 8aafdf6a 20-Oct-2008 roel kluin <roel.kluin@gmail.com>

USB: usbtest.c: length, sglen and vary are unsigned, so cannot be negative

length, sglen and vary are unsigned, so cannot be negative

see
vi drivers/usb/misc/usbtest.c +18
struct usbtest_param {
...
unsigned iterations;
unsigned length;
unsigned vary;
unsigned sglen;
...
};

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# b6c63937 25-Jul-2008 Arjan van de Ven <arjan@linux.intel.com>

Rename WARN() to WARNING() to clear the namespace

We want to use WARN() as a variant of WARN_ON(), however a few drivers are
using WARN() internally. This patch renames these to WARNING() to avoid the
namespace clash. A few cases were defining but not using the thing, for those
cases I just deleted the definition.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: Greg KH <greg@kroah.com>
Cc: Karsten Keil <kkeil@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 6def7553 12-May-2008 Marcin Slusarz <marcin.slusarz@gmail.com>

usbtest: comment on why this code "expects" negative and positive errnos

On Mon, May 12, 2008 at 01:02:22AM -0700, David Brownell wrote:
> On Sunday 11 May 2008, Marcin Slusarz wrote:
> >
> > test_ctrl_queue expects (?) positive and negative errnos.
> > what is going on here?
>
> The sign is just a way to flag something:
>
> /* some faults are allowed, not required */
>
> The negative ones are required. Positive codes are optional,
> in the sense that, depending on how the peripheral happens
> to be implemented, they won't necessarily be triggered.
>
> For example, the test to fetch a device qualifier desriptor
> must succeed if the device is running at high speed. So that
> test is marked as negative. But when it's full speed, it
> could legitimately fail; marked as positive. And so on for
> other tests.
>
> Look at how the codes are *interpreted* to see it work.

Lets document it.

Based on comment from David Brownell <david-b@pacbell.net>.

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 28ffd79c 25-Apr-2008 David Brownell <david-b@pacbell.net>

USB: usbtest displays diagnostics again

Minor cleanup to the "usbtest" driver, mostly to resolve a regression:
all the important diagnostics were at KERN_DEBUG, so that when the
"#define DEBUG" was removed from the top of that file it stopped
providing diagnostics. Fix by using KERN_ERROR. Also:

- Stop using the legacy dbg() calls
- Simplify the internal debug macros
- Correct some test descriptions:
* Test #10 subcase 7 should *always* stall
* Test #10 subcase 8 *may* stall
- Diagnostic about control queue test failures is more informative
- Fix some whitespace "bugs"

And add a warning about the rude interaction between usbfs ioctl()
and khubd during device disconnect ... don't unplug a device under
test, that will wedge.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# cdc97792 24-Feb-2008 Ming Lei <tom.leiming@gmail.com>

USB: remove unnecessary type casting of urb->context

urb->context code cleanup

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 441b62c1 03-Mar-2008 Harvey Harrison <harvey.harrison@gmail.com>

USB: replace remaining __FUNCTION__ occurrences

__FUNCTION__ is gcc-specific, use __func__

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 70a1c9e0 06-Mar-2008 Alan Stern <stern@rowland.harvard.edu>

USB: remove dev->power.power_state

power.power_state is scheduled for removal. This patch (as1053)
removes all uses of that field from drivers/usb. Almost all of them
were write-only, the most significant exceptions being sl811-hcd.c and
u132-hcd.c.

Part of this patch was written by Pavel Machek.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <david-b@pacbell.net>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# dfa5ec79 04-Mar-2008 Julia Lawall <julia@diku.dk>

USB: use DIV_ROUND_UP

The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /
(d)) but is perhaps more readable.

An extract of the semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@haskernel@
@@

#include <linux/kernel.h>

@depends on haskernel@
expression n,d;
@@

(
- (n + d - 1) / d
+ DIV_ROUND_UP(n,d)
|
- (n + (d - 1)) / d
+ DIV_ROUND_UP(n,d)
)

@depends on haskernel@
expression n,d;
@@

- DIV_ROUND_UP((n),d)
+ DIV_ROUND_UP(n,d)

@depends on haskernel@
expression n,d;
@@

- DIV_ROUND_UP(n,(d))
+ DIV_ROUND_UP(n,d)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 4756febb 27-Mar-2008 Alan Stern <stern@rowland.harvard.edu>

USB: fix bug in sg initialization in usbtest

This patch (as1062) fixes a bug in the scatter-gather initialization
code in the usbtest driver. When the sg-helper conversion was
performed, it wasn't done correctly.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# dc0d5c1e 17-Dec-2007 Joe Perches <joe@perches.com>

USB: Spelling fixes

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 26e109b0 13-Dec-2007 Andrew Morton <akpm@linux-foundation.org>

USB: testing driver: don't free a locked mutex

Dopey thing to do and lockdep will (or should) warn.

Spotted by Daniel Walker.

Cc: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Cc: Daniel Walker <dwalker@mvista.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 1cfab028 13-Dec-2007 Matthias Kaehlcke <matthias.kaehlcke@gmail.com>

USB: testing driver: convert dev->sem to mutex

USB testing driver: convert semaphore dev->sem to the mutex API

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6ce4560a 08-Jan-2008 Jan Andersson <jan@gaisler.com>

usb: fix usbtest halt check on big endian systems

usbtest did not swap the received status information when checking for
a non-zero value and failed to discover halted endpoints on big endian
systems.

Cc: stable <stable@kernel.org>
Signed-off-by: Jan Andersson <jan@gaisler.com>
Acked-by: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 45711f1a 22-Oct-2007 Jens Axboe <jens.axboe@oracle.com>

[SG] Update drivers to use sg helpers

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>


# 59d99785 18-Jul-2007 Greg Kroah-Hartman <gregkh@suse.de>

USB: misc: usbtest: clean up urb->status usage

This done in anticipation of removal of urb->status, which will make
that patch easier to review and apply in the future.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# e94b1766 06-Dec-2006 Christoph Lameter <clameter@sgi.com>

[PATCH] slab: remove SLAB_KERNEL

SLAB_KERNEL is an alias of GFP_KERNEL.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 54e6ecb2 06-Dec-2006 Christoph Lameter <clameter@sgi.com>

[PATCH] slab: remove SLAB_ATOMIC

SLAB_ATOMIC is an alias of GFP_ATOMIC

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 4d823dd2 26-Oct-2006 Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>

USB: usbtest: Use usb_endpoint_* functions

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 7d12e780 05-Oct-2006 David Howells <dhowells@redhat.com>

IRQ: Maintain regs pointer globally rather than passing to IRQ handlers

Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.

The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).

Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.

Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.

I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.

This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

struct pt_regs *old_regs = set_irq_regs(regs);

And put the old one back at the end:

set_irq_regs(old_regs);

Don't pass regs through to generic_handle_irq() or __do_IRQ().

In timer_interrupt(), this sort of change will be necessary:

- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);

I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().

Some notes on the interrupt handling in the drivers:

(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.

(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.

(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.

Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)


# f54fa84d 09-Aug-2006 Orjan Friberg <orjan.friberg@axis.com>

USB: usbtest.c: unsigned retval makes ctrl_out return 0 in case of error

In my quest to try and figure out why test 14 (control write) doesn't
work with my EZ-USB board, I noticed that sometimes testusb reported
no error even though the kernel log complained "byte 0 is 0 not 2" etc.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6ab3d562 30-Jun-2006 Jörn Engel <joern@wohnheim.fh-wedel.de>

Remove obsolete #include <linux/config.h>

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>


# 9da2150f 22-May-2006 Alan Stern <stern@rowland.harvard.edu>

[PATCH] usbtest: report errors in iso tests

This patch (as693b) makes the usbtest driver report errors in the
isochronous bulk transfer tests instead of always returning 0. As an
arbitrary cutoff, an error is returned if more than 10% of the packet
transfers fail. It also stops a test immediately upon receiving an URB
submission error.

For a test harness, it's especially important to report when errors occur!

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# caa2a122 15-May-2006 Franck Bui-Huu <vagabon.xyz@gmail.com>

[PATCH] Fix a deadlock in usbtest

ctrl_complete functions acquires ctx->lock and tries to unlink
all queued urbs in case of errors through usb_unlink_urb func.
In its turn usb_unlink_urb calls, through the hcd driver,
usb_hcd_giveback_urb which calls ctrl_complete again. At this
time, ctx->lock is already taken by the same function.

Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 8b524901 02-Apr-2006 David Brownell <david-b@pacbell.net>

[PATCH] USB: usbtest: scatterlist OUT data pattern testing

Previously, scatterlist tests didn't write patterned data. Given how many
corner cases are addresed by them, this was a significant gap in Linux-USB
test coverage. Moreover, when peripherals checked for correct data patterns,
false error reports would drown out the true ones.

This adds the pattern on the way OUT from the host, so scatterlist tests can
now be used to uncover bugs like host TX or peripheral RX paths failing for
back-to-back short packets. It's easy enough to get an error there with at
least one of the {DMA,PIO}{RX,TX} code paths, or run into hardware races
that need to be defended against.

Note this patch doesn't add checking for correct data patterns on the way
IN from peripherals, just a FIXME for later.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 80b6ca48 27-Feb-2006 Eric Sesterhenn <snakebyte@gmx.de>

[PATCH] USB: kzalloc() conversion for rest of drivers/usb

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 75318d2d 21-Nov-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB: remove .owner field from struct usb_driver

It is no longer needed, so let's remove it, saving a bit of memory.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 654f3118 17-Nov-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] USB: move CONFIG_USB_DEBUG checks into the Makefile

This lets us remove a lot of code in the drivers that were all checking
the same thing. It also found some bugs in a few of the drivers, which
has been fixed up.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 378f058c 17-Sep-2005 David Hardeman <david@2gen.com>

[PATCH] Use sg_set_buf/sg_init_one where applicable

This patch uses sg_set_buf/sg_init_one in some places where it was
duplicated.

Signed-off-by: David Hardeman <david@2gen.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: Greg KH <greg@kroah.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>


# 3e8a556a 18-Oct-2005 Alan Stern <stern@rowland.harvard.edu>

[PATCH] Missing transfer_flags setting in usbtest

This patch (as582) adds a missing transfer_flags setting to the usbtest
driver.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# db690874 13-Sep-2005 David Brownell <david-b@pacbell.net>

[PATCH] usb_interface power state

This updates the handling of power state for USB interfaces.

- Formalizes an existing invariant: interface "power state" is a boolean:
ON when I/O is allowed, and FREEZE otherwise. It does so by defining
some inlined helpers, then using them.

- Adds a useful invariant: the only interfaces marked active are those
bound to non-suspended drivers. Later patches build on this invariant.

- Simplifies the interface driver API (and removes some error paths) by
removing the requirement that they record power state changes during
suspend and resume callbacks. Now usbcore does that.

A few drivers were simplified to address that last change.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

drivers/usb/core/hub.c | 33 +++++++++------------
drivers/usb/core/message.c | 1
drivers/usb/core/usb.c | 65 +++++++++++++++++++++++++++++++++----------
drivers/usb/core/usb.h | 18 +++++++++++
drivers/usb/input/hid-core.c | 2 -
drivers/usb/misc/usbtest.c | 10 ------
drivers/usb/net/pegasus.c | 2 -
drivers/usb/net/usbnet.c | 2 -
8 files changed, 85 insertions(+), 48 deletions(-)


# b375a049 29-Jul-2005 Alan Stern <stern@rowland.harvard.edu>

[PATCH] USB: URB_ASYNC_UNLINK flag removed from the kernel

29 July 2005, Cambridge, MA:

This afternoon Alan Stern submitted a patch to remove the URB_ASYNC_UNLINK
flag from the Linux kernel. Mr. Stern explained, "This flag is a relic
from an earlier, less-well-designed system. For over a year it hasn't
been used for anything other than printing warning messages."

An anonymous spokesman for the Linux kernel development community
commented, "This is exactly the sort of thing we see happening all the
time. As the kernel evolves, support for old techniques and old code can
be jettisoned and replaced by newer, better approaches. Proprietary
operating systems do not have the freedom or flexibility to change so
quickly."

Mr. Stern, a staff member at Harvard University's Rowland Institute who
works on Linux only as a hobby, noted that the patch (labelled as548) did
not update two files, keyspan.c and option.c, in the USB drivers' "serial"
subdirectory. "Those files need more extensive changes," he remarked.
"They examine the status field of several URBs at times when they're not
supposed to. That will need to be fixed before the URB_ASYNC_UNLINK flag
is removed."

Greg Kroah-Hartman, the kernel maintainer responsible for overseeing all
of Linux's USB drivers, did not respond to our inquiries or return our
calls. His only comment was "Applied, thanks."

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# ca078bae 03-Sep-2005 Pavel Machek <pavel@ucw.cz>

[PATCH] swsusp: switch pm_message_t to struct

This adds type-checking to pm_message_t, so that people can't confuse it
with int or u32. It also allows us to fix "disk yoyo" during suspend (disk
spinning down/up/down).

[We've tried that before; since that cpufreq problems were fixed and I've
tried make allyes config and fixed resulting damage.]

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Alexander Nyberg <alexn@telia.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# ff7c79e4 22-Apr-2005 David Brownell <david-b@pacbell.net>

[PATCH] USB: usbtest updates

Updates to "usbtest" driver:

* Improve some diagnostics. One path that never generated diagnostics
before should now generate two ... unless you hit a GCC bug that
all my compilers seem to have, go figure.

* Add suspend/resume support, so this behaves when the Linux host
being used for testing suspends.

* Don't test the "zero byte ep0 read" case unless real-world relevance
for the testing is is irrelevant.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 1da177e4 16-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org>

Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!