diff options
15 files changed, 1324 insertions, 2 deletions
@@ -61,6 +61,8 @@ tty/vt-clean-up-the-code-use-kernel-library.patch tty/serial-add-uart_cap_efr-and-uart_cap_sleep-flags-to-16c950-uarts-definition.patch tty/mrst_max3110-add-uart-driver-for-max3110-on-moorestown.patch tty/max3110-sanity-check-a-register.patch +tty/serial-replace-open-coded-mutex-with-a-real-mutex-in-mrst_max3110.c.patch +tty/serial-fix-wakup-races-in-the-mrst_max3110-driver.patch # tty bkl removal work tty/stallion-prune-lock_kernel-calls.patch @@ -96,6 +98,7 @@ tty/tty-implement-btm-as-mutex-instead-of-bkl.patch tty/tty-release-btm-while-sleeping-in-block_til_ready.patch tty/8250-fix-set_ldisc-operation.patch + ################################### # USB stuff for after 2.6.35 is out ################################### @@ -127,8 +130,18 @@ usb/revert-usb-adding-support-for-htc-smartphones-to-ipaq.patch usb/usb-gadget-langwell_udc.c-printk-needs-a-unsigned-long-long-cast-for-a-dma_t.patch usb/usb-conexant-fixed-spacing-and-brace-coding-style-issues.patch usb/usb-add-a-serial-number-parameter-to-g_file_storage-module.patch +usb/usb-atm-fixed-spacing-and-indentation-coding-style-issues.patch +usb/usb-bkl-remove-lock_kernel-in-usbfs-update_sb.patch +usb/usb-bkl-convert-usb_driver-ioctl-to-unlocked_ioctl.patch +usb/usb-bkl-remove-bkl-use-for-usb-serial-driver-probing.patch +usb/usb-bkl-remove-bkl-use-in-uhci-debug.patch +usb/usb-gadget-do-not-take-bkl-for-gadget-ops-ioctl.patch +usb/usb-mon-kill-bkl-usage.patch +usb/usb-gadget-g_mass_storage-static-data-instead-of-dynamic-allocation.patch +usb/usb-gadget-f_mass_storage-fsg_add-renamed-to-fsg_bind_config.patch +usb/usb-gadget-f_fs-functionfs_add-renamed-to-functionfs_bind_config.patch +usb/usb-gadget-composite-usb_string_ids_-functions-added.patch +usb/usb-gadget-f_fs-use-usb_string_ids_n.patch # staging stuff is now in the staging-next tree on git.kernel.org - - diff --git a/tty/serial-fix-wakup-races-in-the-mrst_max3110-driver.patch b/tty/serial-fix-wakup-races-in-the-mrst_max3110-driver.patch new file mode 100644 index 00000000000000..44de4ed4764898 --- /dev/null +++ b/tty/serial-fix-wakup-races-in-the-mrst_max3110-driver.patch @@ -0,0 +1,155 @@ +From alan@linux.intel.com Thu Jun 17 10:32:38 2010 +From: Arjan van de Ven <arjan@linux.intel.com> +Date: Thu, 17 Jun 2010 11:02:15 +0100 +Subject: serial: fix wakup races in the mrst_max3110 driver +To: greg@kroah.com, linux-serial@vger.kernel.org +Message-ID: <20100617100213.4379.16616.stgit@localhost.localdomain> + + +From: Arjan van de Ven <arjan@linux.intel.com> + +The mrst_max3110 driver had a set of unsafe wakeup sequences +along the following line: + +if (!atomic_read(&foo)) { + atomic_set(&foo, 1); + wake_up(worker_thread); +} +and the worker thread would do + +if (atomic_read(&foo)) { + do_work(); + atomic_set(&foo, 0); +} + +which can result in various missed wakups due to test-then-set races, +as well as due to clear-after-work instead of clear-before-work. + +This patch fixes these races by using the proper bit test-and-set operations, +and by doing clear-before-work. + +Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> +Signed-off-by: Alan Cox <alan@linux.intel.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/serial/mrst_max3110.c | 46 ++++++++++++++++-------------------------- + 1 file changed, 18 insertions(+), 28 deletions(-) + +--- a/drivers/serial/mrst_max3110.c ++++ b/drivers/serial/mrst_max3110.c +@@ -48,6 +48,10 @@ + + #define PR_FMT "mrst_max3110: " + ++#define UART_TX_NEEDED 1 ++#define CON_TX_NEEDED 2 ++#define BIT_IRQ_PENDING 3 ++ + struct uart_max3110 { + struct uart_port port; + struct spi_device *spi; +@@ -63,15 +67,13 @@ struct uart_max3110 { + u8 clock; + u8 parity, word_7bits; + +- atomic_t uart_tx_need; ++ unsigned long uart_flags; + + /* console related */ + struct circ_buf con_xmit; +- atomic_t con_tx_need; + + /* irq related */ + u16 irq; +- atomic_t irq_pending; + }; + + /* global data structure, may need be removed */ +@@ -176,10 +178,9 @@ static void serial_m3110_con_putchar(str + xmit->head = (xmit->head + 1) & (PAGE_SIZE - 1); + } + +- if (!atomic_read(&max->con_tx_need)) { +- atomic_set(&max->con_tx_need, 1); ++ ++ if (!test_and_set_bit(CON_TX_NEEDED, &max->uart_flags)) + wake_up_process(max->main_thread); +- } + } + + /* +@@ -318,10 +319,8 @@ static void serial_m3110_start_tx(struct + struct uart_max3110 *max = + container_of(port, struct uart_max3110, port); + +- if (!atomic_read(&max->uart_tx_need)) { +- atomic_set(&max->uart_tx_need, 1); ++ if (!test_and_set_bit(UART_TX_NEEDED, &max->uart_flags)) + wake_up_process(max->main_thread); +- } + } + + static void receive_chars(struct uart_max3110 *max, unsigned char *str, int len) +@@ -392,32 +391,23 @@ static int max3110_main_thread(void *_ma + pr_info(PR_FMT "start main thread\n"); + + do { +- wait_event_interruptible(*wq, (atomic_read(&max->irq_pending) || +- atomic_read(&max->con_tx_need) || +- atomic_read(&max->uart_tx_need)) || +- kthread_should_stop()); ++ wait_event_interruptible(*wq, max->uart_flags || kthread_should_stop()); + + mutex_lock(&max->thread_mutex); + +-#ifdef CONFIG_MRST_MAX3110_IRQ +- if (atomic_read(&max->irq_pending)) { ++ if (test_and_clear_bit(BIT_IRQ_PENDING, &max->uart_flags)) + max3110_console_receive(max); +- atomic_set(&max->irq_pending, 0); +- } +-#endif + + /* first handle console output */ +- if (atomic_read(&max->con_tx_need)) { ++ if (test_and_clear_bit(CON_TX_NEEDED, &max->uart_flags)) + send_circ_buf(max, xmit); +- atomic_set(&max->con_tx_need, 0); +- } + + /* handle uart output */ +- if (atomic_read(&max->uart_tx_need)) { ++ if (test_and_clear_bit(UART_TX_NEEDED, &max->uart_flags)) + transmit_char(max); +- atomic_set(&max->uart_tx_need, 0); +- } ++ + mutex_unlock(&max->thread_mutex); ++ + } while (!kthread_should_stop()); + + return ret; +@@ -430,10 +420,9 @@ static irqreturn_t serial_m3110_irq(int + + /* max3110's irq is a falling edge, not level triggered, + * so no need to disable the irq */ +- if (!atomic_read(&max->irq_pending)) { +- atomic_inc(&max->irq_pending); ++ if (!test_and_set_bit(BIT_IRQ_PENDING, &max->uart_flags)) + wake_up_process(max->main_thread); +- } ++ + return IRQ_HANDLED; + } + #else +@@ -753,7 +742,8 @@ static int serial_m3110_probe(struct spi + max->baud = 0; + + max->cur_conf = 0; +- atomic_set(&max->irq_pending, 0); ++ max->uart_flags = 0; ++ + /* Check if reading configuration register returns something sane */ + + res = RC_TAG; diff --git a/tty/serial-replace-open-coded-mutex-with-a-real-mutex-in-mrst_max3110.c.patch b/tty/serial-replace-open-coded-mutex-with-a-real-mutex-in-mrst_max3110.c.patch new file mode 100644 index 00000000000000..bc97764a0a9e78 --- /dev/null +++ b/tty/serial-replace-open-coded-mutex-with-a-real-mutex-in-mrst_max3110.c.patch @@ -0,0 +1,81 @@ +From alan@linux.intel.com Thu Jun 17 10:32:04 2010 +From: Arjan van de Ven <arjan@linux.intel.com> +Date: Thu, 17 Jun 2010 11:02:06 +0100 +Subject: serial: replace open coded mutex with a real mutex in mrst_max3110.c +To: greg@kroah.com, linux-serial@vger.kernel.org +Message-ID: <20100617100204.4379.5286.stgit@localhost.localdomain> + + +From: Arjan van de Ven <arjan@linux.intel.com> + +The mrst_max3110.c driver uses an open coded, non atomic variable +to create exclusion between two of its worker threads. More than that, +while the main thread does a proper set-work-clear sequence, +the other thread only does a test, with the result that no actual +exclusion is happening. + +this patch replaces this open coded variable with a proper mutex + +in addition, the 'lock' spinlock is removed from the per adapter structure, +the lock was only ever initialized but never used + +Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> +Signed-off-by: Alan Cox <alan@linux.intel.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/serial/mrst_max3110.c | 15 ++++++++------- + 1 file changed, 8 insertions(+), 7 deletions(-) + +--- a/drivers/serial/mrst_max3110.c ++++ b/drivers/serial/mrst_max3110.c +@@ -56,8 +56,7 @@ struct uart_max3110 { + wait_queue_head_t wq; + struct task_struct *main_thread; + struct task_struct *read_thread; +- int mthread_up; +- spinlock_t lock; ++ struct mutex thread_mutex;; + + u32 baud; + u16 cur_conf; +@@ -397,7 +396,8 @@ static int max3110_main_thread(void *_ma + atomic_read(&max->con_tx_need) || + atomic_read(&max->uart_tx_need)) || + kthread_should_stop()); +- max->mthread_up = 1; ++ ++ mutex_lock(&max->thread_mutex); + + #ifdef CONFIG_MRST_MAX3110_IRQ + if (atomic_read(&max->irq_pending)) { +@@ -417,7 +417,7 @@ static int max3110_main_thread(void *_ma + transmit_char(max); + atomic_set(&max->uart_tx_need, 0); + } +- max->mthread_up = 0; ++ mutex_unlock(&max->thread_mutex); + } while (!kthread_should_stop()); + + return ret; +@@ -444,8 +444,9 @@ static int max3110_read_thread(void *_ma + + pr_info(PR_FMT "start read thread\n"); + do { +- if (!max->mthread_up) +- max3110_console_receive(max); ++ mutex_lock(&max->thread_mutex); ++ max3110_console_receive(max); ++ mutex_unlock(&max->thread_mutex); + + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(HZ / 20); +@@ -745,7 +746,7 @@ static int serial_m3110_probe(struct spi + max->name = spi->modalias; /* use spi name as the name */ + max->irq = (u16)spi->irq; + +- spin_lock_init(&max->lock); ++ mutex_init(&max->thread_mutex); + + max->word_7bits = 0; + max->parity = 0; diff --git a/usb/usb-atm-fixed-spacing-and-indentation-coding-style-issues.patch b/usb/usb-atm-fixed-spacing-and-indentation-coding-style-issues.patch new file mode 100644 index 00000000000000..39160159f127cc --- /dev/null +++ b/usb/usb-atm-fixed-spacing-and-indentation-coding-style-issues.patch @@ -0,0 +1,141 @@ +From nikai@nikai.net Thu Jun 17 10:29:32 2010 +From: Nicolas Kaiser <nikai@nikai.net> +Date: Thu, 17 Jun 2010 11:55:49 +0200 +Subject: usb: atm: fixed spacing and indentation coding style issues +To: Greg Kroah-Hartman <gregkh@suse.de> +Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org +Message-ID: <20100617115549.4515e982@absol.kitzblitz> + + +Fixed spacing and indentation coding style issues. + +Signed-off-by: Nicolas Kaiser <nikai@nikai.net> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/usb/atm/usbatm.h | 22 +++++++++++----------- + drivers/usb/atm/xusbatm.c | 10 +++++----- + 2 files changed, 16 insertions(+), 16 deletions(-) + +--- a/drivers/usb/atm/usbatm.h ++++ b/drivers/usb/atm/usbatm.h +@@ -48,7 +48,7 @@ + dev_warn(&(instance)->usb_intf->dev, \ + "failed assertion '%s' at line %d", \ + __stringify(x), __LINE__); \ +- } while(0) ++ } while (0) + #endif + + #define usb_err(instance, format, arg...) \ +@@ -59,7 +59,7 @@ + dev_warn(&(instance)->usb_intf->dev , format , ## arg) + #ifdef DEBUG + #define usb_dbg(instance, format, arg...) \ +- dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg) ++ dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg) + #else + #define usb_dbg(instance, format, arg...) \ + do {} while (0) +@@ -104,21 +104,21 @@ struct usbatm_data; + /* + * Assuming all methods exist and succeed, they are called in this order: + * +-* bind, heavy_init, atm_start, ..., atm_stop, unbind ++* bind, heavy_init, atm_start, ..., atm_stop, unbind + */ + + struct usbatm_driver { + const char *driver_name; + + /* init device ... can sleep, or cause probe() failure */ +- int (*bind) (struct usbatm_data *, struct usb_interface *, ++ int (*bind) (struct usbatm_data *, struct usb_interface *, + const struct usb_device_id *id); + + /* additional device initialization that is too slow to be done in probe() */ +- int (*heavy_init) (struct usbatm_data *, struct usb_interface *); ++ int (*heavy_init) (struct usbatm_data *, struct usb_interface *); + + /* cleanup device ... can sleep, but can't fail */ +- void (*unbind) (struct usbatm_data *, struct usb_interface *); ++ void (*unbind) (struct usbatm_data *, struct usb_interface *); + + /* init ATM device ... can sleep, or cause ATM initialization failure */ + int (*atm_start) (struct usbatm_data *, struct atm_dev *); +@@ -126,9 +126,9 @@ struct usbatm_driver { + /* cleanup ATM device ... can sleep, but can't fail */ + void (*atm_stop) (struct usbatm_data *, struct atm_dev *); + +- int bulk_in; /* bulk rx endpoint */ +- int isoc_in; /* isochronous rx endpoint */ +- int bulk_out; /* bulk tx endpoint */ ++ int bulk_in; /* bulk rx endpoint */ ++ int isoc_in; /* isochronous rx endpoint */ ++ int bulk_out; /* bulk tx endpoint */ + + unsigned rx_padding; + unsigned tx_padding; +@@ -156,7 +156,7 @@ struct usbatm_channel { + struct usbatm_data { + /****************** + * public fields * +- ******************/ ++ ******************/ + + /* mini driver */ + struct usbatm_driver *driver; +@@ -174,7 +174,7 @@ struct usbatm_data { + + /******************************** + * private fields - do not use * +- ********************************/ ++ ********************************/ + + struct kref refcount; + struct mutex serialize; +--- a/drivers/usb/atm/xusbatm.c ++++ b/drivers/usb/atm/xusbatm.c +@@ -49,13 +49,13 @@ static struct usbatm_driver xusbatm_driv + static struct usb_device_id xusbatm_usb_ids[XUSBATM_DRIVERS_MAX + 1]; + static struct usb_driver xusbatm_usb_driver; + +-static struct usb_interface *xusbatm_find_intf (struct usb_device *usb_dev, int altsetting, u8 ep) ++static struct usb_interface *xusbatm_find_intf(struct usb_device *usb_dev, int altsetting, u8 ep) + { + struct usb_host_interface *alt; + struct usb_interface *intf; + int i, j; + +- for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) ++ for (i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) + if ((intf = usb_dev->actconfig->interface[i]) && (alt = usb_altnum_to_altsetting(intf, altsetting))) + for (j = 0; j < alt->desc.bNumEndpoints; j++) + if (alt->endpoint[j].desc.bEndpointAddress == ep) +@@ -63,7 +63,7 @@ static struct usb_interface *xusbatm_fin + return NULL; + } + +-static int xusbatm_capture_intf (struct usbatm_data *usbatm, struct usb_device *usb_dev, ++static int xusbatm_capture_intf(struct usbatm_data *usbatm, struct usb_device *usb_dev, + struct usb_interface *intf, int altsetting, int claim) + { + int ifnum = intf->altsetting->desc.bInterfaceNumber; +@@ -80,7 +80,7 @@ static int xusbatm_capture_intf (struct + return 0; + } + +-static void xusbatm_release_intf (struct usb_device *usb_dev, struct usb_interface *intf, int claimed) ++static void xusbatm_release_intf(struct usb_device *usb_dev, struct usb_interface *intf, int claimed) + { + if (claimed) { + usb_set_intfdata(intf, NULL); +@@ -147,7 +147,7 @@ static void xusbatm_unbind(struct usbatm + + usb_dbg(usbatm, "%s entered\n", __func__); + +- for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) { ++ for (i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) { + struct usb_interface *cur_intf = usb_dev->actconfig->interface[i]; + + if (cur_intf && (usb_get_intfdata(cur_intf) == usbatm)) { diff --git a/usb/usb-bkl-convert-usb_driver-ioctl-to-unlocked_ioctl.patch b/usb/usb-bkl-convert-usb_driver-ioctl-to-unlocked_ioctl.patch new file mode 100644 index 00000000000000..1ebadfd8a1c093 --- /dev/null +++ b/usb/usb-bkl-convert-usb_driver-ioctl-to-unlocked_ioctl.patch @@ -0,0 +1,94 @@ +From arnd@arndb.de Thu Jun 17 10:39:47 2010 +From: Arnd Bergmann <arnd@arndb.de> +Date: Tue, 1 Jun 2010 23:04:41 +0200 +Subject: USB-BKL: Convert usb_driver ioctl to unlocked_ioctl +To: Greg KH <gregkh@suse.de> +Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>, linux-usb@vger.kernel.org, Frederic Weisbecker <fweisbec@gmail.com>, John Kacur <jkacur@redhat.com>, Andi Kleen <andi@firstfloor.org>, Andi Kleen <ak@linux.intel.com> +Message-ID: <1275426285-9088-3-git-send-email-arnd@arndb.de> + + +From: Andi Kleen <ak@linux.intel.com> + +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> + +--- + drivers/usb/core/devio.c | 7 ++----- + drivers/usb/core/hub.c | 3 ++- + drivers/usb/misc/usbtest.c | 3 ++- + include/linux/usb.h | 2 +- + 4 files changed, 7 insertions(+), 8 deletions(-) + +--- a/drivers/usb/core/devio.c ++++ b/drivers/usb/core/devio.c +@@ -1668,13 +1668,10 @@ static int proc_ioctl(struct dev_state * + default: + if (intf->dev.driver) + driver = to_usb_driver(intf->dev.driver); +- if (driver == NULL || driver->ioctl == NULL) { ++ if (driver == NULL || driver->unlocked_ioctl == NULL) { + retval = -ENOTTY; + } else { +- /* keep API that guarantees BKL */ +- lock_kernel(); +- retval = driver->ioctl(intf, ctl->ioctl_code, buf); +- unlock_kernel(); ++ retval = driver->unlocked_ioctl(intf, ctl->ioctl_code, buf); + if (retval == -ENOIOCTLCMD) + retval = -ENOTTY; + } +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -1294,6 +1294,7 @@ descriptor_error: + return -ENODEV; + } + ++/* No BKL needed */ + static int + hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) + { +@@ -3463,7 +3464,7 @@ static struct usb_driver hub_driver = { + .reset_resume = hub_reset_resume, + .pre_reset = hub_pre_reset, + .post_reset = hub_post_reset, +- .ioctl = hub_ioctl, ++ .unlocked_ioctl = hub_ioctl, + .id_table = hub_id_table, + .supports_autosuspend = 1, + }; +--- a/drivers/usb/misc/usbtest.c ++++ b/drivers/usb/misc/usbtest.c +@@ -1548,6 +1548,7 @@ fail: + * off just killing the userspace task and waiting for it to exit. + */ + ++/* No BKL needed */ + static int + usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) + { +@@ -2170,7 +2171,7 @@ static struct usb_driver usbtest_driver + .name = "usbtest", + .id_table = id_table, + .probe = usbtest_probe, +- .ioctl = usbtest_ioctl, ++ .unlocked_ioctl = usbtest_ioctl, + .disconnect = usbtest_disconnect, + .suspend = usbtest_suspend, + .resume = usbtest_resume, +--- a/include/linux/usb.h ++++ b/include/linux/usb.h +@@ -843,7 +843,7 @@ struct usb_driver { + + void (*disconnect) (struct usb_interface *intf); + +- int (*ioctl) (struct usb_interface *intf, unsigned int code, ++ int (*unlocked_ioctl) (struct usb_interface *intf, unsigned int code, + void *buf); + + int (*suspend) (struct usb_interface *intf, pm_message_t message); diff --git a/usb/usb-bkl-remove-bkl-use-for-usb-serial-driver-probing.patch b/usb/usb-bkl-remove-bkl-use-for-usb-serial-driver-probing.patch new file mode 100644 index 00000000000000..f33d9bcd8456f9 --- /dev/null +++ b/usb/usb-bkl-remove-bkl-use-for-usb-serial-driver-probing.patch @@ -0,0 +1,151 @@ +From arnd@arndb.de Thu Jun 17 10:41:12 2010 +From: Andi Kleen <ak@linux.intel.com> +Date: Tue, 1 Jun 2010 23:04:42 +0200 +Subject: USB-BKL: Remove BKL use for usb serial driver probing +To: Greg KH <gregkh@suse.de> +Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>, linux-usb@vger.kernel.org, Frederic Weisbecker <fweisbec@gmail.com>, John Kacur <jkacur@redhat.com>, Andi Kleen <andi@firstfloor.org>, Andi Kleen <ak@linux.intel.com> +Message-ID: <1275426285-9088-4-git-send-email-arnd@arndb.de> + + +From: Andi Kleen <ak@linux.intel.com> + +The usb serial driver initialization tried to use the BKL to stop +driver modules from unloading, but that didn't work anyways. + +There was already some code to do proper try_module_get, +but it was conditional on having a new probe interface. +I checked all the low level drivers and they all have proper +.owner = THIS_MODULE, so it's ok to always use. + +The other problem was the usb_serial_driver_list needing +protection by a lock. This was broken anyways because unregister +did not necessarily have the BKL. + +I extended the extending table_lock mutex to protect this case too. + +With these changes the BKL can be removed here. + +Signed-off-by: Andi Kleen <ak@linux.intel.com> +Cc: Arnd Bergmann <arnd@arndb.de> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> +--- + drivers/usb/serial/usb-serial.c | 30 ++++++++++++++---------------- + 1 file changed, 14 insertions(+), 16 deletions(-) + +--- a/drivers/usb/serial/usb-serial.c ++++ b/drivers/usb/serial/usb-serial.c +@@ -653,6 +653,7 @@ exit: + return id; + } + ++/* Caller must hold table_lock */ + static struct usb_serial_driver *search_serial_device( + struct usb_interface *iface) + { +@@ -718,17 +719,23 @@ int usb_serial_probe(struct usb_interfac + int num_ports = 0; + int max_endpoints; + +- lock_kernel(); /* guard against unloading a serial driver module */ ++ mutex_lock(&table_lock); + type = search_serial_device(interface); + if (!type) { +- unlock_kernel(); ++ mutex_unlock(&table_lock); + dbg("none matched"); + return -ENODEV; + } + ++ if (!try_module_get(type->driver.owner)) { ++ mutex_unlock(&table_lock); ++ dev_err(&interface->dev, "module get failed, exiting\n"); ++ return -EIO; ++ } ++ mutex_unlock(&table_lock); ++ + serial = create_serial(dev, interface, type); + if (!serial) { +- unlock_kernel(); + dev_err(&interface->dev, "%s - out of memory\n", __func__); + return -ENOMEM; + } +@@ -737,20 +744,11 @@ int usb_serial_probe(struct usb_interfac + if (type->probe) { + const struct usb_device_id *id; + +- if (!try_module_get(type->driver.owner)) { +- unlock_kernel(); +- dev_err(&interface->dev, +- "module get failed, exiting\n"); +- kfree(serial); +- return -EIO; +- } +- + id = get_iface_id(type, interface); + retval = type->probe(serial, id); + module_put(type->driver.owner); + + if (retval) { +- unlock_kernel(); + dbg("sub driver rejected device"); + kfree(serial); + return retval; +@@ -822,7 +820,6 @@ int usb_serial_probe(struct usb_interfac + * properly during a later invocation of usb_serial_probe + */ + if (num_bulk_in == 0 || num_bulk_out == 0) { +- unlock_kernel(); + dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n"); + kfree(serial); + return -ENODEV; +@@ -835,7 +832,6 @@ int usb_serial_probe(struct usb_interfac + if (type == &usb_serial_generic_device) { + num_ports = num_bulk_out; + if (num_ports == 0) { +- unlock_kernel(); + dev_err(&interface->dev, + "Generic device with no bulk out, not allowed.\n"); + kfree(serial); +@@ -847,7 +843,6 @@ int usb_serial_probe(struct usb_interfac + /* if this device type has a calc_num_ports function, call it */ + if (type->calc_num_ports) { + if (!try_module_get(type->driver.owner)) { +- unlock_kernel(); + dev_err(&interface->dev, + "module get failed, exiting\n"); + kfree(serial); +@@ -878,7 +873,6 @@ int usb_serial_probe(struct usb_interfac + max_endpoints = max(max_endpoints, num_interrupt_out); + max_endpoints = max(max_endpoints, (int)serial->num_ports); + serial->num_port_pointers = max_endpoints; +- unlock_kernel(); + + dbg("%s - setting up %d port structures for this device", + __func__, max_endpoints); +@@ -1349,6 +1343,7 @@ int usb_serial_register(struct usb_seria + driver->description = driver->driver.name; + + /* Add this device to our list of devices */ ++ mutex_lock(&table_lock); + list_add(&driver->driver_list, &usb_serial_driver_list); + + retval = usb_serial_bus_register(driver); +@@ -1360,6 +1355,7 @@ int usb_serial_register(struct usb_seria + printk(KERN_INFO "USB Serial support registered for %s\n", + driver->description); + ++ mutex_unlock(&table_lock); + return retval; + } + EXPORT_SYMBOL_GPL(usb_serial_register); +@@ -1370,8 +1366,10 @@ void usb_serial_deregister(struct usb_se + /* must be called with BKL held */ + printk(KERN_INFO "USB Serial deregistering driver %s\n", + device->description); ++ mutex_lock(&table_lock); + list_del(&device->driver_list); + usb_serial_bus_deregister(device); ++ mutex_unlock(&table_lock); + } + EXPORT_SYMBOL_GPL(usb_serial_deregister); + diff --git a/usb/usb-bkl-remove-bkl-use-in-uhci-debug.patch b/usb/usb-bkl-remove-bkl-use-in-uhci-debug.patch new file mode 100644 index 00000000000000..2df486dcdec147 --- /dev/null +++ b/usb/usb-bkl-remove-bkl-use-in-uhci-debug.patch @@ -0,0 +1,87 @@ +From arnd@arndb.de Thu Jun 17 10:42:10 2010 +From: Andi Kleen <ak@linux.intel.com> +Date: Tue, 1 Jun 2010 23:04:43 +0200 +Subject: USB-BKL: Remove BKL use in uhci-debug +To: Greg KH <gregkh@suse.de> +Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>, linux-usb@vger.kernel.org, Frederic Weisbecker <fweisbec@gmail.com>, John Kacur <jkacur@redhat.com>, Andi Kleen <andi@firstfloor.org>, Andi Kleen <ak@linux.intel.com> +Message-ID: <1275426285-9088-5-git-send-email-arnd@arndb.de> + + +From: Andi Kleen <ak@linux.intel.com> + +BKL was not really needed, just came from earlier push downs. + +The only part that's a bit dodgy is the lseek function. Would +need another lock or atomic access to fpos on 32bit? +Better to have a libfs lseek + +Signed-off-by: Andi Kleen <ak@linux.intel.com> +Cc: Arnd Bergmann <arnd@arndb.de> +Cc: Alan Stern <stern@rowland.harvard.edu> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/usb/host/uhci-debug.c | 20 +++++++------------- + 1 file changed, 7 insertions(+), 13 deletions(-) + +--- a/drivers/usb/host/uhci-debug.c ++++ b/drivers/usb/host/uhci-debug.c +@@ -495,18 +495,16 @@ static int uhci_debug_open(struct inode + { + struct uhci_hcd *uhci = inode->i_private; + struct uhci_debug *up; +- int ret = -ENOMEM; + unsigned long flags; + +- lock_kernel(); + up = kmalloc(sizeof(*up), GFP_KERNEL); + if (!up) +- goto out; ++ return -ENOMEM; + + up->data = kmalloc(MAX_OUTPUT, GFP_KERNEL); + if (!up->data) { + kfree(up); +- goto out; ++ return -ENOMEM; + } + + up->size = 0; +@@ -517,10 +515,7 @@ static int uhci_debug_open(struct inode + + file->private_data = up; + +- ret = 0; +-out: +- unlock_kernel(); +- return ret; ++ return 0; + } + + static loff_t uhci_debug_lseek(struct file *file, loff_t off, int whence) +@@ -528,9 +523,9 @@ static loff_t uhci_debug_lseek(struct fi + struct uhci_debug *up; + loff_t new = -1; + +- lock_kernel(); + up = file->private_data; + ++ /* XXX: atomic 64bit seek access, but that needs to be fixed in the VFS */ + switch (whence) { + case 0: + new = off; +@@ -539,11 +534,10 @@ static loff_t uhci_debug_lseek(struct fi + new = file->f_pos + off; + break; + } +- if (new < 0 || new > up->size) { +- unlock_kernel(); ++ ++ if (new < 0 || new > up->size) + return -EINVAL; +- } +- unlock_kernel(); ++ + return (file->f_pos = new); + } + diff --git a/usb/usb-bkl-remove-lock_kernel-in-usbfs-update_sb.patch b/usb/usb-bkl-remove-lock_kernel-in-usbfs-update_sb.patch new file mode 100644 index 00000000000000..4ba33ac3d4b513 --- /dev/null +++ b/usb/usb-bkl-remove-lock_kernel-in-usbfs-update_sb.patch @@ -0,0 +1,41 @@ +From arnd@arndb.de Thu Jun 17 10:36:50 2010 +From: Andi Kleen <ak@linux.intel.com> +Date: Tue, 1 Jun 2010 23:04:40 +0200 +Subject: USB-BKL: Remove lock_kernel in usbfs update_sb() +To: Greg KH <gregkh@suse.de> +Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>, linux-usb@vger.kernel.org, Frederic Weisbecker <fweisbec@gmail.com>, John Kacur <jkacur@redhat.com>, Andi Kleen <andi@firstfloor.org>, Andi Kleen <ak@linux.intel.com> +Message-ID: <1275426285-9088-2-git-send-email-arnd@arndb.de> + + +From: Andi Kleen <ak@linux.intel.com> + +The code this is attempting to lock against does not use the BKL, +so it's not needed. + +Most likely this code is still broken/racy (Al Viro also thinks so), +but removing the BKL should not make it worse than before. + +Signed-off-by: Andi Kleen <ak@linux.intel.com> +Cc: Arnd Bergmann <arnd@arndb.de> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/usb/core/inode.c | 4 ---- + 1 file changed, 4 deletions(-) + +--- a/drivers/usb/core/inode.c ++++ b/drivers/usb/core/inode.c +@@ -265,13 +265,9 @@ static int remount(struct super_block *s + return -EINVAL; + } + +- lock_kernel(); +- + if (usbfs_mount && usbfs_mount->mnt_sb) + update_sb(usbfs_mount->mnt_sb); + +- unlock_kernel(); +- + return 0; + } + diff --git a/usb/usb-gadget-composite-usb_string_ids_-functions-added.patch b/usb/usb-gadget-composite-usb_string_ids_-functions-added.patch new file mode 100644 index 00000000000000..4f56506c982565 --- /dev/null +++ b/usb/usb-gadget-composite-usb_string_ids_-functions-added.patch @@ -0,0 +1,131 @@ +From m.nazarewicz@samsung.com Thu Jun 17 10:48:28 2010 +From: Michal Nazarewicz <m.nazarewicz@samsung.com> +Date: Wed, 16 Jun 2010 12:07:59 +0200 +Subject: USB: gadget: composite: usb_string_ids_*() functions added +To: linux-usb@vger.kernel.org +Cc: David Brownell <dbrownell@users.sourceforge.net>, Greg KH <greg@kroah.com>, Kyungmin Park <kyungmin.park@samsung.com>, Marek Szyprowski <m.szyprowski@samsung.com>, linux-kernel@vger.kernel.org +Message-ID: <45fc10256bd2374706e4153360427257d15804a9.1276681840.git.m.nazarewicz@samsung.com> + + +usb_string_ids_tab() and usb_string_ids_n() functions added to +the composite framework. The first accepts an array of +usb_string object and for each registeres a string id and the +second registeres a given number of ids and returns the first. + +This may simplify string ids registration since gadgets and +composite functions won't have to call usb_string_id() several +times and each time check for errer status -- all this will be +done with a single call. + +Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> +Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/usb/gadget/composite.c | 71 ++++++++++++++++++++++++++++++++++++++--- + include/linux/usb/composite.h | 4 ++ + 2 files changed, 71 insertions(+), 4 deletions(-) + +--- a/drivers/usb/gadget/composite.c ++++ b/drivers/usb/gadget/composite.c +@@ -673,20 +673,83 @@ static int get_string(struct usb_composi + * string IDs. Drivers for functions, configurations, or gadgets will + * then store that ID in the appropriate descriptors and string table. + * +- * All string identifier should be allocated using this routine, to +- * ensure that for example different functions don't wrongly assign +- * different meanings to the same identifier. ++ * All string identifier should be allocated using this, ++ * @usb_string_ids_tab() or @usb_string_ids_n() routine, to ensure ++ * that for example different functions don't wrongly assign different ++ * meanings to the same identifier. + */ + int usb_string_id(struct usb_composite_dev *cdev) + { + if (cdev->next_string_id < 254) { +- /* string id 0 is reserved */ ++ /* string id 0 is reserved by USB spec for list of ++ * supported languages */ ++ /* 255 reserved as well? -- mina86 */ + cdev->next_string_id++; + return cdev->next_string_id; + } + return -ENODEV; + } + ++/** ++ * usb_string_ids() - allocate unused string IDs in batch ++ * @cdev: the device whose string descriptor IDs are being allocated ++ * @str: an array of usb_string objects to assign numbers to ++ * Context: single threaded during gadget setup ++ * ++ * @usb_string_ids() is called from bind() callbacks to allocate ++ * string IDs. Drivers for functions, configurations, or gadgets will ++ * then copy IDs from the string table to the appropriate descriptors ++ * and string table for other languages. ++ * ++ * All string identifier should be allocated using this, ++ * @usb_string_id() or @usb_string_ids_n() routine, to ensure that for ++ * example different functions don't wrongly assign different meanings ++ * to the same identifier. ++ */ ++int usb_string_ids_tab(struct usb_composite_dev *cdev, struct usb_string *str) ++{ ++ int next = cdev->next_string_id; ++ ++ for (; str->s; ++str) { ++ if (unlikely(next >= 254)) ++ return -ENODEV; ++ str->id = ++next; ++ } ++ ++ cdev->next_string_id = next; ++ ++ return 0; ++} ++ ++/** ++ * usb_string_ids_n() - allocate unused string IDs in batch ++ * @cdev: the device whose string descriptor IDs are being allocated ++ * @n: number of string IDs to allocate ++ * Context: single threaded during gadget setup ++ * ++ * Returns the first requested ID. This ID and next @n-1 IDs are now ++ * valid IDs. At least providind that @n is non zore because if it ++ * is, returns last requested ID which is now very useful information. ++ * ++ * @usb_string_ids_n() is called from bind() callbacks to allocate ++ * string IDs. Drivers for functions, configurations, or gadgets will ++ * then store that ID in the appropriate descriptors and string table. ++ * ++ * All string identifier should be allocated using this, ++ * @usb_string_id() or @usb_string_ids_n() routine, to ensure that for ++ * example different functions don't wrongly assign different meanings ++ * to the same identifier. ++ */ ++int usb_string_ids_n(struct usb_composite_dev *c, unsigned n) ++{ ++ unsigned next = c->next_string_id; ++ if (unlikely(n > 254 || (unsigned)next + n > 254)) ++ return -ENODEV; ++ c->next_string_id += n; ++ return next + 1; ++} ++ ++ + /*-------------------------------------------------------------------------*/ + + static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req) +--- a/include/linux/usb/composite.h ++++ b/include/linux/usb/composite.h +@@ -342,6 +342,10 @@ struct usb_composite_dev { + }; + + extern int usb_string_id(struct usb_composite_dev *c); ++extern int usb_string_ids_tab(struct usb_composite_dev *c, ++ struct usb_string *str); ++extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); ++ + + /* messaging utils */ + #define DBG(d, fmt, args...) \ diff --git a/usb/usb-gadget-do-not-take-bkl-for-gadget-ops-ioctl.patch b/usb/usb-gadget-do-not-take-bkl-for-gadget-ops-ioctl.patch new file mode 100644 index 00000000000000..ce72348fbc7723 --- /dev/null +++ b/usb/usb-gadget-do-not-take-bkl-for-gadget-ops-ioctl.patch @@ -0,0 +1,52 @@ +From arnd@arndb.de Thu Jun 17 10:44:21 2010 +From: Arnd Bergmann <arnd@arndb.de> +Date: Tue, 1 Jun 2010 23:04:44 +0200 +Subject: usb: gadget: Do not take BKL for gadget->ops->ioctl +To: Greg KH <gregkh@suse.de> +Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>, linux-usb@vger.kernel.org, Frederic Weisbecker <fweisbec@gmail.com>, John Kacur <jkacur@redhat.com>, Andi Kleen <andi@firstfloor.org> +Message-ID: <1275426285-9088-6-git-send-email-arnd@arndb.de> + + +There is no gadget driver in the tree that +actually implements the ioctl operation, so +obviously it is not necessary to hold the +BKL around the call. + +Signed-off-by: Arnd Bergmann <arnd@arndb.de> +Cc: David Brownell <dbrownell@users.sourceforge.net> +Cc: MichaĆ Nazarewicz <m.nazarewicz@samsung.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/usb/gadget/f_fs.c | 2 -- + drivers/usb/gadget/inode.c | 6 ++---- + 2 files changed, 2 insertions(+), 6 deletions(-) + +--- a/drivers/usb/gadget/f_fs.c ++++ b/drivers/usb/gadget/f_fs.c +@@ -714,9 +714,7 @@ static long ffs_ep0_ioctl(struct file *f + struct ffs_function *func = ffs->func; + ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV; + } else if (gadget->ops->ioctl) { +- lock_kernel(); + ret = gadget->ops->ioctl(gadget, code, value); +- unlock_kernel(); + } else { + ret = -ENOTTY; + } +--- a/drivers/usb/gadget/inode.c ++++ b/drivers/usb/gadget/inode.c +@@ -1299,11 +1299,9 @@ static long dev_ioctl (struct file *fd, + struct usb_gadget *gadget = dev->gadget; + long ret = -ENOTTY; + +- if (gadget->ops->ioctl) { +- lock_kernel(); ++ if (gadget->ops->ioctl) + ret = gadget->ops->ioctl (gadget, code, value); +- unlock_kernel(); +- } ++ + return ret; + } + diff --git a/usb/usb-gadget-f_fs-functionfs_add-renamed-to-functionfs_bind_config.patch b/usb/usb-gadget-f_fs-functionfs_add-renamed-to-functionfs_bind_config.patch new file mode 100644 index 00000000000000..03cbb65682a64c --- /dev/null +++ b/usb/usb-gadget-f_fs-functionfs_add-renamed-to-functionfs_bind_config.patch @@ -0,0 +1,64 @@ +From m.nazarewicz@samsung.com Thu Jun 17 10:47:52 2010 +From: Michal Nazarewicz <m.nazarewicz@samsung.com> +Date: Wed, 16 Jun 2010 12:07:58 +0200 +Subject: USB: gadget: f_fs: functionfs_add() renamed to functionfs_bind_config() +To: linux-usb@vger.kernel.org +Cc: David Brownell <dbrownell@users.sourceforge.net>, Greg KH <greg@kroah.com>, Kyungmin Park <kyungmin.park@samsung.com>, Marek Szyprowski <m.szyprowski@samsung.com>, linux-kernel@vger.kernel.org +Message-ID: <0022e21e1b622b3a54d1e55aed727e7e429c7c70.1276681840.git.m.nazarewicz@samsung.com> + + +FunctionFS had a bit unique name for function used to add it +to USB configuration. Renamed as to match naming convention +of other functions. + +Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> +Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/usb/gadget/f_fs.c | 6 +++--- + drivers/usb/gadget/g_ffs.c | 2 +- + include/linux/usb/functionfs.h | 6 +++--- + 3 files changed, 7 insertions(+), 7 deletions(-) + +--- a/drivers/usb/gadget/f_fs.c ++++ b/drivers/usb/gadget/f_fs.c +@@ -1478,9 +1478,9 @@ static void ffs_epfiles_destroy(struct f + } + + +-static int functionfs_add(struct usb_composite_dev *cdev, +- struct usb_configuration *c, +- struct ffs_data *ffs) ++static int functionfs_bind_config(struct usb_composite_dev *cdev, ++ struct usb_configuration *c, ++ struct ffs_data *ffs) + { + struct ffs_function *func; + int ret; +--- a/drivers/usb/gadget/g_ffs.c ++++ b/drivers/usb/gadget/g_ffs.c +@@ -388,7 +388,7 @@ static int __gfs_do_config(struct usb_co + return ret; + } + +- ret = functionfs_add(c->cdev, c, gfs_ffs_data); ++ ret = functionfs_bind_config(c->cdev, c, gfs_ffs_data); + if (unlikely(ret < 0)) + return ret; + +--- a/include/linux/usb/functionfs.h ++++ b/include/linux/usb/functionfs.h +@@ -180,9 +180,9 @@ static int functionfs_bind(struct ffs_da + static void functionfs_unbind(struct ffs_data *ffs) + __attribute__((nonnull)); + +-static int functionfs_add(struct usb_composite_dev *cdev, +- struct usb_configuration *c, +- struct ffs_data *ffs) ++static int functionfs_bind_config(struct usb_composite_dev *cdev, ++ struct usb_configuration *c, ++ struct ffs_data *ffs) + __attribute__((warn_unused_result, nonnull)); + + diff --git a/usb/usb-gadget-f_fs-use-usb_string_ids_n.patch b/usb/usb-gadget-f_fs-use-usb_string_ids_n.patch new file mode 100644 index 00000000000000..dbc8782010dece --- /dev/null +++ b/usb/usb-gadget-f_fs-use-usb_string_ids_n.patch @@ -0,0 +1,76 @@ +From m.nazarewicz@samsung.com Thu Jun 17 10:49:00 2010 +From: Michal Nazarewicz <m.nazarewicz@samsung.com> +Date: Wed, 16 Jun 2010 12:08:00 +0200 +Subject: USB: gadget: f_fs: use usb_string_ids_n() +To: linux-usb@vger.kernel.org +Cc: David Brownell <dbrownell@users.sourceforge.net>, Greg KH <greg@kroah.com>, Kyungmin Park <kyungmin.park@samsung.com>, Marek Szyprowski <m.szyprowski@samsung.com>, linux-kernel@vger.kernel.org +Message-ID: <bb0d9f73c7caae31c0bc291d3dfce44a2f6a3736.1276681840.git.m.nazarewicz@samsung.com> + + +Use usb_string_ids_n() function to simplify string ids +registeration. + +Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> +Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/usb/gadget/f_fs.c | 30 ++++++++++++------------------ + 1 file changed, 12 insertions(+), 18 deletions(-) + +--- a/drivers/usb/gadget/f_fs.c ++++ b/drivers/usb/gadget/f_fs.c +@@ -1375,7 +1375,8 @@ static void ffs_data_reset(struct ffs_da + + static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) + { +- unsigned i, count; ++ struct usb_gadget_strings **lang; ++ int first_id; + + ENTER(); + +@@ -1383,7 +1384,9 @@ static int functionfs_bind(struct ffs_da + || test_and_set_bit(FFS_FL_BOUND, &ffs->flags))) + return -EBADFD; + +- ffs_data_get(ffs); ++ first_id = usb_string_ids_n(cdev, ffs->strings_count); ++ if (unlikely(first_id < 0)) ++ return first_id; + + ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); + if (unlikely(!ffs->ep0req)) +@@ -1391,25 +1394,16 @@ static int functionfs_bind(struct ffs_da + ffs->ep0req->complete = ffs_ep0_complete; + ffs->ep0req->context = ffs; + +- /* Get strings identifiers */ +- for (count = ffs->strings_count, i = 0; i < count; ++i) { +- struct usb_gadget_strings **lang; +- +- int id = usb_string_id(cdev); +- if (unlikely(id < 0)) { +- usb_ep_free_request(cdev->gadget->ep0, ffs->ep0req); +- ffs->ep0req = NULL; +- return id; +- } +- +- lang = ffs->stringtabs; +- do { +- (*lang)->strings[i].id = id; +- ++lang; +- } while (*lang); ++ lang = ffs->stringtabs; ++ for (lang = ffs->stringtabs; *lang; ++lang) { ++ struct usb_string *str = (*lang)->strings; ++ int id = first_id; ++ for (; str->s; ++id, ++str) ++ str->id = id; + } + + ffs->gadget = cdev->gadget; ++ ffs_data_get(ffs); + return 0; + } + diff --git a/usb/usb-gadget-f_mass_storage-fsg_add-renamed-to-fsg_bind_config.patch b/usb/usb-gadget-f_mass_storage-fsg_add-renamed-to-fsg_bind_config.patch new file mode 100644 index 00000000000000..d361f1f9bb74fd --- /dev/null +++ b/usb/usb-gadget-f_mass_storage-fsg_add-renamed-to-fsg_bind_config.patch @@ -0,0 +1,83 @@ +From m.nazarewicz@samsung.com Thu Jun 17 10:47:40 2010 +From: Michal Nazarewicz <m.nazarewicz@samsung.com> +Date: Wed, 16 Jun 2010 12:07:57 +0200 +Subject: USB: gadget: f_mass_storage: fsg_add() renamed to fsg_bind_config() +To: linux-usb@vger.kernel.org +Cc: David Brownell <dbrownell@users.sourceforge.net>, Greg KH <greg@kroah.com>, Kyungmin Park <kyungmin.park@samsung.com>, Marek Szyprowski <m.szyprowski@samsung.com>, linux-kernel@vger.kernel.org +Message-ID: <1cf0484e46e3b2b5ce0dea8cdc7396d4bfa977c5.1276681840.git.m.nazarewicz@samsung.com> + + +Mass Storage Function had a bit unique name for function +used to add it to USB configuration. Renamed as to match +naming convention of other functions. + +Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> +Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/usb/gadget/f_mass_storage.c | 13 ++++++++++--- + drivers/usb/gadget/mass_storage.c | 2 +- + drivers/usb/gadget/multi.c | 4 ++-- + 3 files changed, 13 insertions(+), 6 deletions(-) + +--- a/drivers/usb/gadget/f_mass_storage.c ++++ b/drivers/usb/gadget/f_mass_storage.c +@@ -3023,9 +3023,9 @@ static struct usb_gadget_strings *fsg_st + NULL, + }; + +-static int fsg_add(struct usb_composite_dev *cdev, +- struct usb_configuration *c, +- struct fsg_common *common) ++static int fsg_bind_config(struct usb_composite_dev *cdev, ++ struct usb_configuration *c, ++ struct fsg_common *common) + { + struct fsg_dev *fsg; + int rc; +@@ -3072,6 +3072,13 @@ error_free_fsg: + return rc; + } + ++static inline int __deprecated __maybe_unused ++fsg_add(struct usb_composite_dev *cdev, ++ struct usb_configuration *c, ++ struct fsg_common *common) ++{ ++ return fsg_bind_config(cdev, c, common); ++} + + + /************************* Module parameters *************************/ +--- a/drivers/usb/gadget/mass_storage.c ++++ b/drivers/usb/gadget/mass_storage.c +@@ -161,7 +161,7 @@ static int __init msg_do_config(struct u + if (IS_ERR(retp)) + return PTR_ERR(retp); + +- ret = fsg_add(c->cdev, c, &common); ++ ret = fsg_bind_config(c->cdev, c, &common); + fsg_common_put(&common); + return ret; + } +--- a/drivers/usb/gadget/multi.c ++++ b/drivers/usb/gadget/multi.c +@@ -172,7 +172,7 @@ static int __init rndis_do_config(struct + if (ret < 0) + return ret; + +- ret = fsg_add(c->cdev, c, fsg_common); ++ ret = fsg_bind_config(c->cdev, c, fsg_common); + if (ret < 0) + return ret; + +@@ -208,7 +208,7 @@ static int __init cdc_do_config(struct u + if (ret < 0) + return ret; + +- ret = fsg_add(c->cdev, c, fsg_common); ++ ret = fsg_bind_config(c->cdev, c, fsg_common); + if (ret < 0) + return ret; + diff --git a/usb/usb-gadget-g_mass_storage-static-data-instead-of-dynamic-allocation.patch b/usb/usb-gadget-g_mass_storage-static-data-instead-of-dynamic-allocation.patch new file mode 100644 index 00000000000000..14ce89bdd1b4a0 --- /dev/null +++ b/usb/usb-gadget-g_mass_storage-static-data-instead-of-dynamic-allocation.patch @@ -0,0 +1,53 @@ +From m.nazarewicz@samsung.com Thu Jun 17 10:47:16 2010 +From: Michal Nazarewicz <m.nazarewicz@samsung.com> +Date: Wed, 16 Jun 2010 12:07:56 +0200 +Subject: USB: gadget: g_mass_storage: static data instead of dynamic allocation +To: linux-usb@vger.kernel.org +Cc: David Brownell <dbrownell@users.sourceforge.net>, Greg KH <greg@kroah.com>, Kyungmin Park <kyungmin.park@samsung.com>, Marek Szyprowski <m.szyprowski@samsung.com>, linux-kernel@vger.kernel.org +Message-ID: <7131891c93ac20a3360068e2f4b8fff0de7dfafb.1276681840.git.m.nazarewicz@samsung.com> + + +This patch changes msg_do_config() function so that it uses +a static object for a fsg_common structure instead of dynamically +allocated. This is a micro-optimisation. + +Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> +Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/usb/gadget/mass_storage.c | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +--- a/drivers/usb/gadget/mass_storage.c ++++ b/drivers/usb/gadget/mass_storage.c +@@ -143,7 +143,9 @@ static int msg_thread_exits(struct fsg_c + + static int __init msg_do_config(struct usb_configuration *c) + { +- struct fsg_common *common; ++ static struct fsg_common common; ++ ++ struct fsg_common *retp; + struct fsg_config config; + int ret; + +@@ -154,12 +156,13 @@ static int __init msg_do_config(struct u + + fsg_config_from_params(&config, &mod_data); + config.thread_exits = msg_thread_exits; +- common = fsg_common_init(0, c->cdev, &config); +- if (IS_ERR(common)) +- return PTR_ERR(common); + +- ret = fsg_add(c->cdev, c, common); +- fsg_common_put(common); ++ retp = fsg_common_init(&common, c->cdev, &config); ++ if (IS_ERR(retp)) ++ return PTR_ERR(retp); ++ ++ ret = fsg_add(c->cdev, c, &common); ++ fsg_common_put(&common); + return ret; + } + diff --git a/usb/usb-mon-kill-bkl-usage.patch b/usb/usb-mon-kill-bkl-usage.patch new file mode 100644 index 00000000000000..fece0d81272029 --- /dev/null +++ b/usb/usb-mon-kill-bkl-usage.patch @@ -0,0 +1,100 @@ +From arnd@arndb.de Thu Jun 17 10:45:23 2010 +From: Arnd Bergmann <arnd@arndb.de> +Date: Tue, 1 Jun 2010 23:04:45 +0200 +Subject: USB: mon: kill BKL usage +To: Greg KH <gregkh@suse.de> +Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>, linux-usb@vger.kernel.org, Frederic Weisbecker <fweisbec@gmail.com>, John Kacur <jkacur@redhat.com>, Andi Kleen <andi@firstfloor.org> +Message-ID: <1275426285-9088-7-git-send-email-arnd@arndb.de> + + +compat_ioctl does not use the BKL, so I assume that +the native function does not need it either. + +The open function is already protected by the +driver's mutex, the BKL is probably not needed +here either. + +Signed-off-by: Arnd Bergmann <arnd@arndb.de> +Cc: Alan Stern <stern@rowland.harvard.edu> +Cc: Pete Zaitcev <zaitcev@redhat.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + + +--- + drivers/usb/mon/mon_bin.c | 22 ++-------------------- + 1 file changed, 2 insertions(+), 20 deletions(-) + +--- a/drivers/usb/mon/mon_bin.c ++++ b/drivers/usb/mon/mon_bin.c +@@ -646,17 +646,14 @@ static int mon_bin_open(struct inode *in + size_t size; + int rc; + +- lock_kernel(); + mutex_lock(&mon_lock); + if ((mbus = mon_bus_lookup(iminor(inode))) == NULL) { + mutex_unlock(&mon_lock); +- unlock_kernel(); + return -ENODEV; + } + if (mbus != &mon_bus0 && mbus->u_bus == NULL) { + printk(KERN_ERR TAG ": consistency error on open\n"); + mutex_unlock(&mon_lock); +- unlock_kernel(); + return -ENODEV; + } + +@@ -689,7 +686,6 @@ static int mon_bin_open(struct inode *in + + file->private_data = rp; + mutex_unlock(&mon_lock); +- unlock_kernel(); + return 0; + + err_allocbuff: +@@ -698,7 +694,6 @@ err_allocvec: + kfree(rp); + err_alloc: + mutex_unlock(&mon_lock); +- unlock_kernel(); + return rc; + } + +@@ -954,7 +949,7 @@ static int mon_bin_queued(struct mon_rea + + /* + */ +-static int mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ++static long mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + { + struct mon_reader_bin *rp = file->private_data; + // struct mon_bus* mbus = rp->r.m_bus; +@@ -1094,19 +1089,6 @@ static int mon_bin_ioctl(struct file *fi + return ret; + } + +-static long mon_bin_unlocked_ioctl(struct file *file, unsigned int cmd, +- unsigned long arg) +-{ +- int ret; +- +- lock_kernel(); +- ret = mon_bin_ioctl(file, cmd, arg); +- unlock_kernel(); +- +- return ret; +-} +- +- + #ifdef CONFIG_COMPAT + static long mon_bin_compat_ioctl(struct file *file, + unsigned int cmd, unsigned long arg) +@@ -1250,7 +1232,7 @@ static const struct file_operations mon_ + .read = mon_bin_read, + /* .write = mon_text_write, */ + .poll = mon_bin_poll, +- .unlocked_ioctl = mon_bin_unlocked_ioctl, ++ .unlocked_ioctl = mon_bin_ioctl, + #ifdef CONFIG_COMPAT + .compat_ioctl = mon_bin_compat_ioctl, + #endif |
