Skip to content

Commit 17a3be3

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (30 commits) USB: Fix a bug on appledisplay.c regarding signedness USB: option: support hi speed for modem Haier CE100 USB: audio gadget: free alsa devices when unloading USB: audio gadget: fix wTotalLength calculation usb: otg: isp1301_omap: fix compile error USB: musb: workaround Blackfin FIFO anomalies USB: musb: Fix array index out of bounds issue USB: musb: Fix null pointer dereference issue USB: musb: correct DMA address for tx USB: musb: gadget_ep0: avoid SetupEnd interrupt USB: musb: fix for crash in DM646x USB when (CPPI)DMA is enabled USB: musb: do not work if no gadget driver is loaded USB: musb: gadget: set otg tranceiver to idle when registering gadget USB: musb: Populate the VBUS GPIO with the correct GPIO number USB: musb: MAINTAINERS: Fix my tree's address USB: musb: fix compiling warning with min() macro USB: musb: move musb_remove to __exit USB: musb_gadget: fix kernel oops in txstate() USB: ftdi_sio: sort PID/VID entries in new ftdi_sio_ids.h header USB: ftdi_sio: isolate all device IDs to new ftdi_sio_ids.h header ...
2 parents f793067 + 37e9066 commit 17a3be3

28 files changed

+1226
-1097
lines changed

Documentation/ABI/testing/sysfs-bus-usb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,27 @@ Contact: Alan Stern <[email protected]>
2121
Description:
2222
Each USB device directory will contain a file named
2323
power/level. This file holds a power-level setting for
24-
the device, one of "on", "auto", or "suspend".
24+
the device, either "on" or "auto".
2525

2626
"on" means that the device is not allowed to autosuspend,
2727
although normal suspends for system sleep will still
2828
be honored. "auto" means the device will autosuspend
2929
and autoresume in the usual manner, according to the
30-
capabilities of its driver. "suspend" means the device
31-
is forced into a suspended state and it will not autoresume
32-
in response to I/O requests. However remote-wakeup requests
33-
from the device may still be enabled (the remote-wakeup
34-
setting is controlled separately by the power/wakeup
35-
attribute).
30+
capabilities of its driver.
3631

3732
During normal use, devices should be left in the "auto"
38-
level. The other levels are meant for administrative uses.
33+
level. The "on" level is meant for administrative uses.
3934
If you want to suspend a device immediately but leave it
4035
free to wake up in response to I/O requests, you should
4136
write "0" to power/autosuspend.
4237

38+
Device not capable of proper suspend and resume should be
39+
left in the "on" level. Although the USB spec requires
40+
devices to support suspend/resume, many of them do not.
41+
In fact so many don't that by default, the USB core
42+
initializes all non-hub devices in the "on" level. Some
43+
drivers may change this setting when they are bound.
44+
4345
What: /sys/bus/usb/devices/.../power/persist
4446
Date: May 2007
4547
KernelVersion: 2.6.23

Documentation/usb/power-management.txt

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ being accessed through sysfs, then it definitely is idle.
7171
Forms of dynamic PM
7272
-------------------
7373

74-
Dynamic suspends can occur in two ways: manual and automatic.
75-
"Manual" means that the user has told the kernel to suspend a device,
76-
whereas "automatic" means that the kernel has decided all by itself to
77-
suspend a device. Automatic suspend is called "autosuspend" for
78-
short. In general, a device won't be autosuspended unless it has been
79-
idle for some minimum period of time, the so-called idle-delay time.
74+
Dynamic suspends occur when the kernel decides to suspend an idle
75+
device. This is called "autosuspend" for short. In general, a device
76+
won't be autosuspended unless it has been idle for some minimum period
77+
of time, the so-called idle-delay time.
8078

