aboutsummaryrefslogtreecommitdiffstats
path: root/usb.current
diff options
authorGreg Kroah-Hartman <gregkh@suse.de>2009-12-17 06:55:11 -0800
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-17 06:55:11 -0800
commitbfab1472c48d82a664011be0b5b2464f5feda031 (patch)
treec04ed7c52f5cc546d197a36db9dc03c130ef19d8 /usb.current
parente0f8afebdc25db35df1b3ed71627416ef2015444 (diff)
downloadpatches-bfab1472c48d82a664011be0b5b2464f5feda031.tar.gz
usb and driver core patches
Diffstat (limited to 'usb.current')
-rw-r--r--usb.current/usb-fix-bugs-in-usb_-de-authorize_device.patch131
-rw-r--r--usb.current/usb-gadget-use-err_ptr-is_err.patch67
-rw-r--r--usb.current/usb-power-management-documentation-update.patch133
-rw-r--r--usb.current/usb-rename-usb_configure_device.patch110
4 files changed, 441 insertions, 0 deletions
diff --git a/usb.current/usb-fix-bugs-in-usb_-de-authorize_device.patch b/usb.current/usb-fix-bugs-in-usb_-de-authorize_device.patch
new file mode 100644
index 00000000000000..6b29aeaed5c89b
--- /dev/null
+++ b/usb.current/usb-fix-bugs-in-usb_-de-authorize_device.patch
@@ -0,0 +1,131 @@
+From stern@rowland.harvard.edu Thu Dec 17 06:46:39 2009
+From: Alan Stern <stern@rowland.harvard.edu>
+Date: Tue, 8 Dec 2009 15:54:44 -0500 (EST)
+Subject: [PATCH 2/2] USB: fix bugs in usb_(de)authorize_device
+To: Greg KH <greg@kroah.com>
+Cc: Inaky Perez-Gonzalez <inaky@linux.intel.com>, David Vrabel <david.vrabel@csr.com>
+Message-ID: <Pine.LNX.4.44L0.0912081550420.3046-100000@iolanthe.rowland.org>
+
+
+This patch (as1315) fixes some bugs in the USB core authorization
+code:
+
+ usb_deauthorize_device() should deallocate the device strings
+ instead of leaking them, and it should invoke
+ usb_destroy_configuration() (which does proper reference
+ counting) instead of freeing the config information directly.
+
+ usb_authorize_device() shouldn't change the device strings
+ until it knows that the authorization will succeed, and it should
+ autosuspend the device at the end (having autoresumed the
+ device at the start).
+
+ Because the device strings can be changed, the sysfs routines
+ to display the strings must protect the string pointers by
+ locking the device.
+
+Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
+CC: Inaky Perez-Gonzalez <inaky@linux.intel.com>
+Acked-by: David Vrabel <david.vrabel@csr.com>
+Cc: stable <stable@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ drivers/usb/core/hub.c | 32 ++++++++++++++++++++------------
+ drivers/usb/core/sysfs.c | 6 +++++-
+ 2 files changed, 25 insertions(+), 13 deletions(-)
+
+--- a/drivers/usb/core/hub.c
++++ b/drivers/usb/core/hub.c
+@@ -1849,21 +1849,23 @@ fail:
+ */
+ int usb_deauthorize_device(struct usb_device *usb_dev)
+ {
+- unsigned cnt;
+ usb_lock_device(usb_dev);
+ if (usb_dev->authorized == 0)
+ goto out_unauthorized;
++
+ usb_dev->authorized = 0;
+ usb_set_configuration(usb_dev, -1);
++
++ kfree(usb_dev->product);
+ usb_dev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
++ kfree(usb_dev->manufacturer);
+ usb_dev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
++ kfree(usb_dev->serial);
+ usb_dev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
+- kfree(usb_dev->config);
+- usb_dev->config = NULL;
+- for (cnt = 0; cnt < usb_dev->descriptor.bNumConfigurations; cnt++)
+- kfree(usb_dev->rawdescriptors[cnt]);
++
++ usb_destroy_configuration(usb_dev);
+ usb_dev->descriptor.bNumConfigurations = 0;
+- kfree(usb_dev->rawdescriptors);
++
+ out_unauthorized:
+ usb_unlock_device(usb_dev);
+ return 0;
+@@ -1873,15 +1875,11 @@ out_unauthorized:
+ int usb_authorize_device(struct usb_device *usb_dev)
+ {
+ int result = 0, c;
++
+ usb_lock_device(usb_dev);
+ if (usb_dev->authorized == 1)
+ goto out_authorized;
+- kfree(usb_dev->product);
+- usb_dev->product = NULL;
+- kfree(usb_dev->manufacturer);
+- usb_dev->manufacturer = NULL;
+- kfree(usb_dev->serial);
+- usb_dev->serial = NULL;
++
+ result = usb_autoresume_device(usb_dev);
+ if (result < 0) {
+ dev_err(&usb_dev->dev,
+@@ -1894,6 +1892,14 @@ int usb_authorize_device(struct usb_devi
+ "authorization: %d\n", result);
+ goto error_device_descriptor;
+ }
++
++ kfree(usb_dev->product);
++ usb_dev->product = NULL;
++ kfree(usb_dev->manufacturer);
++ usb_dev->manufacturer = NULL;
++ kfree(usb_dev->serial);
++ usb_dev->serial = NULL;
++
+ usb_dev->authorized = 1;
+ result = usb_enumerate_device(usb_dev);
+ if (result < 0)
+@@ -1912,8 +1918,10 @@ int usb_authorize_device(struct usb_devi
+ }
+ }
+ dev_info(&usb_dev->dev, "authorized to connect\n");
++
+ error_enumerate:
+ error_device_descriptor:
++ usb_autosuspend_device(usb_dev);
+ error_autoresume:
+ out_authorized:
+ usb_unlock_device(usb_dev); // complements locktree
+--- a/drivers/usb/core/sysfs.c
++++ b/drivers/usb/core/sysfs.c
+@@ -82,9 +82,13 @@ static ssize_t show_##name(struct devic
+ struct device_attribute *attr, char *buf) \
+ { \
+ struct usb_device *udev; \
++ int retval; \
+ \
+ udev = to_usb_device(dev); \
+- return sprintf(buf, "%s\n", udev->name); \
++ usb_lock_device(udev); \
++ retval = sprintf(buf, "%s\n", udev->name); \
++ usb_unlock_device(udev); \
++ return retval; \
+ } \
+ static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
+
diff --git a/usb.current/usb-gadget-use-err_ptr-is_err.patch b/usb.current/usb-gadget-use-err_ptr-is_err.patch
new file mode 100644
index 00000000000000..a495eb9be81233
--- /dev/null
+++ b/usb.current/usb-gadget-use-err_ptr-is_err.patch
@@ -0,0 +1,67 @@
+From julia@diku.dk Thu Dec 17 06:47:19 2009
+From: Julia Lawall <julia@diku.dk>
+Date: Wed, 9 Dec 2009 14:23:32 +0100 (CET)
+Subject: USB: gadget: Use ERR_PTR/IS_ERR
+To: David Brownell <dbrownell@users.sourceforge.net>, Greg Kroah-Hartman <gregkh@suse.de>, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
+Message-ID: <Pine.LNX.4.64.0912091422350.27028@ask.diku.dk>
+
+
+From: Julia Lawall <julia@diku.dk>
+
+Use ERR_PTR and IS_ERR rather than mixing integers and pointers.
+
+The semantic match that finds this problem is as follows:
+(http://coccinelle.lip6.fr/)
+
+// <smpl>
+@@
+expression *E;
+@@
+
+* E < 0
+// </smpl>
+
+Signed-off-by: Julia Lawall <julia@diku.dk>
+Acked-by: David Brownell <dbrownell@users.sourceforge.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ drivers/usb/gadget/f_audio.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+--- a/drivers/usb/gadget/f_audio.c
++++ b/drivers/usb/gadget/f_audio.c
+@@ -252,12 +252,12 @@ static struct f_audio_buf *f_audio_buffe
+
+ copy_buf = kzalloc(sizeof *copy_buf, GFP_ATOMIC);
+ if (!copy_buf)
+- return (struct f_audio_buf *)-ENOMEM;
++ return ERR_PTR(-ENOMEM);
+
+ copy_buf->buf = kzalloc(buf_size, GFP_ATOMIC);
+ if (!copy_buf->buf) {
+ kfree(copy_buf);
+- return (struct f_audio_buf *)-ENOMEM;
++ return ERR_PTR(-ENOMEM);
+ }
+
+ return copy_buf;
+@@ -332,7 +332,7 @@ static int f_audio_out_ep_complete(struc
+ list_add_tail(&copy_buf->list, &audio->play_queue);
+ schedule_work(&audio->playback_work);
+ copy_buf = f_audio_buffer_alloc(audio_buf_size);
+- if (copy_buf < 0)
++ if (IS_ERR(copy_buf))
+ return -ENOMEM;
+ }
+
+@@ -576,6 +576,8 @@ static int f_audio_set_alt(struct usb_fu
+ usb_ep_enable(out_ep, audio->out_desc);
+ out_ep->driver_data = audio;
+ audio->copy_buf = f_audio_buffer_alloc(audio_buf_size);
++ if (IS_ERR(audio->copy_buf))
++ return -ENOMEM;
+
+ /*
+ * allocate a bunch of read buffers
diff --git a/usb.current/usb-power-management-documentation-update.patch b/usb.current/usb-power-management-documentation-update.patch
new file mode 100644
index 00000000000000..03bc849bd57b0d
--- /dev/null
+++ b/usb.current/usb-power-management-documentation-update.patch
@@ -0,0 +1,133 @@
+From stern@rowland.harvard.edu Thu Dec 17 06:45:19 2009
+From: Alan Stern <stern@rowland.harvard.edu>
+Date: Tue, 8 Dec 2009 15:49:48 -0500 (EST)
+Subject: [PATCH] USB: power management documentation update
+To: Greg KH <greg@kroah.com>
+Message-ID: <Pine.LNX.4.44L0.0912081544390.3046-100000@iolanthe.rowland.org>
+
+
+This patch (as1313) updates the documentation concerning USB power
+management.
+
+Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ Documentation/ABI/testing/sysfs-bus-usb | 18 +++++++-------
+ Documentation/usb/power-management.txt | 41 +++++++++++---------------------
+ 2 files changed, 25 insertions(+), 34 deletions(-)
+
+--- a/Documentation/ABI/testing/sysfs-bus-usb
++++ b/Documentation/ABI/testing/sysfs-bus-usb
+@@ -21,25 +21,27 @@ Contact: Alan Stern <stern@rowland.harva
+ Description:
+ Each USB device directory will contain a file named
+ power/level. This file holds a power-level setting for
+- the device, one of "on", "auto", or "suspend".
++ the device, either "on" or "auto".
+
+ "on" means that the device is not allowed to autosuspend,
+ although normal suspends for system sleep will still
+ be honored. "auto" means the device will autosuspend
+ and autoresume in the usual manner, according to the
+- capabilities of its driver. "suspend" means the device
+- is forced into a suspended state and it will not autoresume
+- in response to I/O requests. However remote-wakeup requests
+- from the device may still be enabled (the remote-wakeup
+- setting is controlled separately by the power/wakeup
+- attribute).
++ capabilities of its driver.
+
+ During normal use, devices should be left in the "auto"
+- level. The other levels are meant for administrative uses.
++ level. The "on" level is meant for administrative uses.
+ If you want to suspend a device immediately but leave it
+ free to wake up in response to I/O requests, you should
+ write "0" to power/autosuspend.
+
++ Device not capable of proper suspend and resume should be
++ left in the "on" level. Although the USB spec requires
++ devices to support suspend/resume, many of them do not.
++ In fact so many don't that by default, the USB core
++ initializes all non-hub devices in the "on" level. Some
++ drivers may change this setting when they are bound.
++
+ What: /sys/bus/usb/devices/.../power/persist
+ Date: May 2007
+ KernelVersion: 2.6.23
+--- a/Documentation/usb/power-management.txt
++++ b/Documentation/usb/power-management.txt
+@@ -71,12 +71,10 @@ being accessed through sysfs, then it de
+ Forms of dynamic PM
+ -------------------
+
+-Dynamic suspends can occur in two ways: manual and automatic.
+-"Manual" means that the user has told the kernel to suspend a device,
+-whereas "automatic" means that the kernel has decided all by itself to
+-suspend a device. Automatic suspend is called "autosuspend" for
+-short. In general, a device won't be autosuspended unless it has been
+-idle for some minimum period of time, the so-called idle-delay time.
++Dynamic suspends occur when the kernel decides to suspend an idle
++device. This is called "autosuspend" for short. In general, a device
++won't be autosuspended unless it has been idle for some minimum period
++of time, the so-called idle-delay time.
+
+ Of course, nothing the kernel does on its own initiative should
+ prevent the computer or its devices from working properly. If a
+@@ -96,10 +94,11 @@ idle.
+ We can categorize power management events in two broad classes:
+ external and internal. External events are those triggered by some
+ agent outside the USB stack: system suspend/resume (triggered by
+-userspace), manual dynamic suspend/resume (also triggered by
+-userspace), and remote wakeup (triggered by the device). Internal
+-events are those triggered within the USB stack: autosuspend and
+-autoresume.
++userspace), manual dynamic resume (also triggered by userspace), and
++remote wakeup (triggered by the device). Internal events are those
++triggered within the USB stack: autosuspend and autoresume. Note that
++all dynamic suspend events are internal; external agents are not
++allowed to issue dynamic suspends.
+
+
+ The user interface for dynamic PM
+@@ -145,9 +144,9 @@ relevant attribute files are: wakeup, le
+ number of seconds the device should remain idle before
+ the kernel will autosuspend it (the idle-delay time).
+ The default is 2. 0 means to autosuspend as soon as
+- the device becomes idle, and -1 means never to
+- autosuspend. You can write a number to the file to
+- change the autosuspend idle-delay time.
++ the device becomes idle, and negative values mean
++ never to autosuspend. You can write a number to the
++ file to change the autosuspend idle-delay time.
+
+ Writing "-1" to power/autosuspend and writing "on" to power/level do
+ essentially the same thing -- they both prevent the device from being
+@@ -377,9 +376,9 @@ the device hasn't been idle for long eno
+ routine is automatically set up to carry out the operation when the
+ autosuspend idle-delay has expired.
+
+-Autoresume attempts also can fail. This will happen if power/level is
+-set to "suspend" or if the device doesn't manage to resume properly.
+-Unlike autosuspend, there's no delay for an autoresume.
++Autoresume attempts also can fail, although failure would mean that
++the device is no longer present or operating properly. Unlike
++autosuspend, there's no delay for an autoresume.
+
+
+ Other parts of the driver interface
+@@ -527,13 +526,3 @@ succeed, it may still remain active and
+ resume as soon as the system suspend is complete. Or the remote
+ wakeup may fail and get lost. Which outcome occurs depends on timing
+ and on the hardware and firmware design.
+-
+-More interestingly, a device might undergo a manual resume or
+-autoresume during system suspend. With current kernels this shouldn't
+-happen, because manual resumes must be initiated by userspace and
+-autoresumes happen in response to I/O requests, but all user processes
+-and I/O should be quiescent during a system suspend -- thanks to the
+-freezer. However there are plans to do away with the freezer, which
+-would mean these things would become possible. If and when this comes
+-about, the USB core will carefully arrange matters so that either type
+-of resume will block until the entire system has resumed.
diff --git a/usb.current/usb-rename-usb_configure_device.patch b/usb.current/usb-rename-usb_configure_device.patch
new file mode 100644
index 00000000000000..a8d64dadea1310
--- /dev/null
+++ b/usb.current/usb-rename-usb_configure_device.patch
@@ -0,0 +1,110 @@
+From stern@rowland.harvard.edu Thu Dec 17 06:46:08 2009
+From: Alan Stern <stern@rowland.harvard.edu>
+Date: Tue, 8 Dec 2009 15:50:41 -0500 (EST)
+Subject: USB: rename usb_configure_device
+To: Greg KH <greg@kroah.com>
+Message-ID: <Pine.LNX.4.44L0.0912081549510.3046-100000@iolanthe.rowland.org>
+
+
+This patch (as1314) renames usb_configure_device() and
+usb_configure_device_otg() in the hub driver. Neither name is
+appropriate because these routines enumerate devices, they don't
+configure them. That's handled by usb_choose_configuration() and
+usb_set_configuration().
+
+Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
+Cc: stable <stable@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/usb/core/hub.c | 26 +++++++++++++-------------
+ 1 file changed, 13 insertions(+), 13 deletions(-)
+
+--- a/drivers/usb/core/hub.c
++++ b/drivers/usb/core/hub.c
+@@ -1658,12 +1658,12 @@ static inline void announce_device(struc
+ #endif
+
+ /**
+- * usb_configure_device_otg - FIXME (usbcore-internal)
++ * usb_enumerate_device_otg - FIXME (usbcore-internal)
+ * @udev: newly addressed device (in ADDRESS state)
+ *
+- * Do configuration for On-The-Go devices
++ * Finish enumeration for On-The-Go devices
+ */
+-static int usb_configure_device_otg(struct usb_device *udev)
++static int usb_enumerate_device_otg(struct usb_device *udev)
+ {
+ int err = 0;
+
+@@ -1734,7 +1734,7 @@ fail:
+
+
+ /**
+- * usb_configure_device - Detect and probe device intfs/otg (usbcore-internal)
++ * usb_enumerate_device - Read device configs/intfs/otg (usbcore-internal)
+ * @udev: newly addressed device (in ADDRESS state)
+ *
+ * This is only called by usb_new_device() and usb_authorize_device()
+@@ -1745,7 +1745,7 @@ fail:
+ * the string descriptors, as they will be errored out by the device
+ * until it has been authorized.
+ */
+-static int usb_configure_device(struct usb_device *udev)
++static int usb_enumerate_device(struct usb_device *udev)
+ {
+ int err;
+
+@@ -1769,7 +1769,7 @@ static int usb_configure_device(struct u
+ udev->descriptor.iManufacturer);
+ udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
+ }
+- err = usb_configure_device_otg(udev);
++ err = usb_enumerate_device_otg(udev);
+ fail:
+ return err;
+ }
+@@ -1779,8 +1779,8 @@ fail:
+ * usb_new_device - perform initial device setup (usbcore-internal)
+ * @udev: newly addressed device (in ADDRESS state)
+ *
+- * This is called with devices which have been enumerated, but not yet
+- * configured. The device descriptor is available, but not descriptors
++ * This is called with devices which have been detected but not fully
++ * enumerated. The device descriptor is available, but not descriptors
+ * for any device configuration. The caller must have locked either
+ * the parent hub (if udev is a normal device) or else the
+ * 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 *ud
+ if (udev->parent)
+ usb_autoresume_device(udev->parent);
+
+- usb_detect_quirks(udev); /* Determine quirks */
+- err = usb_configure_device(udev); /* detect & probe dev/intfs */
++ usb_detect_quirks(udev);
++ err = usb_enumerate_device(udev); /* Read descriptors */
+ if (err < 0)
+ goto fail;
+ dev_dbg(&udev->dev, "udev %d, busnum %d, minor = %d\n",
+@@ -1895,9 +1895,9 @@ int usb_authorize_device(struct usb_devi
+ goto error_device_descriptor;
+ }
+ usb_dev->authorized = 1;
+- result = usb_configure_device(usb_dev);
++ result = usb_enumerate_device(usb_dev);
+ if (result < 0)
+- goto error_configure;
++ goto error_enumerate;
+ /* Choose and set the configuration. This registers the interfaces
+ * with the driver core and lets interface drivers bind to them.
+ */
+@@ -1912,7 +1912,7 @@ int usb_authorize_device(struct usb_devi
+ }
+ }
+ dev_info(&usb_dev->dev, "authorized to connect\n");
+-error_configure:
++error_enumerate:
+ error_device_descriptor:
+ error_autoresume:
+ out_authorized: