Skip to content

Commit

Permalink
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6
Browse files Browse the repository at this point in the history
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6: (29 commits)
  USB: Add support for Olimex arm-usb-ocd JTAG interface serial port
  USB: Add support for Sierra Wireless Aircard 595U
  USB: ldusb bugfix
  USB: ftdi_sio: Add USB Product Id for OpenDCC
  USB: fix ratelimit call semantics
  USB: handle errors in power/level attribute
  USB: make the autosuspend workqueue thread freezable
  USB: Fix USB OHCI Subvendor for Toshiba Portege 4000
  USB: usblp: Use correct DMA address in case of probe error
  USB: Fix debug output of ark3116
  USB: Onetouch - switch to using input_dev->dev.parent
  USB: don't try to kzalloc 0 bytes
  USB: remove short initial timeout for device descriptor fetch
  USB: Deref URB after usbmon is done with it
  USB: Remove duplicate IDs from option card driver
  USB: auerswald: fix file release handler
  USB: fsl_usb2_udc: Fix UMTI_WIDE support and a compile warning
  USB: set the correct Interrupt interval in usb_bulk_msg
  USB: New device PID for ftdi_sio driver
  USB: remove unneeded WARN_ON
  ...
  • Loading branch information
Linus Torvalds committed May 23, 2007
2 parents 31f6e1b + fa91d43 commit 641e22e
Show file tree
Hide file tree
Showing 30 changed files with 222 additions and 102 deletions.
2 changes: 1 addition & 1 deletion Documentation/DocBook/gadget.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<toc></toc>

<chapter><title>Introduction</title>
<chapter id="intro"><title>Introduction</title>

<para>This document presents a Linux-USB "Gadget"
kernel mode
Expand Down
28 changes: 14 additions & 14 deletions Documentation/DocBook/usb.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@

</chapter>

<chapter><title>USB-Standard Types</title>
<chapter id="types"><title>USB-Standard Types</title>

<para>In <filename>&lt;linux/usb/ch9.h&gt;</filename> you will find
the USB data types defined in chapter 9 of the USB specification.
Expand All @@ -197,7 +197,7 @@

</chapter>

<chapter><title>Host-Side Data Types and Macros</title>
<chapter id="hostside"><title>Host-Side Data Types and Macros</title>

<para>The host side API exposes several layers to drivers, some of
which are more necessary than others.
Expand All @@ -211,7 +211,7 @@

</chapter>

<chapter><title>USB Core APIs</title>
<chapter id="usbcore"><title>USB Core APIs</title>

<para>There are two basic I/O models in the USB API.
The most elemental one is asynchronous: drivers submit requests
Expand Down Expand Up @@ -248,7 +248,7 @@
!Edrivers/usb/core/hub.c
</chapter>

<chapter><title>Host Controller APIs</title>
<chapter id="hcd"><title>Host Controller APIs</title>

<para>These APIs are only for use by host controller drivers,
most of which implement standard register interfaces such as
Expand Down Expand Up @@ -285,7 +285,7 @@
!Idrivers/usb/core/buffer.c
</chapter>

<chapter>
<chapter id="usbfs">
<title>The USB Filesystem (usbfs)</title>

<para>This chapter presents the Linux <emphasis>usbfs</emphasis>.
Expand Down Expand Up @@ -317,7 +317,7 @@
not it has a kernel driver.
</para>

<sect1>
<sect1 id="usbfs-files">
<title>What files are in "usbfs"?</title>

<para>Conventionally mounted at
Expand Down Expand Up @@ -356,7 +356,7 @@

</sect1>

<sect1>
<sect1 id="usbfs-fstab">
<title>Mounting and Access Control</title>

<para>There are a number of mount options for usbfs, which will
Expand Down Expand Up @@ -439,7 +439,7 @@

</sect1>

<sect1>
<sect1 id="usbfs-devices">
<title>/proc/bus/usb/devices</title>

<para>This file is handy for status viewing tools in user
Expand Down Expand Up @@ -473,7 +473,7 @@ for (;;) {
</para>
</sect1>

<sect1>
<sect1 id="usbfs-bbbddd">
<title>/proc/bus/usb/BBB/DDD</title>

<para>Use these files in one of these basic ways:
Expand Down Expand Up @@ -510,7 +510,7 @@ for (;;) {
</sect1>


<sect1>
<sect1 id="usbfs-lifecycle">
<title>Life Cycle of User Mode Drivers</title>

<para>Such a driver first needs to find a device file
Expand Down Expand Up @@ -565,7 +565,7 @@ for (;;) {

</sect1>

<sect1><title>The ioctl() Requests</title>
<sect1 id="usbfs-ioctl"><title>The ioctl() Requests</title>

<para>To use these ioctls, you need to include the following
headers in your userspace program:
Expand Down Expand Up @@ -604,7 +604,7 @@ for (;;) {
</para>


<sect2>
<sect2 id="usbfs-mgmt">
<title>Management/Status Requests</title>

<para>A number of usbfs requests don't deal very directly
Expand Down Expand Up @@ -736,7 +736,7 @@ usbdev_ioctl (int fd, int ifno, unsigned request, void *param)

</sect2>

<sect2>
<sect2 id="usbfs-sync">
<title>Synchronous I/O Support</title>

<para>Synchronous requests involve the kernel blocking
Expand Down Expand Up @@ -865,7 +865,7 @@ usbdev_ioctl (int fd, int ifno, unsigned request, void *param)
</variablelist>
</sect2>

<sect2>
<sect2 id="usbfs-async">
<title>Asynchronous I/O Support</title>

<para>As mentioned above, there are situations where it may be
Expand Down
16 changes: 16 additions & 0 deletions drivers/net/usb/cdc_ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
"CDC descriptors on config\n");
}

/* Maybe CDC descriptors are after the endpoint? This bug has
* been seen on some 2Wire Inc RNDIS-ish products.
*/
if (len == 0) {
struct usb_host_endpoint *hep;

hep = intf->cur_altsetting->endpoint;
if (hep) {
buf = hep->extra;
len = hep->extralen;
}
if (len)
dev_dbg(&intf->dev,
"CDC descriptors on endpoint\n");
}

/* this assumes that if there's a non-RNDIS vendor variant
* of cdc-acm, it'll fail RNDIS requests cleanly.
*/
Expand Down
1 change: 1 addition & 0 deletions drivers/net/usb/rndis_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
dev_err(&intf->dev,
"dev can't take %u byte packets (max %u)\n",
dev->hard_mtu, tmp);
retval = -EINVAL;
goto fail_and_release;
}

Expand Down
25 changes: 15 additions & 10 deletions drivers/net/usb/usbnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,20 +1252,23 @@ EXPORT_SYMBOL_GPL(usbnet_probe);

/*-------------------------------------------------------------------------*/

/* FIXME these suspend/resume methods assume non-CDC style
* devices, with only one interface.
/*
* suspend the whole driver as soon as the first interface is suspended
* resume only when the last interface is resumed
*/

int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
{
struct usbnet *dev = usb_get_intfdata(intf);

/* accelerate emptying of the rx and queues, to avoid
* having everything error out.
*/
netif_device_detach (dev->net);
(void) unlink_urbs (dev, &dev->rxq);
(void) unlink_urbs (dev, &dev->txq);
if (!dev->suspend_count++) {
/* accelerate emptying of the rx and queues, to avoid
* having everything error out.
*/
netif_device_detach (dev->net);
(void) unlink_urbs (dev, &dev->rxq);
(void) unlink_urbs (dev, &dev->txq);
}
return 0;
}
EXPORT_SYMBOL_GPL(usbnet_suspend);
Expand All @@ -1274,8 +1277,10 @@ int usbnet_resume (struct usb_interface *intf)
{
struct usbnet *dev = usb_get_intfdata(intf);

netif_device_attach (dev->net);
tasklet_schedule (&dev->bh);
if (!--dev->suspend_count) {
netif_device_attach (dev->net);
tasklet_schedule (&dev->bh);
}
return 0;
}
EXPORT_SYMBOL_GPL(usbnet_resume);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/usb/usbnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct usbnet {
const char *driver_name;
wait_queue_head_t *wait;
struct mutex phy_mutex;
unsigned char suspend_count;

/* i/o info: pipes etc */
unsigned in, out;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/class/usblp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ static int usblp_probe(struct usb_interface *intf,
usblp->writebuf, usblp->writeurb->transfer_dma);
if (usblp->readbuf)
usb_buffer_free (usblp->dev, USBLP_BUF_SIZE,
usblp->readbuf, usblp->writeurb->transfer_dma);
usblp->readbuf, usblp->readurb->transfer_dma);
kfree(usblp->statusbuf);
kfree(usblp->device_id_string);
usb_free_urb(usblp->writeurb);
Expand Down
10 changes: 6 additions & 4 deletions drivers/usb/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
num_ep = USB_MAXENDPOINTS;
}

len = sizeof(struct usb_host_endpoint) * num_ep;
alt->endpoint = kzalloc(len, GFP_KERNEL);
if (!alt->endpoint)
return -ENOMEM;
if (num_ep > 0) { /* Can't allocate 0 bytes */
len = sizeof(struct usb_host_endpoint) * num_ep;
alt->endpoint = kzalloc(len, GFP_KERNEL);
if (!alt->endpoint)
return -ENOMEM;
}

/* Parse all the endpoint descriptors */
n = 0;
Expand Down
18 changes: 14 additions & 4 deletions drivers/usb/core/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,10 @@ static int autosuspend_check(struct usb_device *udev)

#else

#define autosuspend_check(udev) 0
static inline int autosuspend_check(struct usb_device *udev)
{
return 0;
}

#endif /* CONFIG_USB_SUSPEND */

Expand Down Expand Up @@ -1041,7 +1044,6 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
if (status < 0)
goto done;
}
cancel_delayed_work(&udev->autosuspend);