8179
Of course, nothing the kernel does on its own initiative should
8280
prevent the computer or its devices from working properly. If a
@@ -96,10 +94,11 @@ idle.
9694
We can categorize power management events in two broad classes:
9795
external and internal. External events are those triggered by some
9896
agent outside the USB stack: system suspend/resume (triggered by
99-
userspace), manual dynamic suspend/resume (also triggered by
100-
userspace), and remote wakeup (triggered by the device). Internal
101-
events are those triggered within the USB stack: autosuspend and
102-
autoresume.
97+
userspace), manual dynamic resume (also triggered by userspace), and
98+
remote wakeup (triggered by the device). Internal events are those
99+
triggered within the USB stack: autosuspend and autoresume. Note that
100+
all dynamic suspend events are internal; external agents are not
101+
allowed to issue dynamic suspends.
103102

104103

105104
The user interface for dynamic PM
@@ -145,9 +144,9 @@ relevant attribute files are: wakeup, level, and autosuspend.
145144
number of seconds the device should remain idle before
146145
the kernel will autosuspend it (the idle-delay time).
147146
The default is 2. 0 means to autosuspend as soon as
148-
the device becomes idle, and -1 means never to
149-
autosuspend. You can write a number to the file to
150-
change the autosuspend idle-delay time.
147+
the device becomes idle, and negative values mean
148+
never to autosuspend. You can write a number to the
149+
file to change the autosuspend idle-delay time.
151150

152151
Writing "-1" to power/autosuspend and writing "on" to power/level do
153152
essentially the same thing -- they both prevent the device from being
@@ -377,9 +376,9 @@ the device hasn't been idle for long enough, a delayed workqueue
377376
routine is automatically set up to carry out the operation when the
378377
autosuspend idle-delay has expired.
379378

380-
Autoresume attempts also can fail. This will happen if power/level is
381-
set to "suspend" or if the device doesn't manage to resume properly.
382-
Unlike autosuspend, there's no delay for an autoresume.
379+
Autoresume attempts also can fail, although failure would mean that
380+
the device is no longer present or operating properly. Unlike
381+
autosuspend, there's no delay for an autoresume.
383382

384383

385384
Other parts of the driver interface
@@ -527,13 +526,3 @@ succeed, it may still remain active and thus cause the system to
527526
resume as soon as the system suspend is complete. Or the remote
528527
wakeup may fail and get lost. Which outcome occurs depends on timing
529528
and on the hardware and firmware design.
530-
531-
More interestingly, a device might undergo a manual resume or
532-
autoresume during system suspend. With current kernels this shouldn't
533-
happen, because manual resumes must be initiated by userspace and
534-
autoresumes happen in response to I/O requests, but all user processes
535-
and I/O should be quiescent during a system suspend -- thanks to the
536-
freezer. However there are plans to do away with the freezer, which
537-
would mean these things would become possible. If and when this comes
538-
about, the USB core will carefully arrange matters so that either type
539-
of resume will block until the entire system has resumed.

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3679,7 +3679,7 @@ F: include/linux/isicom.h
36793679
MUSB MULTIPOINT HIGH SPEED DUAL-ROLE CONTROLLER
36803680
M: Felipe Balbi <[email protected]>
36813681
3682-
T: git git://gitorious.org/musb/mainline.git
3682+
T: git git://gitorious.org/usb/usb.git
36833683
S: Maintained
36843684
F: drivers/usb/musb/
36853685

drivers/usb/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,3 @@ obj-y += early/
4444

4545
obj-$(CONFIG_USB_ATM) += atm/
4646
obj-$(CONFIG_USB_SPEEDTOUCH) += atm/
47-
48-
obj-$(CONFIG_USB_ULPI) += otg/

drivers/usb/core/hcd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,9 @@ void usb_hcd_flush_endpoint(struct usb_device *udev,
15971597
}
15981598

