aboutsummaryrefslogtreecommitdiffstats
path: root/usb
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2005-11-29 13:44:15 -0800
committerGreg Kroah-Hartman <gregkh@suse.de>2005-11-29 13:44:15 -0800
commitb61bf52dd14ca81e917ea312778bcd0e44964f00 (patch)
treee98d1aac71b6bbe0bc104d1cf422ae9bfa982059 /usb
parent63a3d8031a84a3c926149088e8b5051d5da8047e (diff)
downloadpatches-b61bf52dd14ca81e917ea312778bcd0e44964f00.tar.gz
usb patches added
Diffstat (limited to 'usb')
-rw-r--r--usb/drivers-usb-misc-sisusbvga-sisusb.c-remove-dead-code.patch40
-rw-r--r--usb/usb-don-t-assume-root-hub-resume-succeeds.patch34
-rw-r--r--usb/usb-gadget-dummy_hcd-updates-to-hcd-state.patch118
-rw-r--r--usb/usb-gadget-file_storage-remove-volatile-declarations.patch235
4 files changed, 427 insertions, 0 deletions
diff --git a/usb/drivers-usb-misc-sisusbvga-sisusb.c-remove-dead-code.patch b/usb/drivers-usb-misc-sisusbvga-sisusb.c-remove-dead-code.patch
new file mode 100644
index 00000000000000..e22a99227fd57c
--- /dev/null
+++ b/usb/drivers-usb-misc-sisusbvga-sisusb.c-remove-dead-code.patch
@@ -0,0 +1,40 @@
+From bunk@stusta.de Tue Nov 29 05:03:48 2005
+Date: Tue, 29 Nov 2005 14:01:55 +0100
+From: Adrian Bunk <bunk@stusta.de>
+To: Greg KH <greg@kroah.com>
+Cc: gregkh@suse.de, Thomas Winischhofer <thomas@winischhofer.net>
+Subject: [2.6 patch] drivers/usb/misc/sisusbvga/sisusb.c: remove dead code
+Message-ID: <20051129130155.GH31395@stusta.de>
+Content-Disposition: inline
+
+The Coverity checker found this dead code.
+
+Signed-off-by: Adrian Bunk <bunk@stusta.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/usb/misc/sisusbvga/sisusb.c | 6 ------
+ 1 file changed, 6 deletions(-)
+
+--- gregkh-2.6.orig/drivers/usb/misc/sisusbvga/sisusb.c
++++ gregkh-2.6/drivers/usb/misc/sisusbvga/sisusb.c
+@@ -863,9 +863,6 @@ static int sisusb_write_mem_bulk(struct
+
+ switch (length) {
+
+- case 0:
+- return ret;
+-
+ case 1:
+ if (userbuffer) {
+ if (get_user(swap8, (u8 __user *)userbuffer))
+@@ -1221,9 +1218,6 @@ static int sisusb_read_mem_bulk(struct s
+
+ switch (length) {
+
+- case 0:
+- return ret;
+-
+ case 1:
+
+ ret |= sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM,
diff --git a/usb/usb-don-t-assume-root-hub-resume-succeeds.patch b/usb/usb-don-t-assume-root-hub-resume-succeeds.patch
new file mode 100644
index 00000000000000..cf270812e49d0f
--- /dev/null
+++ b/usb/usb-don-t-assume-root-hub-resume-succeeds.patch
@@ -0,0 +1,34 @@
+From stern@rowland.harvard.edu Tue Nov 29 09:17:12 2005
+Date: Tue, 29 Nov 2005 12:13:31 -0500 (EST)
+From: Alan Stern <stern@rowland.harvard.edu>
+To: Greg KH <greg@kroah.com>
+Subject: USB: Don't assume root-hub resume succeeds
+Message-ID: <Pine.LNX.4.44L0.0511291208260.4602-100000@iolanthe.rowland.org>
+
+This patch (as614) makes a small change to the part of the hub driver
+responsible for remote wakeup of root hubs. When these wakeups occur
+the driver is suspended, and in case the resume fails the driver should
+remain suspended -- it shouldn't try to proceed with its normal
+processing.
+
+This will hardly ever matter in normal use, but it did crop up while I
+was debugging a different problem.
+
+Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/usb/core/hub.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- gregkh-2.6.orig/drivers/usb/core/hub.c
++++ gregkh-2.6/drivers/usb/core/hub.c
+@@ -2697,6 +2697,8 @@ static void hub_events(void)
+ if (i) {
+ dpm_runtime_resume(&hdev->dev);
+ dpm_runtime_resume(&intf->dev);
++ usb_put_intf(intf);
++ continue;
+ }
+
+ /* Lock the device, then check to see if we were
diff --git a/usb/usb-gadget-dummy_hcd-updates-to-hcd-state.patch b/usb/usb-gadget-dummy_hcd-updates-to-hcd-state.patch
new file mode 100644
index 00000000000000..ef26daec330ab3
--- /dev/null
+++ b/usb/usb-gadget-dummy_hcd-updates-to-hcd-state.patch
@@ -0,0 +1,118 @@
+From stern@rowland.harvard.edu Tue Nov 29 09:11:47 2005
+Date: Tue, 29 Nov 2005 12:08:15 -0500 (EST)
+From: Alan Stern <stern@rowland.harvard.edu>
+To: Greg KH <greg@kroah.com>
+Subject: USB Gadget: dummy_hcd: updates to hcd->state
+Message-ID: <Pine.LNX.4.44L0.0511291204270.4602-100000@iolanthe.rowland.org>
+
+This patch (as613) moves the updates to hcd->state in the dummy_hcd
+driver to where they now belong. It also uses the new
+HC_FLAG_HW_ACCESSIBLE flag in a way that simulates a real PCI
+controller, and it adds checks for attempts to resume the bus while the
+controller is suspended or to suspend the controller while the bus is
+active.
+
+Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/usb/gadget/dummy_hcd.c | 43 +++++++++++++++++++++++++++++------------
+ 1 file changed, 31 insertions(+), 12 deletions(-)
+
+--- gregkh-2.6.orig/drivers/usb/gadget/dummy_hcd.c
++++ gregkh-2.6/drivers/usb/gadget/dummy_hcd.c
+@@ -1576,7 +1576,7 @@ static int dummy_hub_status (struct usb_
+ dum = hcd_to_dummy (hcd);
+
+ spin_lock_irqsave (&dum->lock, flags);
+- if (hcd->state != HC_STATE_RUNNING)
++ if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))
+ goto done;
+
+ if (dum->resuming && time_after_eq (jiffies, dum->re_timeout)) {
+@@ -1623,7 +1623,7 @@ static int dummy_hub_control (
+ int retval = 0;
+ unsigned long flags;
+
+- if (hcd->state != HC_STATE_RUNNING)
++ if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))
+ return -ETIMEDOUT;
+
+ dum = hcd_to_dummy (hcd);
+@@ -1756,9 +1756,12 @@ static int dummy_bus_suspend (struct usb
+ {
+ struct dummy *dum = hcd_to_dummy (hcd);
+
++ dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__);
++
+ spin_lock_irq (&dum->lock);
+ dum->rh_state = DUMMY_RH_SUSPENDED;
+ set_link_state (dum);
++ hcd->state = HC_STATE_SUSPENDED;
+ spin_unlock_irq (&dum->lock);
+ return 0;
+ }
+@@ -1766,14 +1769,23 @@ static int dummy_bus_suspend (struct usb
+ static int dummy_bus_resume (struct usb_hcd *hcd)
+ {
+ struct dummy *dum = hcd_to_dummy (hcd);
++ int rc = 0;
++
++ dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__);
+
+ spin_lock_irq (&dum->lock);
+- dum->rh_state = DUMMY_RH_RUNNING;
+- set_link_state (dum);
+- if (!list_empty(&dum->urbp_list))
+- mod_timer (&dum->timer, jiffies);
++ if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
++ dev_warn (&hcd->self.root_hub->dev, "HC isn't running!\n");
++ rc = -ENODEV;
++ } else {
++ dum->rh_state = DUMMY_RH_RUNNING;
++ set_link_state (dum);
++ if (!list_empty(&dum->urbp_list))
++ mod_timer (&dum->timer, jiffies);
++ hcd->state = HC_STATE_RUNNING;
++ }
+ spin_unlock_irq (&dum->lock);
+- return 0;
++ return rc;
+ }
+
+ /*-------------------------------------------------------------------------*/
+@@ -1933,12 +1945,19 @@ static int dummy_hcd_remove (struct plat
+ static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state)
+ {
+ struct usb_hcd *hcd;
++ struct dummy *dum;
++ int rc = 0;
+
+ dev_dbg (&pdev->dev, "%s\n", __FUNCTION__);
+- hcd = platform_get_drvdata (pdev);
+
+- hcd->state = HC_STATE_SUSPENDED;
+- return 0;
++ hcd = platform_get_drvdata (pdev);
++ dum = hcd_to_dummy (hcd);
++ if (dum->rh_state == DUMMY_RH_RUNNING) {
++ dev_warn(&pdev->dev, "Root hub isn't suspended!\n");
++ rc = -EBUSY;
++ } else
++ clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
++ return rc;
+ }
+
+ static int dummy_hcd_resume (struct platform_device *pdev)
+@@ -1946,9 +1965,9 @@ static int dummy_hcd_resume (struct plat
+ struct usb_hcd *hcd;
+
+ dev_dbg (&pdev->dev, "%s\n", __FUNCTION__);
+- hcd = platform_get_drvdata (pdev);
+- hcd->state = HC_STATE_RUNNING;
+
++ hcd = platform_get_drvdata (pdev);
++ set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+ usb_hcd_poll_rh_status (hcd);
+ return 0;
+ }
diff --git a/usb/usb-gadget-file_storage-remove-volatile-declarations.patch b/usb/usb-gadget-file_storage-remove-volatile-declarations.patch
new file mode 100644
index 00000000000000..1a4bdeff246baf
--- /dev/null
+++ b/usb/usb-gadget-file_storage-remove-volatile-declarations.patch
@@ -0,0 +1,235 @@
+From stern@rowland.harvard.edu Tue Nov 29 09:06:21 2005
+Date: Tue, 29 Nov 2005 12:04:24 -0500 (EST)
+From: Alan Stern <stern@rowland.harvard.edu>
+To: Greg KH <greg@kroah.com>
+cc: Pavel Machek <pavel@ucw.cz>
+Subject: USB Gadget: file_storage: remove "volatile" declarations
+Message-ID: <Pine.LNX.4.44L0.0511291155540.4602-100000@iolanthe.rowland.org>
+
+This patch (as612) removes the "volatile" declarations from the
+file-storage gadget. It turns out that they aren't needed for anything
+much; adding a few memory barriers does a sufficient job.
+
+The patch also removes a wait_queue. Not much point having a queue when
+only one task is ever going to be on it!
+
+Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/usb/gadget/file_storage.c | 59 ++++++++++++++++++++++++--------------
+ 1 file changed, 38 insertions(+), 21 deletions(-)
+
+--- gregkh-2.6.orig/drivers/usb/gadget/file_storage.c
++++ gregkh-2.6/drivers/usb/gadget/file_storage.c
+@@ -239,7 +239,6 @@
+ #include <linux/string.h>
+ #include <linux/suspend.h>
+ #include <linux/utsname.h>
+-#include <linux/wait.h>
+
+ #include <linux/usb_ch9.h>
+ #include <linux/usb_gadget.h>
+@@ -251,7 +250,7 @@
+
+ #define DRIVER_DESC "File-backed Storage Gadget"
+ #define DRIVER_NAME "g_file_storage"
+-#define DRIVER_VERSION "20 October 2004"
++#define DRIVER_VERSION "28 November 2005"
+
+ static const char longname[] = DRIVER_DESC;
+ static const char shortname[] = DRIVER_NAME;
+@@ -588,7 +587,7 @@ enum fsg_buffer_state {
+ struct fsg_buffhd {
+ void *buf;
+ dma_addr_t dma;
+- volatile enum fsg_buffer_state state;
++ enum fsg_buffer_state state;
+ struct fsg_buffhd *next;
+
+ /* The NetChip 2280 is faster, and handles some protocol faults
+@@ -597,9 +596,9 @@ struct fsg_buffhd {
+ unsigned int bulk_out_intended_length;
+
+ struct usb_request *inreq;
+- volatile int inreq_busy;
++ int inreq_busy;
+ struct usb_request *outreq;
+- volatile int outreq_busy;
++ int outreq_busy;
+ };
+
+ enum fsg_state {
+@@ -637,11 +636,11 @@ struct fsg_dev {
+
+ struct usb_ep *ep0; // Handy copy of gadget->ep0
+ struct usb_request *ep0req; // For control responses
+- volatile unsigned int ep0_req_tag;
++ unsigned int ep0_req_tag;
+ const char *ep0req_name;
+
+ struct usb_request *intreq; // For interrupt responses
+- volatile int intreq_busy;
++ int intreq_busy;
+ struct fsg_buffhd *intr_buffhd;
+
+ unsigned int bulk_out_maxpacket;
+@@ -671,7 +670,6 @@ struct fsg_dev {
+ struct fsg_buffhd *next_buffhd_to_drain;
+ struct fsg_buffhd buffhds[NUM_BUFFERS];
+
+- wait_queue_head_t thread_wqh;
+ int thread_wakeup_needed;
+ struct completion thread_notifier;
+ struct task_struct *thread_task;
+@@ -1076,11 +1074,13 @@ static int populate_config_buf(struct us
+
+ /* These routines may be called in process context or in_irq */
+
++/* Caller must hold fsg->lock */
+ static void wakeup_thread(struct fsg_dev *fsg)
+ {
+ /* Tell the main thread that something has happened */
+ fsg->thread_wakeup_needed = 1;
+- wake_up_all(&fsg->thread_wqh);
++ if (fsg->thread_task)
++ wake_up_process(fsg->thread_task);
+ }
+
+
+@@ -1167,11 +1167,12 @@ static void bulk_in_complete(struct usb_
+ usb_ep_fifo_flush(ep);
+
+ /* Hold the lock while we update the request and buffer states */
++ smp_wmb();
+ spin_lock(&fsg->lock);
+ bh->inreq_busy = 0;
+ bh->state = BUF_STATE_EMPTY;
+- spin_unlock(&fsg->lock);
+ wakeup_thread(fsg);
++ spin_unlock(&fsg->lock);
+ }
+
+ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
+@@ -1188,11 +1189,12 @@ static void bulk_out_complete(struct usb
+ usb_ep_fifo_flush(ep);
+
+ /* Hold the lock while we update the request and buffer states */
++ smp_wmb();
+ spin_lock(&fsg->lock);
+ bh->outreq_busy = 0;
+ bh->state = BUF_STATE_FULL;
+- spin_unlock(&fsg->lock);
+ wakeup_thread(fsg);
++ spin_unlock(&fsg->lock);
+ }
+
+
+@@ -1209,11 +1211,12 @@ static void intr_in_complete(struct usb_
+ usb_ep_fifo_flush(ep);
+
+ /* Hold the lock while we update the request and buffer states */
++ smp_wmb();
+ spin_lock(&fsg->lock);
+ fsg->intreq_busy = 0;
+ bh->state = BUF_STATE_EMPTY;
+- spin_unlock(&fsg->lock);
+ wakeup_thread(fsg);
++ spin_unlock(&fsg->lock);
+ }
+
+ #else
+@@ -1264,8 +1267,8 @@ static void received_cbi_adsc(struct fsg
+ fsg->cbbuf_cmnd_size = req->actual;
+ memcpy(fsg->cbbuf_cmnd, req->buf, fsg->cbbuf_cmnd_size);
+
+- spin_unlock(&fsg->lock);
+ wakeup_thread(fsg);
++ spin_unlock(&fsg->lock);
+ }
+
+ #else
+@@ -1517,8 +1520,8 @@ static int fsg_setup(struct usb_gadget *
+
+ /* Use this for bulk or interrupt transfers, not ep0 */
+ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
+- struct usb_request *req, volatile int *pbusy,
+- volatile enum fsg_buffer_state *state)
++ struct usb_request *req, int *pbusy,
++ enum fsg_buffer_state *state)
+ {
+ int rc;
+
+@@ -1526,8 +1529,11 @@ static void start_transfer(struct fsg_de
+ dump_msg(fsg, "bulk-in", req->buf, req->length);
+ else if (ep == fsg->intr_in)
+ dump_msg(fsg, "intr-in", req->buf, req->length);
++
++ spin_lock_irq(&fsg->lock);
+ *pbusy = 1;
+ *state = BUF_STATE_BUSY;
++ spin_unlock_irq(&fsg->lock);
+ rc = usb_ep_queue(ep, req, GFP_KERNEL);
+ if (rc != 0) {
+ *pbusy = 0;
+@@ -1547,14 +1553,23 @@ static void start_transfer(struct fsg_de
+
+ static int sleep_thread(struct fsg_dev *fsg)
+ {
+- int rc;
++ int rc = 0;
+
+ /* Wait until a signal arrives or we are woken up */
+- rc = wait_event_interruptible(fsg->thread_wqh,
+- fsg->thread_wakeup_needed);
++ for (;;) {
++ try_to_freeze();
++ set_current_state(TASK_INTERRUPTIBLE);
++ if (signal_pending(current)) {
++ rc = -EINTR;
++ break;
++ }
++ if (fsg->thread_wakeup_needed)
++ break;
++ schedule();
++ }
++ __set_current_state(TASK_RUNNING);
+ fsg->thread_wakeup_needed = 0;
+- try_to_freeze();
+- return (rc ? -EINTR : 0);
++ return rc;
+ }
+
+
+@@ -1791,6 +1806,7 @@ static int do_write(struct fsg_dev *fsg)
+ if (bh->state == BUF_STATE_EMPTY && !get_some_more)
+ break; // We stopped early
+ if (bh->state == BUF_STATE_FULL) {
++ smp_rmb();
+ fsg->next_buffhd_to_drain = bh->next;
+ bh->state = BUF_STATE_EMPTY;
+
+@@ -2359,6 +2375,7 @@ static int throw_away_data(struct fsg_de
+
+ /* Throw away the data in a filled buffer */
+ if (bh->state == BUF_STATE_FULL) {
++ smp_rmb();
+ bh->state = BUF_STATE_EMPTY;
+ fsg->next_buffhd_to_drain = bh->next;
+
+@@ -3024,6 +3041,7 @@ static int get_next_command(struct fsg_d
+ if ((rc = sleep_thread(fsg)) != 0)
+ return rc;
+ }
++ smp_rmb();
+ rc = received_cbw(fsg, bh);
+ bh->state = BUF_STATE_EMPTY;
+
+@@ -4072,7 +4090,6 @@ static int __init fsg_alloc(void)
+ spin_lock_init(&fsg->lock);
+ init_rwsem(&fsg->filesem);
+ kref_init(&fsg->ref);
+- init_waitqueue_head(&fsg->thread_wqh);
+ init_completion(&fsg->thread_notifier);
+
+ the_fsg = fsg;