/* Suspend all the interfaces and then udev itself */
if (udev->actconfig) {
Expand All @@ -1062,9 +1064,16 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
usb_resume_interface(intf);
}

/* Try another autosuspend when the interfaces aren't busy */
if (udev->auto_pm)
autosuspend_check(udev);

/* If the suspend succeeded, propagate it up the tree */
} else if (parent)
usb_autosuspend_device(parent);
} else {
cancel_delayed_work(&udev->autosuspend);
if (parent)
usb_autosuspend_device(parent);
}

done:
// dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
Expand Down Expand Up @@ -1475,6 +1484,7 @@ int usb_external_resume_device(struct usb_device *udev)
usb_pm_lock(udev);
udev->auto_pm = 0;
status = usb_resume_both(udev);
udev->last_busy = jiffies;
usb_pm_unlock(udev);

/* Now that the device is awake, we can start trying to autosuspend
Expand Down
6 changes: 1 addition & 5 deletions drivers/usb/core/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,8 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
atomic_dec (&urb->use_count);
if (urb->reject)
wake_up (&usb_kill_urb_queue);
usb_put_urb (urb);
usbmon_urb_submit_error(&hcd->self, urb, status);
usb_put_urb (urb);
}
return status;
}
Expand Down Expand Up @@ -1175,10 +1175,6 @@ void usb_hcd_endpoint_disable (struct usb_device *udev,
struct urb *urb;

hcd = bus_to_hcd(udev->bus);

WARN_ON (!HC_IS_RUNNING (hcd->state) && hcd->state != HC_STATE_HALT &&
udev->state != USB_STATE_NOTATTACHED);

local_irq_disable ();

/* ep is already gone from udev->ep_{in,out}[]; no more submits */
Expand Down
21 changes: 8 additions & 13 deletions drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2201,22 +2201,17 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
continue;
}

/* Use a short timeout the first time through,
* so that recalcitrant full-speed devices with
* 8- or 16-byte ep0-maxpackets won't slow things
* down tremendously by NAKing the unexpectedly
* early status stage. Also, retry on all errors;
* some devices are flakey.
* 255 is for WUSB devices, we actually need to use 512.
* WUSB1.0[4.8.1].
/* Retry on all errors; some devices are flakey.
* 255 is for WUSB devices, we actually need to use
* 512 (WUSB1.0[4.8.1]).
*/
for (j = 0; j < 3; ++j) {
buf->bMaxPacketSize0 = 0;
r = usb_control_msg(udev, usb_rcvaddr0pipe(),
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
USB_DT_DEVICE << 8, 0,
buf, GET_DESCRIPTOR_BUFSIZE,
(i ? USB_CTRL_GET_TIMEOUT : 1000));
USB_CTRL_GET_TIMEOUT);
switch (buf->bMaxPacketSize0) {
case 8: case 16: case 32: case 64: case 255:
if (buf->bDescriptorType ==
Expand Down Expand Up @@ -2426,10 +2421,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,

if (portchange & USB_PORT_STAT_C_CONNECTION) {
status = hub_port_debounce(hub, port1);
if (status < 0 && printk_ratelimit()) {
dev_err (hub_dev,
"connect-debounce failed, port %d disabled\n",
port1);
if (status < 0) {
if (printk_ratelimit())
dev_err (hub_dev, "connect-debounce failed, "
"port %d disabled\n", port1);
goto done;
}
portstatus = status;
Expand Down
9 changes: 2 additions & 7 deletions drivers/usb/core/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,10 @@ int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,

if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_INT) {
int interval;

if (usb_dev->speed == USB_SPEED_HIGH)
interval = 1 << min(15, ep->desc.bInterval - 1);
else
interval = ep->desc.bInterval;
pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30);
usb_fill_int_urb(urb, usb_dev, pipe, data, len,
usb_api_blocking_completion, NULL, interval);
usb_api_blocking_completion, NULL,
ep->desc.bInterval);
} else
usb_fill_bulk_urb(urb, usb_dev, pipe, data, len,
usb_api_blocking_completion, NULL);
Expand Down
7 changes: 7 additions & 0 deletions drivers/usb/core/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,15 @@ set_level(struct device *dev, struct device_attribute *attr,
int len = count;
char *cp;
int rc = 0;
int old_autosuspend_disabled, old_autoresume_disabled;

cp = memchr(buf, '\n', count);
if (cp)
len = cp - buf;

usb_lock_device(udev);
old_autosuspend_disabled = udev->autosuspend_disabled;
old_autoresume_disabled = udev->autoresume_disabled;

/* Setting the flags without calling usb_pm_lock is a subject to
* races, but who cares...
Expand All @@ -263,6 +266,10 @@ set_level(struct device *dev, struct device_attribute *attr,
} else
rc = -EINVAL;

if (rc) {
udev->autosuspend_disabled = old_autosuspend_disabled;
udev->autoresume_disabled = old_autoresume_disabled;
}
usb_unlock_device(udev);
return (rc < 0 ? rc : count);
}
Expand Down
Loading

0 comments on commit 641e22e

Please sign in to comment.