15991599
/**
1600-
* Check whether a new bandwidth setting exceeds the bus bandwidth.
1600+
* usb_hcd_alloc_bandwidth - check whether a new bandwidth setting exceeds
1601+
* the bus bandwidth
1602+
* @udev: target &usb_device
16011603
* @new_config: new configuration to install
16021604
* @cur_alt: the current alternate interface setting
16031605
* @new_alt: alternate interface setting that is being installed

drivers/usb/core/hub.c

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,12 +1658,12 @@ static inline void announce_device(struct usb_device *udev) { }
16581658
#endif
16591659

16601660
/**
1661-
* usb_configure_device_otg - FIXME (usbcore-internal)
1661+
* usb_enumerate_device_otg - FIXME (usbcore-internal)
16621662
* @udev: newly addressed device (in ADDRESS state)
16631663
*
1664-
* Do configuration for On-The-Go devices
1664+
* Finish enumeration for On-The-Go devices
16651665
*/
1666-
static int usb_configure_device_otg(struct usb_device *udev)
1666+
static int usb_enumerate_device_otg(struct usb_device *udev)
16671667
{
16681668
int err = 0;
16691669

@@ -1734,7 +1734,7 @@ static int usb_configure_device_otg(struct usb_device *udev)
17341734

17351735

17361736
/**
1737-
* usb_configure_device - Detect and probe device intfs/otg (usbcore-internal)
1737+
* usb_enumerate_device - Read device configs/intfs/otg (usbcore-internal)
17381738
* @udev: newly addressed device (in ADDRESS state)
17391739
*
17401740
* This is only called by usb_new_device() and usb_authorize_device()
@@ -1745,7 +1745,7 @@ static int usb_configure_device_otg(struct usb_device *udev)
17451745
* the string descriptors, as they will be errored out by the device
17461746
* until it has been authorized.
17471747
*/
1748-
static int usb_configure_device(struct usb_device *udev)
1748+
static int usb_enumerate_device(struct usb_device *udev)
17491749
{
17501750
int err;
17511751

@@ -1769,7 +1769,7 @@ static int usb_configure_device(struct usb_device *udev)
17691769
udev->descriptor.iManufacturer);
17701770
udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
17711771
}
1772-
err = usb_configure_device_otg(udev);
1772+
err = usb_enumerate_device_otg(udev);
17731773
fail:
17741774
return err;
17751775
}
@@ -1779,8 +1779,8 @@ static int usb_configure_device(struct usb_device *udev)
17791779
* usb_new_device - perform initial device setup (usbcore-internal)
17801780
* @udev: newly addressed device (in ADDRESS state)
17811781
*
1782-
* This is called with devices which have been enumerated, but not yet
1783-
* configured. The device descriptor is available, but not descriptors
1782+
* This is called with devices which have been detected but not fully
1783+
* enumerated. The device descriptor is available, but not descriptors
17841784
* for any device configuration. The caller must have locked either
17851785
* the parent hub (if udev is a normal device) or else the
17861786
* usb_bus_list_lock (if udev is a root hub). The parent's pointer to
@@ -1803,8 +1803,8 @@ int usb_new_device(struct usb_device *udev)
18031803
if (udev->parent)
18041804
usb_autoresume_device(udev->parent);
18051805

1806-
usb_detect_quirks(udev); /* Determine quirks */
1807-
err = usb_configure_device(udev); /* detect & probe dev/intfs */
1806+
usb_detect_quirks(udev);
1807+
err = usb_enumerate_device(udev); /* Read descriptors */
18081808
if (err < 0)
18091809
goto fail;
18101810
dev_dbg(&udev->dev, "udev %d, busnum %d, minor = %d\n",
@@ -1849,21 +1849,23 @@ int usb_new_device(struct usb_device *udev)
18491849
*/
18501850
int usb_deauthorize_device(struct usb_device *usb_dev)
18511851
{
1852-
unsigned cnt;
18531852
usb_lock_device(usb_dev);
18541853
if (usb_dev->authorized == 0)
18551854
goto out_unauthorized;
1855+
18561856
usb_dev->authorized = 0;
18571857
usb_set_configuration(usb_dev, -1);
1858+
1859+
kfree(usb_dev->product);
18581860
usb_dev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
1861+
kfree(usb_dev->manufacturer);
18591862
usb_dev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
1863+
kfree(usb_dev->serial);
18601864
usb_dev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
1861-
kfree(usb_dev->config);
1862-
usb_dev->config = NULL;
1863-
for (cnt = 0; cnt < usb_dev->descriptor.bNumConfigurations; cnt++)
1864-
kfree(usb_dev->rawdescriptors[cnt]);
1865+
1866+
usb_destroy_configuration(usb_dev);
18651867
usb_dev->descriptor.bNumConfigurations = 0;
1866-
kfree(usb_dev->rawdescriptors);
1868+
18671869
out_unauthorized:
18681870
usb_unlock_device(usb_dev);
18691871
return 0;
@@ -1873,15 +1875,11 @@ int usb_deauthorize_device(struct usb_device *usb_dev)
18731875
int usb_authorize_device(struct usb_device *usb_dev)
18741876
{
18751877
int result = 0, c;
1878+
18761879
usb_lock_device(usb_dev);
18771880
if (usb_dev->authorized == 1)
18781881
goto out_authorized;
1879-
kfree(usb_dev->product);
1880-
usb_dev->product = NULL;
1881-
kfree(usb_dev->manufacturer);
1882-
usb_dev->manufacturer = NULL;
1883-
kfree(usb_dev->serial);
1884-
usb_dev->serial = NULL;
1882+
18851883
result = usb_autoresume_device(usb_dev);
18861884
if (result < 0) {
18871885
dev_err(&usb_dev->dev,
@@ -1894,10 +1892,18 @@ int usb_authorize_device(struct usb_device *usb_dev)
18941892
"authorization: %d\n", result);
18951893
goto error_device_descriptor;
18961894
}
1895+
1896+
kfree(usb_dev->product);
1897+
usb_dev->product = NULL;
1898+
kfree(usb_dev->manufacturer);
1899+
usb_dev->manufacturer = NULL;
1900+
kfree(usb_dev->serial);
1901+
usb_dev->serial = NULL;
1902+
18971903
usb_dev->authorized = 1;
1898-
result = usb_configure_device(usb_dev);
1904+
result = usb_enumerate_device(usb_dev);
18991905
if (result < 0)
1900-
goto error_configure;
1906+
goto error_enumerate;
19011907
/* Choose and set the configuration. This registers the interfaces
19021908
* with the driver core and lets interface drivers bind to them.
19031909
*/
@@ -1912,8 +1918,10 @@ int usb_authorize_device(struct usb_device *usb_dev)
19121918
}
19131919
}
19141920
dev_info(&usb_dev->dev, "authorized to connect\n");
1915-
error_configure:
1921+
1922+
error_enumerate:
19161923
error_device_descriptor:
1924+
usb_autosuspend_device(usb_dev);
19171925
error_autoresume:
19181926
out_authorized:
19191927
usb_unlock_device(usb_dev); // complements locktree

drivers/usb/core/sysfs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,13 @@ static ssize_t show_##name(struct device *dev, \
8282
struct device_attribute *attr, char *buf) \
8383
{ \
8484
struct usb_device *udev; \
85+
int retval; \
8586
\
8687
udev = to_usb_device(dev); \
87-
return sprintf(buf, "%s\n", udev->name); \
88+
usb_lock_device(udev); \
89+
retval = sprintf(buf, "%s\n", udev->name); \
90+
usb_unlock_device(udev); \
91+
return retval; \
8892
} \
8993
static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
9094

drivers/usb/core/usb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ MODULE_PARM_DESC(autosuspend, "default autosuspend delay");
6666
/**
6767
* usb_find_alt_setting() - Given a configuration, find the alternate setting
6868
* for the given interface.
69-
* @config - the configuration to search (not necessarily the current config).
70-
* @iface_num - interface number to search in
71-
* @alt_num - alternate interface setting number to search for.
69+
* @config: the configuration to search (not necessarily the current config).
70+
* @iface_num: interface number to search in
71+
* @alt_num: alternate interface setting number to search for.
7272
*
7373
* Search the configuration's interface cache for the given alt setting.
7474
*/

drivers/usb/early/ehci-dbgp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ int dbgp_external_startup(void)
613613
}
614614
EXPORT_SYMBOL_GPL(dbgp_external_startup);
615615

616-
static int __init ehci_reset_port(int port)
616+
static int ehci_reset_port(int port)
617617
{
618618
u32 portsc;
619619
u32 delay_time, delay;

drivers/usb/gadget/audio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static int __init audio_bind(struct usb_composite_dev *cdev)
158158

159159
static int __exit audio_unbind(struct usb_composite_dev *cdev)
160160
{
161+
gaudio_cleanup();
161162
return 0;
162163
}
163164

drivers/usb/gadget/f_audio.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,16 @@ static struct usb_interface_descriptor ac_interface_desc __initdata = {
5656
DECLARE_UAC_AC_HEADER_DESCRIPTOR(2);
5757

5858
#define UAC_DT_AC_HEADER_LENGTH UAC_DT_AC_HEADER_SIZE(F_AUDIO_NUM_INTERFACES)
59+
/* 1 input terminal, 1 output terminal and 1 feature unit */
60+
#define UAC_DT_TOTAL_LENGTH (UAC_DT_AC_HEADER_LENGTH + UAC_DT_INPUT_TERMINAL_SIZE \
61+
+ UAC_DT_OUTPUT_TERMINAL_SIZE + UAC_DT_FEATURE_UNIT_SIZE(0))
5962
/* B.3.2 Class-Specific AC Interface Descriptor */
6063
static struct uac_ac_header_descriptor_2 ac_header_desc = {
6164
.bLength = UAC_DT_AC_HEADER_LENGTH,
6265
.bDescriptorType = USB_DT_CS_INTERFACE,
6366
.bDescriptorSubtype = UAC_HEADER,
6467
.bcdADC = __constant_cpu_to_le16(0x0100),
65-
.wTotalLength = __constant_cpu_to_le16(UAC_DT_AC_HEADER_LENGTH),
68+
.wTotalLength = __constant_cpu_to_le16(UAC_DT_TOTAL_LENGTH),
6669
.bInCollection = F_AUDIO_NUM_INTERFACES,
6770
.baInterfaceNr = {
6871
[0] = F_AUDIO_AC_INTERFACE,
@@ -252,12 +255,12 @@ static struct f_audio_buf *f_audio_buffer_alloc(int buf_size)
252255

253256
copy_buf = kzalloc(sizeof *copy_buf, GFP_ATOMIC);
254257
if (!copy_buf)
255-
return (struct f_audio_buf *)-ENOMEM;
258+
return ERR_PTR(-ENOMEM);
256259

257260
copy_buf->buf = kzalloc(buf_size, GFP_ATOMIC);
258261
if (!copy_buf->buf) {
259262
kfree(copy_buf);
260-
return (struct f_audio_buf *)-ENOMEM;
263+
return ERR_PTR(-ENOMEM);
261264
}
262265

263266
return copy_buf;
@@ -332,7 +335,7 @@ static int f_audio_out_ep_complete(struct usb_ep *ep, struct usb_request *req)
332335
list_add_tail(&copy_buf->list, &audio->play_queue);
333336
schedule_work(&audio->playback_work);
334337
copy_buf = f_audio_buffer_alloc(audio_buf_size);
335-
if (copy_buf < 0)
338+
if (IS_ERR(copy_buf))
336339
return -ENOMEM;
337340
}
338341

@@ -576,6 +579,8 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
576579
usb_ep_enable(out_ep, audio->out_desc);
577580
out_ep->driver_data = audio;
578581
audio->copy_buf = f_audio_buffer_alloc(audio_buf_size);
582+
if (IS_ERR(audio->copy_buf))
583+
return -ENOMEM;
579584

580585
/*
581586
* allocate a bunch of read buffers
@@ -787,7 +792,7 @@ int __init audio_bind_config(struct usb_configuration *c)
787792
return status;
788793

789794
add_fail:
790-
gaudio_cleanup(&audio->card);
795+
gaudio_cleanup();
791796
setup_fail:
792797
kfree(audio);
793798
return status;

0 commit comments

Comments
 (0)