Merge remote-tracking branch 'usb/usb-next'
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 13 Sep 2016 02:41:11 +0000 (12:41 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 13 Sep 2016 02:41:11 +0000 (12:41 +1000)
83 files changed:
Documentation/devicetree/bindings/usb/usb4604.txt [new file with mode: 0644]
MAINTAINERS
drivers/usb/Kconfig
drivers/usb/atm/cxacru.c
drivers/usb/atm/speedtch.c
drivers/usb/atm/ueagle-atm.c
drivers/usb/atm/usbatm.c
drivers/usb/class/cdc-acm.c
drivers/usb/class/cdc-wdm.c
drivers/usb/class/usbtmc.c
drivers/usb/common/ulpi.c
drivers/usb/core/Kconfig
drivers/usb/core/Makefile
drivers/usb/core/hcd.c
drivers/usb/core/hub.c
drivers/usb/core/message.c
drivers/usb/core/of.c
drivers/usb/core/otg_whitelist.h
drivers/usb/core/urb.c
drivers/usb/dwc2/gadget.c
drivers/usb/dwc2/hcd.c
drivers/usb/dwc3/Kconfig
drivers/usb/gadget/udc/fsl_qe_udc.c
drivers/usb/gadget/udc/goku_udc.c
drivers/usb/gadget/udc/omap_udc.c
drivers/usb/gadget/udc/udc-xilinx.c
drivers/usb/host/bcma-hcd.c
drivers/usb/host/ehci-platform.c
drivers/usb/host/fhci-hcd.c
drivers/usb/host/fsl-mph-dr-of.c
drivers/usb/host/max3421-hcd.c
drivers/usb/host/ohci-at91.c
drivers/usb/host/ohci-omap.c
drivers/usb/host/ohci-sa1111.c
drivers/usb/host/uhci-hcd.c
drivers/usb/host/whci/init.c
drivers/usb/host/xhci-tegra.c
drivers/usb/host/xhci.c
drivers/usb/misc/Kconfig
drivers/usb/misc/Makefile
drivers/usb/misc/adutux.c
drivers/usb/misc/appledisplay.c
drivers/usb/misc/cypress_cy7c63.c
drivers/usb/misc/cytherm.c
drivers/usb/misc/ftdi-elan.c
drivers/usb/misc/idmouse.c
drivers/usb/misc/iowarrior.c
drivers/usb/misc/ldusb.c
drivers/usb/misc/legousbtower.c
drivers/usb/misc/lvstest.c
drivers/usb/misc/sisusbvga/sisusb.c
drivers/usb/misc/trancevibrator.c
drivers/usb/misc/usb4604.c [new file with mode: 0644]
drivers/usb/misc/usblcd.c
drivers/usb/misc/usbsevseg.c
drivers/usb/misc/uss720.c
drivers/usb/misc/yurex.c
drivers/usb/musb/am35x.c
drivers/usb/musb/da8xx.c
drivers/usb/renesas_usbhs/mod_gadget.c
drivers/usb/renesas_usbhs/mod_host.c
drivers/usb/renesas_usbhs/pipe.c
drivers/usb/storage/alauda.c
drivers/usb/storage/sddr09.c
drivers/usb/storage/usb.c
drivers/usb/usb-skeleton.c
drivers/usb/usbip/Kconfig
drivers/usb/usbip/stub_rx.c
drivers/usb/usbip/vhci.h
drivers/usb/usbip/vhci_hcd.c
drivers/usb/usbip/vhci_rx.c
drivers/usb/usbip/vhci_sysfs.c
drivers/usb/usbip/vudc_dev.c
drivers/usb/usbip/vudc_rx.c
drivers/usb/wusbcore/crypto.c
drivers/usb/wusbcore/security.c
drivers/usb/wusbcore/wa-nep.c
drivers/usb/wusbcore/wa-xfer.c
drivers/uwb/hwa-rc.c
drivers/watchdog/pcwd_usb.c
include/linux/bcma/bcma_regs.h
include/linux/ulpi/driver.h
include/soc/at91/atmel-sfr.h

diff --git a/Documentation/devicetree/bindings/usb/usb4604.txt b/Documentation/devicetree/bindings/usb/usb4604.txt
new file mode 100644 (file)
index 0000000..82506d1
--- /dev/null
@@ -0,0 +1,19 @@
+SMSC USB4604 High-Speed Hub Controller
+
+Required properties:
+- compatible: Should be "smsc,usb4604"
+
+Optional properties:
+- reg: Specifies the i2c slave address, it is required and should be 0x2d
+       if I2C is used.
+- reset-gpios: Should specify GPIO for reset.
+- initial-mode: Should specify initial mode.
+                (1 for HUB mode, 2 for STANDBY mode)
+
+Examples:
+       usb-hub@2d {
+               compatible = "smsc,usb4604";
+               reg = <0x2d>;
+               reset-gpios = <&gpx3 5 1>;
+               initial-mode = <1>;
+       };
index 43ba25fd9107a035a18eb8a5e8ba6e87392fb828..7da11ca92e7db1ae901f22f4b716103c11432ca1 100644 (file)
@@ -12272,7 +12272,7 @@ S:      Maintained
 F:     drivers/net/usb/lan78xx.*
 
 USB MASS STORAGE DRIVER
-M:     Matthew Dharm <mdharm-usb@one-eyed-alien.net>
+M:     Alan Stern <stern@rowland.harvard.edu>
 L:     linux-usb@vger.kernel.org
 L:     usb-storage@lists.one-eyed-alien.net
 S:     Maintained
index 8689dcba5201b9311a9177515f78a78b7a6a24b0..2b9159a9ab4fc5b93d383dfce67f8e1b9c6e4b7b 100644 (file)
@@ -160,4 +160,25 @@ config USB_LED_TRIG
          LEDs and you want to use them as activity indicators for USB host or
          gadget.
 
+config USB_ULPI_BUS
+       tristate "USB ULPI PHY interface support"
+       depends on USB_COMMON
+       help
+         UTMI+ Low Pin Interface (ULPI) is specification for a commonly used
+         USB 2.0 PHY interface. The ULPI specification defines a standard set
+         of registers that can be used to detect the vendor and product which
+         allows ULPI to be handled as a bus. This module is the driver for that
+         bus.
+
+         The ULPI interfaces (the buses) are registered by the drivers for USB
+         controllers which support ULPI register access and have ULPI PHY
+         attached to them. The ULPI PHY drivers themselves are normal PHY
+         drivers.
+
+         ULPI PHYs provide often functions such as ADP sensing/probing (OTG
+         protocol) and USB charger detection.
+
+         To compile this driver as a module, choose M here: the module will
+         be called ulpi.
+
 endif # USB_SUPPORT
index 0a866e90b49c80ee04061ae1af3ac5020dd3a237..f9fe86b6f7b5b6ac5e35d944500cd74781f6dd26 100644 (file)
@@ -1139,10 +1139,8 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
 
        /* instance init */
        instance = kzalloc(sizeof(*instance), GFP_KERNEL);
-       if (!instance) {
-               usb_dbg(usbatm_instance, "cxacru_bind: no memory for instance data\n");
+       if (!instance)
                return -ENOMEM;
-       }
 
        instance->usbatm = usbatm_instance;
        instance->modem_type = (struct cxacru_modem_type *) id->driver_info;
@@ -1168,13 +1166,11 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
        }
        instance->rcv_urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!instance->rcv_urb) {
-               usb_dbg(usbatm_instance, "cxacru_bind: no memory for rcv_urb\n");
                ret = -ENOMEM;
                goto fail;
        }
        instance->snd_urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!instance->snd_urb) {
-               usb_dbg(usbatm_instance, "cxacru_bind: no memory for snd_urb\n");
                ret = -ENOMEM;
                goto fail;
        }
index 0270d1312f834fbacec08db3a3fbd33441ad4396..5083eb5b0d5ed9f7d7dc90ee5309c4ae5e6d437a 100644 (file)
@@ -817,7 +817,6 @@ static int speedtch_bind(struct usbatm_data *usbatm,
        instance = kzalloc(sizeof(*instance), GFP_KERNEL);
 
        if (!instance) {
-               usb_err(usbatm, "%s: no memory for instance data!\n", __func__);
                ret = -ENOMEM;
                goto fail_release;
        }
index 4333dc576a12321f4cdd88808ffb7a98dc5efc41..df67815f74e68020076c8b59bcecc8ba0bf3782d 100644 (file)
@@ -2196,17 +2196,12 @@ static int uea_boot(struct uea_softc *sc)
                load_XILINX_firmware(sc);
 
        intr = kmalloc(size, GFP_KERNEL);
-       if (!intr) {
-               uea_err(INS_TO_USBDEV(sc),
-                      "cannot allocate interrupt package\n");
+       if (!intr)
                goto err0;
-       }
 
        sc->urb_int = usb_alloc_urb(0, GFP_KERNEL);
-       if (!sc->urb_int) {
-               uea_err(INS_TO_USBDEV(sc), "cannot allocate interrupt URB\n");
+       if (!sc->urb_int)
                goto err1;
-       }
 
        usb_fill_int_urb(sc->urb_int, sc->usb_dev,
                         usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE),
@@ -2561,10 +2556,8 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
        }
 
        sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL);
-       if (!sc) {
-               uea_err(usb, "uea_init: not enough memory !\n");
+       if (!sc)
                return -ENOMEM;
-       }
 
        sc->usb_dev = usb;
        usbatm->driver_data = sc;
index db322d9ccb6e59c28c0ee54a8c11171dcbf8f284..4dec9df8764b9abc3544b81e4e06da1d7aec5a8f 100644 (file)
@@ -819,7 +819,6 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
 
        new = kzalloc(sizeof(struct usbatm_vcc_data), GFP_KERNEL);
        if (!new) {
-               atm_err(instance, "%s: no memory for vcc_data!\n", __func__);
                ret = -ENOMEM;
                goto fail;
        }
@@ -1032,10 +1031,8 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
 
        /* instance init */
        instance = kzalloc(sizeof(*instance) + sizeof(struct urb *) * (num_rcv_urbs + num_snd_urbs), GFP_KERNEL);
-       if (!instance) {
-               dev_err(dev, "%s: no memory for instance data!\n", __func__);
+       if (!instance)
                return -ENOMEM;
-       }
 
        /* public fields */
 
@@ -1141,7 +1138,6 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
 
                urb = usb_alloc_urb(iso_packets, GFP_KERNEL);
                if (!urb) {
-                       dev_err(dev, "%s: no memory for urb %d!\n", __func__, i);
                        error = -ENOMEM;
                        goto fail_unbind;
                }
@@ -1151,7 +1147,6 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
                /* zero the tx padding to avoid leaking information */
                buffer = kzalloc(channel->buf_size, GFP_KERNEL);
                if (!buffer) {
-                       dev_err(dev, "%s: no memory for buffer %d!\n", __func__, i);
                        error = -ENOMEM;
                        goto fail_unbind;
                }
@@ -1182,7 +1177,6 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
        instance->cell_buf = kmalloc(instance->rx_channel.stride, GFP_KERNEL);
 
        if (!instance->cell_buf) {
-               dev_err(dev, "%s: no memory for cell buffer!\n", __func__);
                error = -ENOMEM;
                goto fail_unbind;
        }
index 0f3f62e81e5b20b50140ab482df70e818de860a5..fef0d8fcd91646b89d1f081c40c129f1faf957c7 100644 (file)
@@ -492,8 +492,6 @@ static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
        struct acm *acm;
        int retval;
 
-       dev_dbg(tty->dev, "%s\n", __func__);
-
        acm = acm_get_by_minor(tty->index);
        if (!acm)
                return -ENODEV;
@@ -515,8 +513,6 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
 {
        struct acm *acm = tty->driver_data;
 
-       dev_dbg(tty->dev, "%s\n", __func__);
-
        return tty_port_open(&acm->port, tty, filp);
 }
 
@@ -545,8 +541,6 @@ static int acm_port_activate(struct tty_port *port, struct tty_struct *tty)
        int retval = -ENODEV;
        int i;
 
-       dev_dbg(&acm->control->dev, "%s\n", __func__);
-
        mutex_lock(&acm->mutex);
        if (acm->disconnected)
                goto disconnected;
@@ -607,8 +601,6 @@ static void acm_port_destruct(struct tty_port *port)
 {
        struct acm *acm = container_of(port, struct acm, port);
 
-       dev_dbg(&acm->control->dev, "%s\n", __func__);
-
        acm_release_minor(acm);
        usb_put_intf(acm->control);
        kfree(acm->country_codes);
@@ -622,8 +614,6 @@ static void acm_port_shutdown(struct tty_port *port)
        struct acm_wb *wb;
        int i;
 
-       dev_dbg(&acm->control->dev, "%s\n", __func__);
-
        /*
         * Need to grab write_lock to prevent race with resume, but no need to
         * hold it due to the tty-port initialised flag.
@@ -654,21 +644,21 @@ static void acm_port_shutdown(struct tty_port *port)
 static void acm_tty_cleanup(struct tty_struct *tty)
 {
        struct acm *acm = tty->driver_data;
-       dev_dbg(&acm->control->dev, "%s\n", __func__);
+
        tty_port_put(&acm->port);
 }
 
 static void acm_tty_hangup(struct tty_struct *tty)
 {
        struct acm *acm = tty->driver_data;
-       dev_dbg(&acm->control->dev, "%s\n", __func__);
+
        tty_port_hangup(&acm->port);
 }
 
 static void acm_tty_close(struct tty_struct *tty, struct file *filp)
 {
        struct acm *acm = tty->driver_data;
-       dev_dbg(&acm->control->dev, "%s\n", __func__);
+
        tty_port_close(&acm->port, tty, filp);
 }
 
@@ -1533,8 +1523,6 @@ static void stop_data_traffic(struct acm *acm)
 {
        int i;
 
-       dev_dbg(&acm->control->dev, "%s\n", __func__);
-
        usb_kill_urb(acm->ctrlurb);
        for (i = 0; i < ACM_NW; i++)
                usb_kill_urb(acm->wb[i].urb);
@@ -1551,8 +1539,6 @@ static void acm_disconnect(struct usb_interface *intf)
        struct tty_struct *tty;
        int i;
 
-       dev_dbg(&intf->dev, "%s\n", __func__);
-
        /* sibling interface is already cleaning up */
        if (!acm)
                return;
index 337948c42110a82c8564be326ad0e65ebb848080..0a6369510f2dd52b0908ca874df90653f6c7bfea 100644 (file)
@@ -58,6 +58,7 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);
 #define WDM_SUSPENDING         8
 #define WDM_RESETTING          9
 #define WDM_OVERFLOW           10
+#define WDM_DRAIN_ON_OPEN      11
 
 #define WDM_MAX                        16
 
@@ -154,6 +155,9 @@ static void wdm_out_callback(struct urb *urb)
        wake_up(&desc->wait);
 }
 
+/* forward declaration */
+static int service_outstanding_interrupt(struct wdm_device *desc);
+
 static void wdm_in_callback(struct urb *urb)
 {
        struct wdm_device *desc = urb->context;
@@ -167,18 +171,18 @@ static void wdm_in_callback(struct urb *urb)
                switch (status) {
                case -ENOENT:
                        dev_dbg(&desc->intf->dev,
-                               "nonzero urb status received: -ENOENT");
+                               "nonzero urb status received: -ENOENT\n");
                        goto skip_error;
                case -ECONNRESET:
                        dev_dbg(&desc->intf->dev,
-                               "nonzero urb status received: -ECONNRESET");
+                               "nonzero urb status received: -ECONNRESET\n");
                        goto skip_error;
                case -ESHUTDOWN:
                        dev_dbg(&desc->intf->dev,
-                               "nonzero urb status received: -ESHUTDOWN");
+                               "nonzero urb status received: -ESHUTDOWN\n");
                        goto skip_error;
                case -EPIPE:
-                       dev_err(&desc->intf->dev,
+                       dev_dbg(&desc->intf->dev,
                                "nonzero urb status received: -EPIPE\n");
                        break;
                default:
@@ -188,7 +192,13 @@ static void wdm_in_callback(struct urb *urb)
                }
        }
 
-       desc->rerr = status;
+       /*
+        * only set a new error if there is no previous error.
+        * Errors are only cleared during read/open
+        */
+       if (desc->rerr  == 0)
+               desc->rerr = status;
+
        if (length + desc->length > desc->wMaxCommand) {
                /* The buffer would overflow */
                set_bit(WDM_OVERFLOW, &desc->flags);
@@ -200,10 +210,40 @@ static void wdm_in_callback(struct urb *urb)
                        desc->reslength = length;
                }
        }
+
+       /*
+        * Handling devices with the WDM_DRAIN_ON_OPEN flag set:
+        * If desc->resp_count is unset, then the urb was submitted
+        * without a prior notification.  If the device returned any
+        * data, then this implies that it had messages queued without
+        * notifying us.  Continue reading until that queue is flushed.
+        */
+       if (!desc->resp_count) {
+               if (!length) {
+                       /* do not propagate the expected -EPIPE */
+                       desc->rerr = 0;
+                       goto unlock;
+               }
+               dev_dbg(&desc->intf->dev, "got %d bytes without notification\n", length);
+               set_bit(WDM_RESPONDING, &desc->flags);
+               usb_submit_urb(desc->response, GFP_ATOMIC);
+       }
+
 skip_error:
+       set_bit(WDM_READ, &desc->flags);
        wake_up(&desc->wait);
 
-       set_bit(WDM_READ, &desc->flags);
+       if (desc->rerr) {
+               /*
+                * Since there was an error, userspace may decide to not read
+                * any data after poll'ing.
+                * We should respond to further attempts from the device to send
+                * data, so that we can get unstuck.
+                */
+               service_outstanding_interrupt(desc);
+       }
+
+unlock:
        spin_unlock(&desc->iuspin);
 }
 
@@ -244,18 +284,18 @@ static void wdm_int_callback(struct urb *urb)
        switch (dr->bNotificationType) {
        case USB_CDC_NOTIFY_RESPONSE_AVAILABLE:
                dev_dbg(&desc->intf->dev,
-                       "NOTIFY_RESPONSE_AVAILABLE received: index %d len %d",
+                       "NOTIFY_RESPONSE_AVAILABLE received: index %d len %d\n",
                        le16_to_cpu(dr->wIndex), le16_to_cpu(dr->wLength));
                break;
 
        case USB_CDC_NOTIFY_NETWORK_CONNECTION:
 
                dev_dbg(&desc->intf->dev,
-                       "NOTIFY_NETWORK_CONNECTION %s network",
+                       "NOTIFY_NETWORK_CONNECTION %s network\n",
                        dr->wValue ? "connected to" : "disconnected from");
                goto exit;
        case USB_CDC_NOTIFY_SPEED_CHANGE:
-               dev_dbg(&desc->intf->dev, "SPEED_CHANGE received (len %u)",
+               dev_dbg(&desc->intf->dev, "SPEED_CHANGE received (len %u)\n",
                        urb->actual_length);
                goto exit;
        default:
@@ -274,8 +314,7 @@ static void wdm_int_callback(struct urb *urb)
                && !test_bit(WDM_DISCONNECTING, &desc->flags)
                && !test_bit(WDM_SUSPENDING, &desc->flags)) {
                rv = usb_submit_urb(desc->response, GFP_ATOMIC);
-               dev_dbg(&desc->intf->dev, "%s: usb_submit_urb %d",
-                       __func__, rv);
+               dev_dbg(&desc->intf->dev, "submit response URB %d\n", rv);
        }
        spin_unlock(&desc->iuspin);
        if (rv < 0) {
@@ -417,7 +456,7 @@ static ssize_t wdm_write
                rv = usb_translate_errors(rv);
                goto out_free_mem_pm;
        } else {
-               dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d",
+               dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d\n",
                        le16_to_cpu(req->wIndex));
        }
 
@@ -436,17 +475,14 @@ out_free_mem:
 }
 
 /*
- * clear WDM_READ flag and possibly submit the read urb if resp_count
- * is non-zero.
+ * Submit the read urb if resp_count is non-zero.
  *
  * Called with desc->iuspin locked
  */
-static int clear_wdm_read_flag(struct wdm_device *desc)
+static int service_outstanding_interrupt(struct wdm_device *desc)
 {
        int rv = 0;
 
-       clear_bit(WDM_READ, &desc->flags);
-
        /* submit read urb only if the device is waiting for it */
        if (!desc->resp_count || !--desc->resp_count)
                goto out;
@@ -537,8 +573,9 @@ retry:
                }
 
                if (!desc->reslength) { /* zero length read */
-                       dev_dbg(&desc->intf->dev, "%s: zero length - clearing WDM_READ\n", __func__);
-                       rv = clear_wdm_read_flag(desc);
+                       dev_dbg(&desc->intf->dev, "zero length - clearing WDM_READ\n");
+                       clear_bit(WDM_READ, &desc->flags);
+                       rv = service_outstanding_interrupt(desc);
                        spin_unlock_irq(&desc->iuspin);
                        if (rv < 0)
                                goto err;
@@ -563,8 +600,10 @@ retry:
 
        desc->length -= cntr;
        /* in case we had outstanding data */
-       if (!desc->length)
-               clear_wdm_read_flag(desc);
+       if (!desc->length) {
+               clear_bit(WDM_READ, &desc->flags);
+               service_outstanding_interrupt(desc);
+       }
        spin_unlock_irq(&desc->iuspin);
        rv = cntr;
 
@@ -647,6 +686,17 @@ static int wdm_open(struct inode *inode, struct file *file)
                        dev_err(&desc->intf->dev,
                                "Error submitting int urb - %d\n", rv);
                        rv = usb_translate_errors(rv);
+               } else if (test_bit(WDM_DRAIN_ON_OPEN, &desc->flags)) {
+                       /*
+                        * Some devices keep pending messages queued
+                        * without resending notifications.  We must
+                        * flush the message queue before we can
+                        * assume a one-to-one relationship between
+                        * notifications and messages in the queue
+                        */
+                       dev_dbg(&desc->intf->dev, "draining queued data\n");
+                       set_bit(WDM_RESPONDING, &desc->flags);
+                       rv = usb_submit_urb(desc->response, GFP_KERNEL);
                }
        } else {
                rv = 0;
@@ -673,7 +723,7 @@ static int wdm_release(struct inode *inode, struct file *file)
 
        if (!desc->count) {
                if (!test_bit(WDM_DISCONNECTING, &desc->flags)) {
-                       dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
+                       dev_dbg(&desc->intf->dev, "wdm_release: cleanup\n");
                        kill_urbs(desc);
                        spin_lock_irq(&desc->iuspin);
                        desc->resp_count = 0;
@@ -753,7 +803,8 @@ static void wdm_rxwork(struct work_struct *work)
 /* --- hotplug --- */
 
 static int wdm_create(struct usb_interface *intf, struct usb_endpoint_descriptor *ep,
-               u16 bufsize, int (*manage_power)(struct usb_interface *, int))
+               u16 bufsize, int (*manage_power)(struct usb_interface *, int),
+               bool drain_on_open)
 {
        int rv = -ENOMEM;
        struct wdm_device *desc;
@@ -840,6 +891,68 @@ static int wdm_create(struct usb_interface *intf, struct usb_endpoint_descriptor
 
        desc->manage_power = manage_power;
 
+       /*
+        * "drain_on_open" enables a hack to work around a firmware
+        * issue observed on network functions, in particular MBIM
+        * functions.
+        *
+        * Quoting section 7 of the CDC-WMC r1.1 specification:
+        *
+        *  "The firmware shall interpret GetEncapsulatedResponse as a
+        *   request to read response bytes. The firmware shall send
+        *   the next wLength bytes from the response. The firmware
+        *   shall allow the host to retrieve data using any number of
+        *   GetEncapsulatedResponse requests. The firmware shall
+        *   return a zero- length reply if there are no data bytes
+        *   available.
+        *
+        *   The firmware shall send ResponseAvailable notifications
+        *   periodically, using any appropriate algorithm, to inform
+        *   the host that there is data available in the reply
+        *   buffer. The firmware is allowed to send ResponseAvailable
+        *   notifications even if there is no data available, but
+        *   this will obviously reduce overall performance."
+        *
+        * These requirements, although they make equally sense, are
+        * often not implemented by network functions. Some firmwares
+        * will queue data indefinitely, without ever resending a
+        * notification. The result is that the driver and firmware
+        * loses "syncronization" if the driver ever fails to respond
+        * to a single notification, something which easily can happen
+        * on release(). When this happens, the driver will appear to
+        * never receive notifications for the most current data. Each
+        * notification will only cause a single read, which returns
+        * the oldest data in the firmware's queue.
+        *
+        * The "drain_on_open" hack resolves the situation by draining
+        * data from the firmware until none is returned, without a
+        * prior notification.
+        *
+        * This will inevitably race with the firmware, risking that
+        * we read data from the device before handling the associated
+        * notification. To make things worse, some of the devices
+        * needing the hack do not implement the "return zero if no
+        * data is available" requirement either. Instead they return
+        * an error on the subsequent read in this case.  This means
+        * that "winning" the race can cause an unexpected EIO to
+        * userspace.
+        *
+        * "winning" the race is more likely on resume() than on
+        * open(), and the unexpected error is more harmful in the
+        * middle of an open session. The hack is therefore only
+        * applied on open(), and not on resume() where it logically
+        * would be equally necessary. So we define open() as the only
+        * driver <-> device "syncronization point".  Should we happen
+        * to lose a notification after open(), then syncronization
+        * will be lost until release()
+        *
+        * The hack should not be enabled for CDC WDM devices
+        * conforming to the CDC-WMC r1.1 specification.  This is
+        * ensured by setting drain_on_open to false in wdm_probe().
+        */
+       if (drain_on_open)
+               set_bit(WDM_DRAIN_ON_OPEN, &desc->flags);
+
        spin_lock(&wdm_device_list_lock);
        list_add(&desc->device_list, &wdm_device_list);
        spin_unlock(&wdm_device_list_lock);
@@ -893,7 +1006,7 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
                goto err;
        ep = &iface->endpoint[0].desc;
 
-       rv = wdm_create(intf, ep, maxcom, &wdm_manage_power);
+       rv = wdm_create(intf, ep, maxcom, &wdm_manage_power, false);
 
 err:
        return rv;
@@ -925,7 +1038,7 @@ struct usb_driver *usb_cdc_wdm_register(struct usb_interface *intf,
 {
        int rv = -EINVAL;
 
-       rv = wdm_create(intf, ep, bufsize, manage_power);
+       rv = wdm_create(intf, ep, bufsize, manage_power, true);
        if (rv < 0)
                goto err;
 
@@ -967,7 +1080,7 @@ static void wdm_disconnect(struct usb_interface *intf)
        if (!desc->count)
                cleanup(desc);
        else
-               dev_dbg(&intf->dev, "%s: %d open files - postponing cleanup\n", __func__, desc->count);
+               dev_dbg(&intf->dev, "%d open files - postponing cleanup\n", desc->count);
        mutex_unlock(&wdm_mutex);
 }
 
index 917a55c4480dc4de6e46ab1bc6cf5f9a759aae21..da4f2509f567750663879e25d2d1a53dea8d230d 100644 (file)
@@ -1467,10 +1467,8 @@ static int usbtmc_probe(struct usb_interface *intf,
        if (data->iin_ep_present) {
                /* allocate int urb */
                data->iin_urb = usb_alloc_urb(0, GFP_KERNEL);
-               if (!data->iin_urb) {
-                       dev_err(&intf->dev, "Failed to allocate int urb\n");
+               if (!data->iin_urb)
                        goto error_register;
-               }
 
                /* will reference data in int urb */
                kref_get(&data->kref);
@@ -1478,10 +1476,8 @@ static int usbtmc_probe(struct usb_interface *intf,
                /* allocate buffer for interrupt in */
                data->iin_buffer = kmalloc(data->iin_wMaxPacketSize,
                                        GFP_KERNEL);
-               if (!data->iin_buffer) {
-                       dev_err(&intf->dev, "Failed to allocate int buf\n");
+               if (!data->iin_buffer)
                        goto error_register;
-               }
 
                /* fill interrupt urb */
                usb_fill_int_urb(data->iin_urb, data->usb_dev,
index 01c0c0477a9e93d1c8e1150b80763f5ee6c90a02..e04a34e7a341d64af2262cf0dd436875794ac09a 100644 (file)
@@ -127,16 +127,17 @@ static struct device_type ulpi_dev_type = {
  *
  * Registers a driver with the ULPI bus.
  */
-int ulpi_register_driver(struct ulpi_driver *drv)
+int __ulpi_register_driver(struct ulpi_driver *drv, struct module *module)
 {
        if (!drv->probe)
                return -EINVAL;
 
+       drv->driver.owner = module;
        drv->driver.bus = &ulpi_bus;
 
        return driver_register(&drv->driver);
 }
-EXPORT_SYMBOL_GPL(ulpi_register_driver);
+EXPORT_SYMBOL_GPL(__ulpi_register_driver);
 
 /**
  * ulpi_unregister_driver - unregister a driver with the ULPI bus
index dd280108758f3aff975f25653119d107b1e6cc3a..d6e43ce9679945d791a6442279b5c2ebfc97dd77 100644 (file)
@@ -82,24 +82,3 @@ config USB_OTG_FSM
        help
          Implements OTG Finite State Machine as specified in On-The-Go
          and Embedded Host Supplement to the USB Revision 2.0 Specification.
-
-config USB_ULPI_BUS
-       tristate "USB ULPI PHY interface support"
-       depends on USB_SUPPORT
-       help
-         UTMI+ Low Pin Interface (ULPI) is specification for a commonly used
-         USB 2.0 PHY interface. The ULPI specification defines a standard set
-         of registers that can be used to detect the vendor and product which
-         allows ULPI to be handled as a bus. This module is the driver for that
-         bus.
-
-         The ULPI interfaces (the buses) are registered by the drivers for USB
-         controllers which support ULPI register access and have ULPI PHY
-         attached to them. The ULPI PHY drivers themselves are normal PHY
-         drivers.
-
-         ULPI PHYs provide often functions such as ADP sensing/probing (OTG
-         protocol) and USB charger detection.
-
-         To compile this driver as a module, choose M here: the module will
-         be called ulpi.
index 9780877010b4d19b1302d4b899ff3f19462a18b5..da36b784a0ef7769c98236f4b864f6e0608f4ce7 100644 (file)
@@ -5,8 +5,9 @@
 usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o
 usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o
 usbcore-y += devio.o notify.o generic.o quirks.o devices.o
-usbcore-y += port.o of.o
+usbcore-y += port.o
 
+usbcore-$(CONFIG_OF)           += of.o
 usbcore-$(CONFIG_PCI)          += hcd-pci.o
 usbcore-$(CONFIG_ACPI)         += usb-acpi.o
 
index d2e3f655c26f6ce16e4b63a82d7e83afbd15a524..746c47d86cf5e133b2d1d4fa1885bf0ac3a2a662 100644 (file)
@@ -2517,10 +2517,8 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver,
        struct usb_hcd *hcd;
 
        hcd = kzalloc(sizeof(*hcd) + driver->hcd_priv_size, GFP_KERNEL);
-       if (!hcd) {
-               dev_dbg (dev, "hcd alloc failed\n");
+       if (!hcd)
                return NULL;
-       }
        if (primary_hcd == NULL) {
                hcd->address0_mutex = kmalloc(sizeof(*hcd->address0_mutex),
                                GFP_KERNEL);
@@ -3033,7 +3031,7 @@ EXPORT_SYMBOL_GPL(usb_hcd_platform_shutdown);
 
 /*-------------------------------------------------------------------------*/
 
-#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)
+#if IS_ENABLED(CONFIG_USB_MON)
 
 const struct usb_mon_operations *mon_ops;
 
index 1d5fc32d06d007a6f64526a531da8ae69e8e6950..b48dc76385b652ac5c3bd27b2555e35e59d6eaa9 100644 (file)
@@ -1823,10 +1823,8 @@ descriptor_error:
        dev_info(&intf->dev, "USB hub found\n");
 
        hub = kzalloc(sizeof(*hub), GFP_KERNEL);
-       if (!hub) {
-               dev_dbg(&intf->dev, "couldn't kmalloc hub struct\n");
+       if (!hub)
                return -ENOMEM;
-       }
 
        kref_init(&hub->kref);
        hub->intfdev = &intf->dev;
@@ -5337,11 +5335,10 @@ static int descriptors_changed(struct usb_device *udev,
        }
 
        buf = kmalloc(len, GFP_NOIO);
-       if (buf == NULL) {
-               dev_err(&udev->dev, "no mem to re-read configs after reset\n");
+       if (!buf)
                /* assume the worst */
                return 1;
-       }
+
        for (index = 0; index < udev->descriptor.bNumConfigurations; index++) {
                old_length = le16_to_cpu(udev->config[index].desc.wTotalLength);
                length = usb_get_descriptor(udev, USB_DT_CONFIG, index, buf,
index 0406a59f05510cb1dee98ffbf22b55c0ccd65750..5ab5c1a81462b621d335b2f3a9ef40268dc73a99 100644 (file)
@@ -1760,17 +1760,14 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
                nintf = cp->desc.bNumInterfaces;
                new_interfaces = kmalloc(nintf * sizeof(*new_interfaces),
                                GFP_NOIO);
-               if (!new_interfaces) {
-                       dev_err(&dev->dev, "Out of memory\n");
+               if (!new_interfaces)
                        return -ENOMEM;
-               }
 
                for (; n < nintf; ++n) {
                        new_interfaces[n] = kzalloc(
                                        sizeof(struct usb_interface),
                                        GFP_NOIO);
                        if (!new_interfaces[n]) {
-                               dev_err(&dev->dev, "Out of memory\n");
                                ret = -ENOMEM;
 free_interfaces:
                                while (--n >= 0)
index 2289700c31d6e2fb3fd55e58280a32a48a676703..3de4f8873984d2d04749f2f87b8b5c0fb2b9f59b 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <linux/of.h>
+#include <linux/usb/of.h>
 
 /**
  * usb_of_get_child_node - Find the device node match port number
index a95b0c989c216eca774abd0709451096fda19792..085049d37d7a5b23ff8dbf44b02afc1837fe3b68 100644 (file)
@@ -38,7 +38,7 @@ static struct usb_device_id whitelist_table[] = {
 { USB_DEVICE(0x0525, 0xa4a2), },
 #endif
 
-#if    defined(CONFIG_USB_TEST) || defined(CONFIG_USB_TEST_MODULE)
+#if    IS_ENABLED(CONFIG_USB_TEST)
 /* gadget zero, for testing */
 { USB_DEVICE(0x0525, 0xa4a0), },
 #endif
index c601e25b609fb58e6842c18e62e5c484c98182ae..a9039696476e68c8da475bbe40e1b841e64d903b 100644 (file)
@@ -68,10 +68,8 @@ struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags)
        urb = kmalloc(sizeof(struct urb) +
                iso_packets * sizeof(struct usb_iso_packet_descriptor),
                mem_flags);
-       if (!urb) {
-               printk(KERN_ERR "alloc_urb: kmalloc failed\n");
+       if (!urb)
                return NULL;
-       }
        usb_init_urb(urb);
        return urb;
 }
index af46adfae41ca5fd92b1401eff078e84bf27c7aa..2ff03ae08e144d8541c6f8bfca5afb6874e87049 100644 (file)
@@ -3908,17 +3908,13 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
 
        hsotg->ctrl_buff = devm_kzalloc(hsotg->dev,
                        DWC2_CTRL_BUFF_SIZE, GFP_KERNEL);
-       if (!hsotg->ctrl_buff) {
-               dev_err(dev, "failed to allocate ctrl request buff\n");
+       if (!hsotg->ctrl_buff)
                return -ENOMEM;
-       }
 
        hsotg->ep0_buff = devm_kzalloc(hsotg->dev,
                        DWC2_CTRL_BUFF_SIZE, GFP_KERNEL);
-       if (!hsotg->ep0_buff) {
-               dev_err(dev, "failed to allocate ctrl reply buff\n");
+       if (!hsotg->ep0_buff)
                return -ENOMEM;
-       }
 
        ret = devm_request_irq(hsotg->dev, irq, dwc2_hsotg_irq, IRQF_SHARED,
                                dev_name(hsotg->dev), hsotg);
index 2df3d04d26f5687b9bb84499b0ec55648a0f45a0..df5a065780054f21841ca9f08b8ab118922c530b 100644 (file)
@@ -5040,7 +5040,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
 
        /* Create new workqueue and init work */
        retval = -ENOMEM;
-       hsotg->wq_otg = create_singlethread_workqueue("dwc2");
+       hsotg->wq_otg = alloc_ordered_workqueue("dwc2", 0);
        if (!hsotg->wq_otg) {
                dev_err(hsotg->dev, "Failed to create workqueue\n");
                goto error2;
index a64ce1c94d6d36901a97cda2a62c536423420eb7..b97cde76914daae6290af9d101a3efa757072a00 100644 (file)
@@ -1,7 +1,7 @@
 config USB_DWC3
        tristate "DesignWare USB3 DRD Core Support"
        depends on (USB || USB_GADGET) && HAS_DMA
-       select USB_XHCI_PLATFORM if USB_SUPPORT && USB_XHCI_HCD
+       select USB_XHCI_PLATFORM if USB_XHCI_HCD
        help
          Say Y or M here if your system has a Dual Role SuperSpeed
          USB controller based on the DesignWare USB3 IP Core.
index 8bb011ea78f7df483f23a0325fc082f36fb8b900..4fff51b8a18e4062b4e99ba97b424c93cc2416d7 100644 (file)
@@ -421,10 +421,8 @@ static int qe_ep_rxbd_update(struct qe_ep *ep)
        bd = ep->rxbase;
 
        ep->rxframe = kmalloc(sizeof(*ep->rxframe), GFP_ATOMIC);
-       if (ep->rxframe == NULL) {
-               dev_err(ep->udc->dev, "malloc rxframe failed\n");
+       if (!ep->rxframe)
                return -ENOMEM;
-       }
 
        qe_frame_init(ep->rxframe);
 
@@ -435,9 +433,7 @@ static int qe_ep_rxbd_update(struct qe_ep *ep)
 
        size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * (bdring_len + 1);
        ep->rxbuffer = kzalloc(size, GFP_ATOMIC);
-       if (ep->rxbuffer == NULL) {
-               dev_err(ep->udc->dev, "malloc rxbuffer failed,size=%d\n",
-                               size);
+       if (!ep->rxbuffer) {
                kfree(ep->rxframe);
                return -ENOMEM;
        }
@@ -668,10 +664,8 @@ static int qe_ep_init(struct qe_udc *udc,
 
        if ((ep->tm == USBP_TM_CTL) || (ep->dir == USB_DIR_IN)) {
                ep->txframe = kmalloc(sizeof(*ep->txframe), GFP_ATOMIC);
-               if (ep->txframe == NULL) {
-                       dev_err(udc->dev, "malloc txframe failed\n");
+               if (!ep->txframe)
                        goto en_done2;
-               }
                qe_frame_init(ep->txframe);
        }
 
@@ -2344,10 +2338,8 @@ static struct qe_udc *qe_udc_config(struct platform_device *ofdev)
        u32 offset;
 
        udc = kzalloc(sizeof(*udc), GFP_KERNEL);
-       if (udc == NULL) {
-               dev_err(&ofdev->dev, "malloc udc failed\n");
+       if (!udc)
                goto cleanup;
-       }
 
        udc->dev = &ofdev->dev;
 
index d2205d9e0c8b43265901352548342b0e8646ca97..1400415fe67ac863a5fafe5f4395e92c5298c710 100644 (file)
@@ -1767,8 +1767,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
        /* alloc, and start init */
        dev = kzalloc (sizeof *dev, GFP_KERNEL);
-       if (dev == NULL){
-               pr_debug("enomem %s\n", pci_name(pdev));
+       if (!dev) {
                retval = -ENOMEM;
                goto err;
        }
index 9b7d39484ed3afa55c95a254379b995341bc7ad4..a8709f9e56488133dcf6be3979b2b49ea8875bb6 100644 (file)
@@ -2875,7 +2875,7 @@ bad_on_1710:
        xceiv = NULL;
        /* "udc" is now valid */
        pullup_disable(udc);
-#if    defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
+#if    IS_ENABLED(CONFIG_USB_OHCI_HCD)
        udc->gadget.is_otg = (config->otg != 0);
 #endif
 
index f8bf290f189444c5544f43d7a047981beab5dbc2..588e2531b8b81e05365f0d85fabd1e90452540a4 100644 (file)
@@ -973,10 +973,8 @@ static struct usb_request *xudc_ep_alloc_request(struct usb_ep *_ep,
 
        udc = ep->udc;
        req = kzalloc(sizeof(*req), gfp_flags);
-       if (!req) {
-               dev_err(udc->dev, "%s:not enough memory", __func__);
+       if (!req)
                return NULL;
-       }
 
        req->ep = ep;
        INIT_LIST_HEAD(&req->queue);
index 172ef17911aad33fd5bc34a2d68e75d64ee830bf..e0761d92f2b6d31ff07b74ccfbcf6beddd4e3391 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
+#include <linux/of_platform.h>
 #include <linux/usb/ehci_pdriver.h>
 #include <linux/usb/ohci_pdriver.h>
 
@@ -34,6 +35,9 @@ MODULE_AUTHOR("Hauke Mehrtens");
 MODULE_DESCRIPTION("Common USB driver for BCMA Bus");
 MODULE_LICENSE("GPL");
 
+/* See BCMA_CLKCTLST_EXTRESREQ and BCMA_CLKCTLST_EXTRESST */
+#define USB_BCMA_CLKCTLST_USB_CLK_REQ                  0x00000100
+
 struct bcma_hcd_device {
        struct bcma_device *core;
        struct platform_device *ehci_dev;
@@ -165,6 +169,76 @@ static void bcma_hcd_init_chip_mips(struct bcma_device *dev)
        }
 }
 
+/**
+ * bcma_hcd_usb20_old_arm_init - Initialize old USB 2.0 controller on ARM
+ *
+ * Old USB 2.0 core is identified as BCMA_CORE_USB20_HOST and was introduced
+ * long before Northstar devices. It seems some cheaper chipsets like BCM53573
+ * still use it.
+ * Initialization of this old core differs between MIPS and ARM.
+ */
+static int bcma_hcd_usb20_old_arm_init(struct bcma_hcd_device *usb_dev)
+{
+       struct bcma_device *core = usb_dev->core;
+       struct device *dev = &core->dev;
+       struct bcma_device *pmu_core;
+
+       usleep_range(10000, 20000);
+       if (core->id.rev < 5)
+               return 0;
+
+       pmu_core = bcma_find_core(core->bus, BCMA_CORE_PMU);
+       if (!pmu_core) {
+               dev_err(dev, "Could not find PMU core\n");
+               return -ENOENT;
+       }
+
+       /* Take USB core out of reset */
+       bcma_awrite32(core, BCMA_IOCTL, BCMA_IOCTL_CLK | BCMA_IOCTL_FGC);
+       usleep_range(100, 200);
+       bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
+       usleep_range(100, 200);
+       bcma_awrite32(core, BCMA_RESET_CTL, 0);
+       usleep_range(100, 200);
+       bcma_awrite32(core, BCMA_IOCTL, BCMA_IOCTL_CLK);
+       usleep_range(100, 200);
+
+       /* Enable Misc PLL */
+       bcma_write32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT |
+                                         BCMA_CLKCTLST_HQCLKREQ |
+                                         USB_BCMA_CLKCTLST_USB_CLK_REQ);
+       usleep_range(100, 200);
+
+       bcma_write32(core, 0x510, 0xc7f85000);
+       bcma_write32(core, 0x510, 0xc7f85003);
+       usleep_range(300, 600);
+
+       /* Program USB PHY PLL parameters */
+       bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_ADDR, 0x6);
+       bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_DATA, 0x005360c1);
+       usleep_range(100, 200);
+       bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_ADDR, 0x7);
+       bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_DATA, 0x0);
+       usleep_range(100, 200);
+       bcma_set32(pmu_core, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
+       usleep_range(100, 200);
+
+       bcma_write32(core, 0x510, 0x7f8d007);
+       udelay(1000);
+
+       /* Take controller out of reset */
+       bcma_write32(core, 0x200, 0x4ff);
+       usleep_range(25, 50);
+       bcma_write32(core, 0x200, 0x6ff);
+       usleep_range(25, 50);
+       bcma_write32(core, 0x200, 0x7ff);
+       usleep_range(25, 50);
+
+       of_platform_default_populate(dev->of_node, NULL, dev);
+
+       return 0;
+}
+
 static void bcma_hcd_init_chip_arm_phy(struct bcma_device *dev)
 {
        struct bcma_device *arm_core;
@@ -338,6 +412,18 @@ err_unregister_ohci_dev:
        return err;
 }
 
+static int bcma_hcd_usb30_init(struct bcma_hcd_device *bcma_hcd)
+{
+       struct bcma_device *core = bcma_hcd->core;
+       struct device *dev = &core->dev;
+
+       bcma_core_enable(core, 0);
+
+       of_platform_default_populate(dev->of_node, NULL, dev);
+
+       return 0;
+}
+
 static int bcma_hcd_probe(struct bcma_device *core)
 {
        int err;
@@ -357,14 +443,24 @@ static int bcma_hcd_probe(struct bcma_device *core)
 
        switch (core->id.id) {
        case BCMA_CORE_USB20_HOST:
+               if (IS_ENABLED(CONFIG_ARM))
+                       err = bcma_hcd_usb20_old_arm_init(usb_dev);
+               else if (IS_ENABLED(CONFIG_MIPS))
+                       err = bcma_hcd_usb20_init(usb_dev);
+               else
+                       err = -ENOTSUPP;
+               break;
        case BCMA_CORE_NS_USB20:
                err = bcma_hcd_usb20_init(usb_dev);
-               if (err)
-                       return err;
+               break;
+       case BCMA_CORE_NS_USB30:
+               err = bcma_hcd_usb30_init(usb_dev);
                break;
        default:
                return -ENODEV;
        }
+       if (err)
+               return err;
 
        bcma_set_drvdata(core, usb_dev);
        return 0;
@@ -416,6 +512,7 @@ static int bcma_hcd_resume(struct bcma_device *dev)
 static const struct bcma_device_id bcma_hcd_table[] = {
        BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS),
        BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_USB20, BCMA_ANY_REV, BCMA_ANY_CLASS),
+       BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_USB30, BCMA_ANY_REV, BCMA_ANY_CLASS),
        {},
 };
 MODULE_DEVICE_TABLE(bcma, bcma_hcd_table);
index 6816b8c371d0cd3d9925cd78cfd70cfe4b7b812e..876dca4fc2162520603afdfd430e26d54b82531f 100644 (file)
@@ -38,7 +38,7 @@
 #include "ehci.h"
 
 #define DRIVER_DESC "EHCI generic platform driver"
-#define EHCI_MAX_CLKS 3
+#define EHCI_MAX_CLKS 4
 #define EHCI_MAX_RSTS 3
 #define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv)
 
index 0960f41f945aba959da6efd566754b3b6553b124..55a0ae6f2d7430cdd4846a121efaa2620ae379cc 100644 (file)
@@ -310,10 +310,8 @@ static struct fhci_usb *fhci_create_lld(struct fhci_hcd *fhci)
 
        /* allocate memory for SCC data structure */
        usb = kzalloc(sizeof(*usb), GFP_KERNEL);
-       if (!usb) {
-               fhci_err(fhci, "no memory for SCC data struct\n");
+       if (!usb)
                return NULL;
-       }
 
        usb->fhci = fhci;
        usb->hc_list = fhci->hc_list;
index 1044b0f9d656f122f4bf3a994465147683f9b05f..f07ccb25bc244f4f98c33a80d12a9c874e3696c1 100644 (file)
@@ -222,23 +222,17 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
        pdata->controller_ver = usb_get_ver_info(np);
 
        /* Activate Erratum by reading property in device tree */
-       if (of_get_property(np, "fsl,usb-erratum-a007792", NULL))
-               pdata->has_fsl_erratum_a007792 = 1;
-       else
-               pdata->has_fsl_erratum_a007792 = 0;
-       if (of_get_property(np, "fsl,usb-erratum-a005275", NULL))
-               pdata->has_fsl_erratum_a005275 = 1;
-       else
-               pdata->has_fsl_erratum_a005275 = 0;
+       pdata->has_fsl_erratum_a007792 =
+               of_property_read_bool(np, "fsl,usb-erratum-a007792");
+       pdata->has_fsl_erratum_a005275 =
+               of_property_read_bool(np, "fsl,usb-erratum-a005275");
 
        /*
         * Determine whether phy_clk_valid needs to be checked
         * by reading property in device tree
         */
-       if (of_get_property(np, "phy-clk-valid", NULL))
-               pdata->check_phy_clk_valid = 1;
-       else
-               pdata->check_phy_clk_valid = 0;
+       pdata->check_phy_clk_valid =
+               of_property_read_bool(np, "phy-clk-valid");
 
        if (pdata->have_sysif_regs) {
                if (pdata->controller_ver == FSL_USB_VER_NONE) {
index 2f7690092a7ffb6e67ca893d9d491f48da6be8d3..369869a29ebd4d2ead3fda4efcddeb1d745a6d5c 100644 (file)
@@ -1856,15 +1856,11 @@ max3421_probe(struct spi_device *spi)
        INIT_LIST_HEAD(&max3421_hcd->ep_list);
 
        max3421_hcd->tx = kmalloc(sizeof(*max3421_hcd->tx), GFP_KERNEL);
-       if (!max3421_hcd->tx) {
-               dev_err(&spi->dev, "failed to kmalloc tx buffer\n");
+       if (!max3421_hcd->tx)
                goto error;
-       }
        max3421_hcd->rx = kmalloc(sizeof(*max3421_hcd->rx), GFP_KERNEL);
-       if (!max3421_hcd->rx) {
-               dev_err(&spi->dev, "failed to kmalloc rx buffer\n");
+       if (!max3421_hcd->rx)
                goto error;
-       }
 
        max3421_hcd->spi_thread = kthread_run(max3421_spi_thread, hcd,
                                              "max3421_spi_thread");
index d177372bb357ca51a6304c8a951df0ed2c8863ae..31102170c7a0bf07f4d8da0a6b26ea02e18b521b 100644 (file)
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 #include <linux/usb.h>
 #include <linux/usb/hcd.h>
+#include <soc/at91/atmel-sfr.h>
 
 #include "ohci.h"
 
@@ -51,6 +54,7 @@ struct ohci_at91_priv {
        struct clk *hclk;
        bool clocked;
        bool wakeup;            /* Saved wake-up state for resume */
+       struct regmap *sfr_regmap;
 };
 /* interface and function clocks; sometimes also an AHB clock */
 
@@ -134,6 +138,17 @@ static void at91_stop_hc(struct platform_device *pdev)
 
 static void usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *);
 
+struct regmap *at91_dt_syscon_sfr(void)
+{
+       struct regmap *regmap;
+
+       regmap = syscon_regmap_lookup_by_compatible("atmel,sama5d2-sfr");
+       if (IS_ERR(regmap))
+               regmap = NULL;
+
+       return regmap;
+}
+
 /* configure so an HC device and id are always provided */
 /* always called with process context; sleeping is OK */
 
@@ -197,6 +212,10 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
                goto err;
        }
 
+       ohci_at91->sfr_regmap = at91_dt_syscon_sfr();
+       if (!ohci_at91->sfr_regmap)
+               dev_warn(dev, "failed to find sfr node\n");
+
        board = hcd->self.controller->platform_data;
        ohci = hcd_to_ohci(hcd);
        ohci->num_ports = board->ports;
@@ -282,6 +301,28 @@ static int ohci_at91_hub_status_data(struct usb_hcd *hcd, char *buf)
        return length;
 }
 
+static int ohci_at91_port_suspend(struct regmap *regmap, u8 set)
+{
+       u32 regval;
+       int ret;
+
+       if (!regmap)
+               return 0;
+
+       ret = regmap_read(regmap, AT91_SFR_OHCIICR, &regval);
+       if (ret)
+               return ret;
+
+       if (set)
+               regval |= AT91_OHCIICR_USB_SUSPEND;
+       else
+               regval &= ~AT91_OHCIICR_USB_SUSPEND;
+
+       regmap_write(regmap, AT91_SFR_OHCIICR, regval);
+
+       return 0;
+}
+
 /*
  * Look at the control requests to the root hub and see if we need to override.
  */
@@ -289,6 +330,7 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                                 u16 wIndex, char *buf, u16 wLength)
 {
        struct at91_usbh_data *pdata = dev_get_platdata(hcd->self.controller);
+       struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
        struct usb_hub_descriptor *desc;
        int ret = -EINVAL;
        u32 *data = (u32 *)buf;
@@ -301,7 +343,8 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 
        switch (typeReq) {
        case SetPortFeature:
-               if (wValue == USB_PORT_FEAT_POWER) {
+               switch (wValue) {
+               case USB_PORT_FEAT_POWER:
                        dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n");
                        if (valid_port(wIndex)) {
                                ohci_at91_usb_set_power(pdata, wIndex, 1);
@@ -309,6 +352,15 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        }
 
                        goto out;
+
+               case USB_PORT_FEAT_SUSPEND:
+                       dev_dbg(hcd->self.controller, "SetPortFeat: SUSPEND\n");
+                       if (valid_port(wIndex)) {
+                               ohci_at91_port_suspend(ohci_at91->sfr_regmap,
+                                                      1);
+                               return 0;
+                       }
+                       break;
                }
                break;
 
@@ -342,6 +394,16 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                                ohci_at91_usb_set_power(pdata, wIndex, 0);
                                return 0;
                        }
+                       break;
+
+               case USB_PORT_FEAT_SUSPEND:
+                       dev_dbg(hcd->self.controller, "ClearPortFeature: SUSPEND\n");
+                       if (valid_port(wIndex)) {
+                               ohci_at91_port_suspend(ohci_at91->sfr_regmap,
+                                                      0);
+                               return 0;
+                       }
+                       break;
                }
                break;
        }
@@ -599,6 +661,8 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
        if (ohci_at91->wakeup)
                enable_irq_wake(hcd->irq);
 
+       ohci_at91_port_suspend(ohci_at91->sfr_regmap, 1);
+
        ret = ohci_suspend(hcd, ohci_at91->wakeup);
        if (ret) {
                if (ohci_at91->wakeup)
@@ -638,6 +702,9 @@ ohci_hcd_at91_drv_resume(struct device *dev)
        at91_start_clock(ohci_at91);
 
        ohci_resume(hcd, false);
+
+       ohci_at91_port_suspend(ohci_at91->sfr_regmap, 0);
+
        return 0;
 }
 
index de7c68602a7e907fb5227205895d2352f28bd714..495c1454b9e81e229efc86086320375a1c3dee6f 100644 (file)
@@ -36,7 +36,6 @@
 #include <mach/mux.h>
 
 #include <mach/hardware.h>
-#include <mach/irqs.h>
 #include <mach/usb.h>
 
 
index 2ac266d692a2960acb400773738014eb728933b8..3a9ea32508df4e83454b3ce00676ccdf660ac839 100644 (file)
@@ -13,9 +13,7 @@
  * This file is licenced under the GPL.
  */
 
-#include <mach/hardware.h>
 #include <asm/mach-types.h>
-#include <mach/assabet.h>
 #include <asm/hardware/sa1111.h>
 
 #ifndef CONFIG_SA1111
@@ -127,7 +125,7 @@ static int sa1111_start_hc(struct sa1111_dev *dev)
        dev_dbg(&dev->dev, "starting SA-1111 OHCI USB Controller\n");
 
        if (machine_is_xp860() ||
-           machine_has_neponset() ||
+           machine_is_assabet() ||
            machine_is_pfs168() ||
            machine_is_badge4())
                usb_rst = USB_RESET_PWRSENSELOW | USB_RESET_PWRCTRLLOW;
index a7de8e8bb4582bbee1e411a136a3223efcb9ac59..5d3d914ab4fb441f78ab3e5fae799453fb2ec014 100644 (file)
@@ -601,11 +601,8 @@ static int uhci_start(struct usb_hcd *hcd)
 
        uhci->frame_cpu = kcalloc(UHCI_NUMFRAMES, sizeof(*uhci->frame_cpu),
                        GFP_KERNEL);
-       if (!uhci->frame_cpu) {
-               dev_err(uhci_dev(uhci),
-                       "unable to allocate memory for frame pointers\n");
+       if (!uhci->frame_cpu)
                goto err_alloc_frame_cpu;
-       }
 
        uhci->td_pool = dma_pool_create("uhci_td", uhci_dev(uhci),
                        sizeof(struct uhci_td), 16, 0);
index e36372393bb1f8719293a3cc979c95c075277e85..ad8eb575c30a29ed6aa7773c99146de1531b8c20 100644 (file)
@@ -65,7 +65,7 @@ int whc_init(struct whc *whc)
        init_waitqueue_head(&whc->cmd_wq);
        init_waitqueue_head(&whc->async_list_wq);
        init_waitqueue_head(&whc->periodic_list_wq);
-       whc->workqueue = create_singlethread_workqueue(dev_name(&whc->umc->dev));
+       whc->workqueue = alloc_ordered_workqueue(dev_name(&whc->umc->dev), 0);
        if (whc->workqueue == NULL) {
                ret = -ENOMEM;
                goto error;
index 0f53ae0f464e6dd2f7cbb95cb56a0181a9aae741..d39b37be71f01fdda4d0e0704d0e099051ac3097 100644 (file)
@@ -1033,7 +1033,6 @@ static int tegra_xusb_probe(struct platform_device *pdev)
        tegra->phys = devm_kcalloc(&pdev->dev, tegra->num_phys,
                                   sizeof(*tegra->phys), GFP_KERNEL);
        if (!tegra->phys) {
-               dev_err(&pdev->dev, "failed to allocate PHY array\n");
                err = -ENOMEM;
                goto put_padctl;
        }
index 01d96c9b3a75b95b93da48ce9f250722d03d9483..1a4ca02729c274cb83762636e5556ca75e840144 100644 (file)
@@ -295,10 +295,8 @@ static int xhci_setup_msix(struct xhci_hcd *xhci)
        xhci->msix_entries =
                kmalloc((sizeof(struct msix_entry))*xhci->msix_count,
                                GFP_KERNEL);
-       if (!xhci->msix_entries) {
-               xhci_err(xhci, "Failed to allocate MSI-X entries\n");
+       if (!xhci->msix_entries)
                return -ENOMEM;
-       }
 
        for (i = 0; i < xhci->msix_count; i++) {
                xhci->msix_entries[i].entry = i;
index eb8f8d37cd955b67a1c7ec7146694271f70a88d3..47b357760afc245a583e77b5a419b7a6a0b6927b 100644 (file)
@@ -240,6 +240,12 @@ config USB_HSIC_USB3503
        help
          This option enables support for SMSC USB3503 HSIC to USB 2.0 Driver.
 
+config USB_HSIC_USB4604
+       tristate "USB4604 HSIC to USB20 Driver"
+       depends on I2C
+       help
+         This option enables support for SMSC USB4604 HSIC to USB 2.0 Driver.
+
 config USB_LINK_LAYER_TEST
        tristate "USB Link Layer Test driver"
        help
index 3d79faaad2fbdb05e1c9fe3a71e70c71330ef269..3d1992750da427eee344397e55b1f9ae7385aa7c 100644 (file)
@@ -24,6 +24,7 @@ obj-$(CONFIG_USB_USS720)              += uss720.o
 obj-$(CONFIG_USB_SEVSEG)               += usbsevseg.o
 obj-$(CONFIG_USB_YUREX)                        += yurex.o
 obj-$(CONFIG_USB_HSIC_USB3503)         += usb3503.o
+obj-$(CONFIG_USB_HSIC_USB4604)         += usb4604.o
 obj-$(CONFIG_USB_CHAOSKEY)             += chaoskey.o
 obj-$(CONFIG_UCSI)                     += ucsi.o
 
index 3071c0ef909bf0cd828feff797d332e4e33899be..564268fca07a0209ac093675f355ed59da965ad4 100644 (file)
@@ -672,8 +672,7 @@ static int adu_probe(struct usb_interface *interface,
 
        /* allocate memory for our device state and initialize it */
        dev = kzalloc(sizeof(struct adu_device), GFP_KERNEL);
-       if (dev == NULL) {
-               dev_err(&interface->dev, "Out of memory\n");
+       if (!dev) {
                retval = -ENOMEM;
                goto exit;
        }
@@ -710,7 +709,6 @@ static int adu_probe(struct usb_interface *interface,
 
        dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL);
        if (!dev->read_buffer_primary) {
-               dev_err(&interface->dev, "Couldn't allocate read_buffer_primary\n");
                retval = -ENOMEM;
                goto error;
        }
@@ -723,7 +721,6 @@ static int adu_probe(struct usb_interface *interface,
 
        dev->read_buffer_secondary = kmalloc((4 * in_end_size), GFP_KERNEL);
        if (!dev->read_buffer_secondary) {
-               dev_err(&interface->dev, "Couldn't allocate read_buffer_secondary\n");
                retval = -ENOMEM;
                goto error;
        }
@@ -735,29 +732,21 @@ static int adu_probe(struct usb_interface *interface,
        memset(dev->read_buffer_secondary + (3 * in_end_size), 'h', in_end_size);
 
        dev->interrupt_in_buffer = kmalloc(in_end_size, GFP_KERNEL);
-       if (!dev->interrupt_in_buffer) {
-               dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer\n");
+       if (!dev->interrupt_in_buffer)
                goto error;
-       }
 
        /* debug code prime the buffer */
        memset(dev->interrupt_in_buffer, 'i', in_end_size);
 
        dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!dev->interrupt_in_urb) {
-               dev_err(&interface->dev, "Couldn't allocate interrupt_in_urb\n");
+       if (!dev->interrupt_in_urb)
                goto error;
-       }
        dev->interrupt_out_buffer = kmalloc(out_end_size, GFP_KERNEL);
-       if (!dev->interrupt_out_buffer) {
-               dev_err(&interface->dev, "Couldn't allocate interrupt_out_buffer\n");
+       if (!dev->interrupt_out_buffer)
                goto error;
-       }
        dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!dev->interrupt_out_urb) {
-               dev_err(&interface->dev, "Couldn't allocate interrupt_out_urb\n");
+       if (!dev->interrupt_out_urb)
                goto error;
-       }
 
        if (!usb_string(udev, udev->descriptor.iSerialNumber, dev->serial_number,
                        sizeof(dev->serial_number))) {
index a0a3827b4aff75a774a01f2a6edc147989702697..da5ff401a35489614db878afadf8cc8bbdffc852 100644 (file)
@@ -85,7 +85,6 @@ struct appledisplay {
 };
 
 static atomic_t count_displays = ATOMIC_INIT(0);
-static struct workqueue_struct *wq;
 
 static void appledisplay_complete(struct urb *urb)
 {
@@ -122,7 +121,7 @@ static void appledisplay_complete(struct urb *urb)
        case ACD_BTN_BRIGHT_UP:
        case ACD_BTN_BRIGHT_DOWN:
                pdata->button_pressed = 1;
-               queue_delayed_work(wq, &pdata->work, 0);
+               schedule_delayed_work(&pdata->work, 0);
                break;
        case ACD_BTN_NONE:
        default:
@@ -239,7 +238,6 @@ static int appledisplay_probe(struct usb_interface *iface,
        pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL);
        if (!pdata) {
                retval = -ENOMEM;
-               dev_err(&iface->dev, "Out of memory\n");
                goto error;
        }
 
@@ -253,8 +251,6 @@ static int appledisplay_probe(struct usb_interface *iface,
        pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL);
        if (!pdata->msgdata) {
                retval = -ENOMEM;
-               dev_err(&iface->dev,
-                       "Allocating buffer for control messages failed\n");
                goto error;
        }
 
@@ -262,7 +258,6 @@ static int appledisplay_probe(struct usb_interface *iface,
        pdata->urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!pdata->urb) {
                retval = -ENOMEM;
-               dev_err(&iface->dev, "Allocating URB failed\n");
                goto error;
        }
 
@@ -344,7 +339,7 @@ static void appledisplay_disconnect(struct usb_interface *iface)
 
        if (pdata) {
                usb_kill_urb(pdata->urb);
-               cancel_delayed_work(&pdata->work);
+               cancel_delayed_work_sync(&pdata->work);
                backlight_device_unregister(pdata->bd);
                usb_free_coherent(pdata->udev, ACD_URB_BUFFER_LEN,
                        pdata->urbdata, pdata->urb->transfer_dma);
@@ -365,19 +360,11 @@ static struct usb_driver appledisplay_driver = {
 
 static int __init appledisplay_init(void)
 {
-       wq = create_singlethread_workqueue("appledisplay");
-       if (!wq) {
-               printk(KERN_ERR "appledisplay: Could not create work queue\n");
-               return -ENOMEM;
-       }
-
        return usb_register(&appledisplay_driver);
 }
 
 static void __exit appledisplay_exit(void)
 {
-       flush_workqueue(wq);
-       destroy_workqueue(wq);
        usb_deregister(&appledisplay_driver);
 }
 
index 402b94dd25315959dec45d1196c05af227bc32f5..5c93a888c40e565eec60ab8ecfdeaf68b9f3310a 100644 (file)
@@ -79,7 +79,6 @@ static int vendor_command(struct cypress *dev, unsigned char request,
        /* allocate some memory for the i/o buffer*/
        iobuf = kzalloc(CYPRESS_MAX_REQSIZE, GFP_KERNEL);
        if (!iobuf) {
-               dev_err(&dev->udev->dev, "Out of memory!\n");
                retval = -ENOMEM;
                goto error;
        }
@@ -208,10 +207,8 @@ static int cypress_probe(struct usb_interface *interface,
 
        /* allocate memory for our device state and initialize it */
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-       if (dev == NULL) {
-               dev_err(&interface->dev, "Out of memory!\n");
+       if (!dev)
                goto error_mem;
-       }
 
        dev->udev = usb_get_dev(interface_to_usbdev(interface));
 
index 9bab1a33bc16b6518a3b0a8c31e335c8b5ba27fc..9d8bb8dacdcd114691ad36f5c9576982b6c2654f 100644 (file)
@@ -101,10 +101,8 @@ static ssize_t set_brightness(struct device *dev, struct device_attribute *attr,
        int retval;
    
        buffer = kmalloc(8, GFP_KERNEL);
-       if (!buffer) {
-               dev_err(&cytherm->udev->dev, "out of memory\n");
+       if (!buffer)
                return 0;
-       }
 
        cytherm->brightness = simple_strtoul(buf, NULL, 10);
    
@@ -148,10 +146,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char
        int temp, sign;
    
        buffer = kmalloc(8, GFP_KERNEL);
-       if (!buffer) {
-               dev_err(&cytherm->udev->dev, "out of memory\n");
+       if (!buffer)
                return 0;
-       }
 
        /* read temperature */
        retval = vendor_command(cytherm->udev, READ_RAM, TEMP, 0, buffer, 8);
@@ -192,10 +188,8 @@ static ssize_t show_button(struct device *dev, struct device_attribute *attr, ch
        unsigned char *buffer;
 
        buffer = kmalloc(8, GFP_KERNEL);
-       if (!buffer) {
-               dev_err(&cytherm->udev->dev, "out of memory\n");
+       if (!buffer)
                return 0;
-       }
 
        /* check button */
        retval = vendor_command(cytherm->udev, READ_RAM, BUTTON, 0, buffer, 8);
@@ -230,10 +224,8 @@ static ssize_t show_port0(struct device *dev, struct device_attribute *attr, cha
        unsigned char *buffer;
 
        buffer = kmalloc(8, GFP_KERNEL);
-       if (!buffer) {
-               dev_err(&cytherm->udev->dev, "out of memory\n");
+       if (!buffer)
                return 0;
-       }
 
        retval = vendor_command(cytherm->udev, READ_PORT, 0, 0, buffer, 8);
        if (retval)
@@ -257,10 +249,8 @@ static ssize_t set_port0(struct device *dev, struct device_attribute *attr, cons
        int tmp;
    
        buffer = kmalloc(8, GFP_KERNEL);
-       if (!buffer) {
-               dev_err(&cytherm->udev->dev, "out of memory\n");
+       if (!buffer)
                return 0;
-       }
 
        tmp = simple_strtoul(buf, NULL, 10);
    
@@ -290,10 +280,8 @@ static ssize_t show_port1(struct device *dev, struct device_attribute *attr, cha
        unsigned char *buffer;
 
        buffer = kmalloc(8, GFP_KERNEL);
-       if (!buffer) {
-               dev_err(&cytherm->udev->dev, "out of memory\n");
+       if (!buffer)
                return 0;
-       }
 
        retval = vendor_command(cytherm->udev, READ_PORT, 1, 0, buffer, 8);
        if (retval)
@@ -317,10 +305,8 @@ static ssize_t set_port1(struct device *dev, struct device_attribute *attr, cons
        int tmp;
    
        buffer = kmalloc(8, GFP_KERNEL);
-       if (!buffer) {
-               dev_err(&cytherm->udev->dev, "out of memory\n");
+       if (!buffer)
                return 0;
-       }
 
        tmp = simple_strtoul(buf, NULL, 10);
    
@@ -351,10 +337,8 @@ static int cytherm_probe(struct usb_interface *interface,
        int retval = -ENOMEM;
 
        dev = kzalloc (sizeof(struct usb_cytherm), GFP_KERNEL);
-       if (dev == NULL) {
-               dev_err (&interface->dev, "Out of memory\n");
+       if (!dev)
                goto error_mem;
-       }
 
        dev->udev = usb_get_dev(udev);
 
index 9b5b3b2281cae47afb0b88042a5c956a826498f6..9a82f8308ad7fa131e30f88079163d06f62f5807 100644 (file)
@@ -61,9 +61,6 @@ module_param(distrust_firmware, bool, 0);
 MODULE_PARM_DESC(distrust_firmware,
                 "true to distrust firmware power/overcurrent setup");
 extern struct platform_driver u132_platform_driver;
-static struct workqueue_struct *status_queue;
-static struct workqueue_struct *command_queue;
-static struct workqueue_struct *respond_queue;
 /*
  * ftdi_module_lock exists to protect access to global variables
  *
@@ -228,56 +225,56 @@ static void ftdi_elan_init_kref(struct usb_ftdi *ftdi)
 
 static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
 {
-       if (!queue_delayed_work(status_queue, &ftdi->status_work, delta))
+       if (!schedule_delayed_work(&ftdi->status_work, delta))
                kref_put(&ftdi->kref, ftdi_elan_delete);
 }
 
 static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
 {
-       if (queue_delayed_work(status_queue, &ftdi->status_work, delta))
+       if (schedule_delayed_work(&ftdi->status_work, delta))
                kref_get(&ftdi->kref);
 }
 
 static void ftdi_status_cancel_work(struct usb_ftdi *ftdi)
 {
-       if (cancel_delayed_work(&ftdi->status_work))
+       if (cancel_delayed_work_sync(&ftdi->status_work))
                kref_put(&ftdi->kref, ftdi_elan_delete);
 }
 
 static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
 {
-       if (!queue_delayed_work(command_queue, &ftdi->command_work, delta))
+       if (!schedule_delayed_work(&ftdi->command_work, delta))
                kref_put(&ftdi->kref, ftdi_elan_delete);
 }
 
 static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
 {
-       if (queue_delayed_work(command_queue, &ftdi->command_work, delta))
+       if (schedule_delayed_work(&ftdi->command_work, delta))
                kref_get(&ftdi->kref);
 }
 
 static void ftdi_command_cancel_work(struct usb_ftdi *ftdi)
 {
-       if (cancel_delayed_work(&ftdi->command_work))
+       if (cancel_delayed_work_sync(&ftdi->command_work))
                kref_put(&ftdi->kref, ftdi_elan_delete);
 }
 
 static void ftdi_response_requeue_work(struct usb_ftdi *ftdi,
                                       unsigned int delta)
 {
-       if (!queue_delayed_work(respond_queue, &ftdi->respond_work, delta))
+       if (!schedule_delayed_work(&ftdi->respond_work, delta))
                kref_put(&ftdi->kref, ftdi_elan_delete);
 }
 
 static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
 {
-       if (queue_delayed_work(respond_queue, &ftdi->respond_work, delta))
+       if (schedule_delayed_work(&ftdi->respond_work, delta))
                kref_get(&ftdi->kref);
 }
 
 static void ftdi_response_cancel_work(struct usb_ftdi *ftdi)
 {
-       if (cancel_delayed_work(&ftdi->respond_work))
+       if (cancel_delayed_work_sync(&ftdi->respond_work))
                kref_put(&ftdi->kref, ftdi_elan_delete);
 }
 
@@ -785,11 +782,8 @@ static int ftdi_elan_command_engine(struct usb_ftdi *ftdi)
                return 0;
        total_size = ftdi_elan_total_command_size(ftdi, command_size);
        urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!urb) {
-               dev_err(&ftdi->udev->dev, "could not get a urb to write %d commands totaling %d bytes to the Uxxx\n",
-                       command_size, total_size);
+       if (!urb)
                return -ENOMEM;
-       }
        buf = usb_alloc_coherent(ftdi->udev, total_size, GFP_KERNEL,
                                 &urb->transfer_dma);
        if (!buf) {
@@ -1948,10 +1942,8 @@ static int ftdi_elan_synchronize_flush(struct usb_ftdi *ftdi)
        int I = 257;
        int i = 0;
        urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!urb) {
-               dev_err(&ftdi->udev->dev, "could not alloc a urb for flush sequence\n");
+       if (!urb)
                return -ENOMEM;
-       }
        buf = usb_alloc_coherent(ftdi->udev, I, GFP_KERNEL, &urb->transfer_dma);
        if (!buf) {
                dev_err(&ftdi->udev->dev, "could not get a buffer for flush sequence\n");
@@ -1988,10 +1980,8 @@ static int ftdi_elan_synchronize_reset(struct usb_ftdi *ftdi)
        int I = 4;
        int i = 0;
        urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!urb) {
-               dev_err(&ftdi->udev->dev, "could not get a urb for the reset sequence\n");
+       if (!urb)
                return -ENOMEM;
-       }
        buf = usb_alloc_coherent(ftdi->udev, I, GFP_KERNEL, &urb->transfer_dma);
        if (!buf) {
                dev_err(&ftdi->udev->dev, "could not get a buffer for the reset sequence\n");
@@ -2740,7 +2730,6 @@ static int ftdi_elan_probe(struct usb_interface *interface,
                        ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress;
                        ftdi->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
                        if (!ftdi->bulk_in_buffer) {
-                               dev_err(&ftdi->udev->dev, "Could not allocate bulk_in_buffer\n");
                                retval = -ENOMEM;
                                goto error;
                        }
@@ -2823,9 +2812,6 @@ static void ftdi_elan_disconnect(struct usb_interface *interface)
                        ftdi->initialized = 0;
                        ftdi->registered = 0;
                }
-               flush_workqueue(status_queue);
-               flush_workqueue(command_queue);
-               flush_workqueue(respond_queue);
                ftdi->disconnected += 1;
                usb_set_intfdata(interface, NULL);
                dev_info(&ftdi->udev->dev, "USB FTDI U132 host controller interface now disconnected\n");
@@ -2845,31 +2831,12 @@ static int __init ftdi_elan_init(void)
        pr_info("driver %s\n", ftdi_elan_driver.name);
        mutex_init(&ftdi_module_lock);
        INIT_LIST_HEAD(&ftdi_static_list);
-       status_queue = create_singlethread_workqueue("ftdi-status-control");
-       if (!status_queue)
-               goto err_status_queue;
-       command_queue = create_singlethread_workqueue("ftdi-command-engine");
-       if (!command_queue)
-               goto err_command_queue;
-       respond_queue = create_singlethread_workqueue("ftdi-respond-engine");
-       if (!respond_queue)
-               goto err_respond_queue;
        result = usb_register(&ftdi_elan_driver);
        if (result) {
-               destroy_workqueue(status_queue);
-               destroy_workqueue(command_queue);
-               destroy_workqueue(respond_queue);
                pr_err("usb_register failed. Error number %d\n", result);
        }
        return result;
 
-err_respond_queue:
-       destroy_workqueue(command_queue);
-err_command_queue:
-       destroy_workqueue(status_queue);
-err_status_queue:
-       pr_err("%s couldn't create workqueue\n", ftdi_elan_driver.name);
-       return -ENOMEM;
 }
 
 static void __exit ftdi_elan_exit(void)
@@ -2882,15 +2849,7 @@ static void __exit ftdi_elan_exit(void)
                ftdi_status_cancel_work(ftdi);
                ftdi_command_cancel_work(ftdi);
                ftdi_response_cancel_work(ftdi);
-       } flush_workqueue(status_queue);
-       destroy_workqueue(status_queue);
-       status_queue = NULL;
-       flush_workqueue(command_queue);
-       destroy_workqueue(command_queue);
-       command_queue = NULL;
-       flush_workqueue(respond_queue);
-       destroy_workqueue(respond_queue);
-       respond_queue = NULL;
+       }
 }
 
 
index 5105397e62fc764616fce38899747195cafcc553..2975e80b7a56f9bce341707012c174da09dc9d49 100644 (file)
@@ -366,7 +366,6 @@ static int idmouse_probe(struct usb_interface *interface,
                        kmalloc(IMGSIZE + dev->bulk_in_size, GFP_KERNEL);
 
                if (!dev->bulk_in_buffer) {
-                       dev_err(&interface->dev, "Unable to allocate input buffer.\n");
                        idmouse_delete(dev);
                        return -ENOMEM;
                }
index 1950e87b4219047908dfdad73fe30650cad7b8ca..095778ff984de25838b1e0eda53e0794dd382f8c 100644 (file)
@@ -278,7 +278,7 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer,
        dev = file->private_data;
 
        /* verify that the device wasn't unplugged */
-       if (dev == NULL || !dev->present)
+       if (!dev || !dev->present)
                return -ENODEV;
 
        dev_dbg(&dev->interface->dev, "minor %d, count = %zd\n",
@@ -413,8 +413,6 @@ static ssize_t iowarrior_write(struct file *file,
                int_out_urb = usb_alloc_urb(0, GFP_KERNEL);
                if (!int_out_urb) {
                        retval = -ENOMEM;
-                       dev_dbg(&dev->interface->dev,
-                               "Unable to allocate urb\n");
                        goto error_no_urb;
                }
                buf = usb_alloc_coherent(dev->udev, dev->report_size,
@@ -482,9 +480,8 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd,
        int io_res;             /* checks for bytes read/written and copy_to/from_user results */
 
        dev = file->private_data;
-       if (dev == NULL) {
+       if (!dev)
                return -ENODEV;
-       }
 
        buffer = kzalloc(dev->report_size, GFP_KERNEL);
        if (!buffer)
@@ -654,9 +651,8 @@ static int iowarrior_release(struct inode *inode, struct file *file)
        int retval = 0;
 
        dev = file->private_data;
-       if (dev == NULL) {
+       if (!dev)
                return -ENODEV;
-       }
 
        dev_dbg(&dev->interface->dev, "minor %d\n", dev->minor);
 
@@ -766,10 +762,8 @@ static int iowarrior_probe(struct usb_interface *interface,
 
        /* allocate memory for our device state and initialize it */
        dev = kzalloc(sizeof(struct iowarrior), GFP_KERNEL);
-       if (dev == NULL) {
-               dev_err(&interface->dev, "Out of memory\n");
+       if (!dev)
                return retval;
-       }
 
        mutex_init(&dev->mutex);
 
@@ -812,15 +806,11 @@ static int iowarrior_probe(struct usb_interface *interface,
 
        /* create the urb and buffer for reading */
        dev->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!dev->int_in_urb) {
-               dev_err(&interface->dev, "Couldn't allocate interrupt_in_urb\n");
+       if (!dev->int_in_urb)
                goto error;
-       }
        dev->int_in_buffer = kmalloc(dev->report_size, GFP_KERNEL);
-       if (!dev->int_in_buffer) {
-               dev_err(&interface->dev, "Couldn't allocate int_in_buffer\n");
+       if (!dev->int_in_buffer)
                goto error;
-       }
        usb_fill_int_urb(dev->int_in_urb, dev->udev,
                         usb_rcvintpipe(dev->udev,
                                        dev->int_in_endpoint->bEndpointAddress),
@@ -831,10 +821,8 @@ static int iowarrior_probe(struct usb_interface *interface,
        dev->read_queue =
            kmalloc(((dev->report_size + 1) * MAX_INTERRUPT_BUFFER),
                    GFP_KERNEL);
-       if (!dev->read_queue) {
-               dev_err(&interface->dev, "Couldn't allocate read_queue\n");
+       if (!dev->read_queue)
                goto error;
-       }
        /* Get the serial-number of the chip */
        memset(dev->chip_serial, 0x00, sizeof(dev->chip_serial));
        usb_string(udev, udev->descriptor.iSerialNumber, dev->chip_serial,
index cce22ff1c2eb4249ac02f011bca5be154a8ad927..9ca595632f171c2ac705c3c465769afe80c1e6f7 100644 (file)
@@ -658,10 +658,8 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
        /* allocate memory for our device state and initialize it */
 
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-       if (dev == NULL) {
-               dev_err(&intf->dev, "Out of memory\n");
+       if (!dev)
                goto exit;
-       }
        mutex_init(&dev->mutex);
        spin_lock_init(&dev->rbsl);
        dev->intf = intf;
@@ -674,10 +672,8 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
             (le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_LD_COM3LAB)) &&
            (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x103)) {
                buffer = kmalloc(256, GFP_KERNEL);
-               if (buffer == NULL) {
-                       dev_err(&intf->dev, "Couldn't allocate string buffer\n");
+               if (!buffer)
                        goto error;
-               }
                /* usb_string makes SETUP+STALL to leave always ControlReadLoop */
                usb_string(udev, 255, buffer, 256);
                kfree(buffer);
@@ -704,32 +700,22 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
 
        dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);
        dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL);
-       if (!dev->ring_buffer) {
-               dev_err(&intf->dev, "Couldn't allocate ring_buffer\n");
+       if (!dev->ring_buffer)
                goto error;
-       }
        dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);
-       if (!dev->interrupt_in_buffer) {
-               dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n");
+       if (!dev->interrupt_in_buffer)
                goto error;
-       }
        dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!dev->interrupt_in_urb) {
-               dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n");
+       if (!dev->interrupt_in_urb)
                goto error;
-       }
        dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? usb_endpoint_maxp(dev->interrupt_out_endpoint) :
                                                                         udev->descriptor.bMaxPacketSize0;
        dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL);
-       if (!dev->interrupt_out_buffer) {
-               dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n");
+       if (!dev->interrupt_out_buffer)
                goto error;
-       }
        dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!dev->interrupt_out_urb) {
-               dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb\n");
+       if (!dev->interrupt_out_urb)
                goto error;
-       }
        dev->interrupt_in_interval = min_interrupt_in_interval > dev->interrupt_in_endpoint->bInterval ? min_interrupt_in_interval : dev->interrupt_in_endpoint->bInterval;
        if (dev->interrupt_out_endpoint)
                dev->interrupt_out_interval = min_interrupt_out_interval > dev->interrupt_out_endpoint->bInterval ? min_interrupt_out_interval : dev->interrupt_out_endpoint->bInterval;
index 7771be3ac178ea0e95ca7da1f85ff55543ff4a00..ece9b3c1eaac2959bafefcaf7205a76799a94e50 100644 (file)
@@ -817,10 +817,8 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
 
        dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL);
 
-       if (dev == NULL) {
-               dev_err(idev, "Out of memory\n");
+       if (!dev)
                goto exit;
-       }
 
        mutex_init(&dev->lock);
 
@@ -871,30 +869,20 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
        }
 
        dev->read_buffer = kmalloc (read_buffer_size, GFP_KERNEL);
-       if (!dev->read_buffer) {
-               dev_err(idev, "Couldn't allocate read_buffer\n");
+       if (!dev->read_buffer)
                goto error;
-       }
        dev->interrupt_in_buffer = kmalloc (usb_endpoint_maxp(dev->interrupt_in_endpoint), GFP_KERNEL);
-       if (!dev->interrupt_in_buffer) {
-               dev_err(idev, "Couldn't allocate interrupt_in_buffer\n");
+       if (!dev->interrupt_in_buffer)
                goto error;
-       }
        dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!dev->interrupt_in_urb) {
-               dev_err(idev, "Couldn't allocate interrupt_in_urb\n");
+       if (!dev->interrupt_in_urb)
                goto error;
-       }
        dev->interrupt_out_buffer = kmalloc (write_buffer_size, GFP_KERNEL);
-       if (!dev->interrupt_out_buffer) {
-               dev_err(idev, "Couldn't allocate interrupt_out_buffer\n");
+       if (!dev->interrupt_out_buffer)
                goto error;
-       }
        dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!dev->interrupt_out_urb) {
-               dev_err(idev, "Couldn't allocate interrupt_out_urb\n");
+       if (!dev->interrupt_out_urb)
                goto error;
-       }
        dev->interrupt_in_interval = interrupt_in_interval ? interrupt_in_interval : dev->interrupt_in_endpoint->bInterval;
        dev->interrupt_out_interval = interrupt_out_interval ? interrupt_out_interval : dev->interrupt_out_endpoint->bInterval;
 
index 86b4e4b2ab9a608912118e38a294b7d7f0d8f8a7..77176511658f3328f830ecdbd056f072a6c84f8a 100644 (file)
@@ -34,8 +34,6 @@ struct lvs_rh {
        struct usb_hub_descriptor descriptor;
        /* urb for polling interrupt pipe */
        struct urb *urb;
-       /* LVS RH work queue */
-       struct workqueue_struct *rh_queue;
        /* LVH RH work */
        struct work_struct      rh_work;
        /* RH port status */
@@ -247,10 +245,8 @@ static ssize_t get_dev_desc_store(struct device *dev,
        int ret;
 
        descriptor = kmalloc(sizeof(*descriptor), GFP_KERNEL);
-       if (!descriptor) {
-               dev_err(dev, "failed to allocate descriptor memory\n");
+       if (!descriptor)
                return -ENOMEM;
-       }
 
        udev = create_lvs_device(intf);
        if (!udev) {
@@ -355,7 +351,7 @@ static void lvs_rh_irq(struct urb *urb)
 {
        struct lvs_rh *lvs = urb->context;
 
-       queue_work(lvs->rh_queue, &lvs->rh_work);
+       schedule_work(&lvs->rh_work);
 }
 
 static int lvs_rh_probe(struct usb_interface *intf,
@@ -397,24 +393,15 @@ static int lvs_rh_probe(struct usb_interface *intf,
 
        /* submit urb to poll interrupt endpoint */
        lvs->urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!lvs->urb) {
-               dev_err(&intf->dev, "couldn't allocate lvs urb\n");
+       if (!lvs->urb)
                return -ENOMEM;
-       }
-
-       lvs->rh_queue = create_singlethread_workqueue("lvs_rh_queue");
-       if (!lvs->rh_queue) {
-               dev_err(&intf->dev, "couldn't create workqueue\n");
-               ret = -ENOMEM;
-               goto free_urb;
-       }
 
        INIT_WORK(&lvs->rh_work, lvs_rh_work);
 
        ret = sysfs_create_group(&intf->dev.kobj, &lvs_attr_group);
        if (ret < 0) {
                dev_err(&intf->dev, "Failed to create sysfs node %d\n", ret);
-               goto destroy_queue;
+               goto free_urb;
        }
 
        pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress);
@@ -432,8 +419,6 @@ static int lvs_rh_probe(struct usb_interface *intf,
 
 sysfs_remove:
        sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group);
-destroy_queue:
-       destroy_workqueue(lvs->rh_queue);
 free_urb:
        usb_free_urb(lvs->urb);
        return ret;
@@ -444,7 +429,7 @@ static void lvs_rh_disconnect(struct usb_interface *intf)
        struct lvs_rh *lvs = usb_get_intfdata(intf);
 
        sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group);
-       destroy_workqueue(lvs->rh_queue);
+       flush_work(&lvs->rh_work);
        usb_free_urb(lvs->urb);
 }
 
index 02abfcdfbf7bc887b4b331a5da9066d5db8c152a..05bd39d62568198bc5ff5e6e0dc59910e279a677 100644 (file)
@@ -3084,7 +3084,6 @@ static int sisusb_probe(struct usb_interface *intf,
        /* Allocate URBs */
        sisusb->sisurbin = usb_alloc_urb(0, GFP_KERNEL);
        if (!sisusb->sisurbin) {
-               dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate URBs\n");
                retval = -ENOMEM;
                goto error_3;
        }
@@ -3093,8 +3092,6 @@ static int sisusb_probe(struct usb_interface *intf,
        for (i = 0; i < sisusb->numobufs; i++) {
                sisusb->sisurbout[i] = usb_alloc_urb(0, GFP_KERNEL);
                if (!sisusb->sisurbout[i]) {
-                       dev_err(&sisusb->sisusb_dev->dev,
-                                       "Failed to allocate URBs\n");
                        retval = -ENOMEM;
                        goto error_4;
                }
index 4145314a515b9554469ccde9ee0d6d968a7142b2..9795457723d86cfbed9563c9d0c454575010cd11 100644 (file)
@@ -95,8 +95,7 @@ static int tv_probe(struct usb_interface *interface,
        int retval;
 
        dev = kzalloc(sizeof(struct trancevibrator), GFP_KERNEL);
-       if (dev == NULL) {
-               dev_err(&interface->dev, "Out of memory\n");
+       if (!dev) {
                retval = -ENOMEM;
                goto error;
        }
diff --git a/drivers/usb/misc/usb4604.c b/drivers/usb/misc/usb4604.c
new file mode 100644 (file)
index 0000000..e9f37fb
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * Driver for SMSC USB4604 USB HSIC 4-port 2.0 hub controller driver
+ * Based on usb3503 driver
+ *
+ * Copyright (c) 2012-2013 Dongjin Kim (tobetter@gmail.com)
+ * Copyright (c) 2016 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/gpio/consumer.h>
+
+enum usb4604_mode {
+       USB4604_MODE_UNKNOWN,
+       USB4604_MODE_HUB,
+       USB4604_MODE_STANDBY,
+};
+
+struct usb4604 {
+       enum usb4604_mode       mode;
+       struct device           *dev;
+       struct gpio_desc        *gpio_reset;
+};
+
+static void usb4604_reset(struct usb4604 *hub, int state)
+{
+       gpiod_set_value_cansleep(hub->gpio_reset, state);
+
+       /* Wait for i2c logic to come up */
+       if (state)
+               msleep(250);
+}
+
+static int usb4604_connect(struct usb4604 *hub)
+{
+       struct device *dev = hub->dev;
+       struct i2c_client *client = to_i2c_client(dev);
+       int err;
+       u8 connect_cmd[] = { 0xaa, 0x55, 0x00 };
+
+       usb4604_reset(hub, 1);
+
+       err = i2c_master_send(client, connect_cmd, ARRAY_SIZE(connect_cmd));
+       if (err < 0) {
+               usb4604_reset(hub, 0);
+               return err;
+       }
+
+       hub->mode = USB4604_MODE_HUB;
+       dev_dbg(dev, "switched to HUB mode\n");
+
+       return 0;
+}
+
+static int usb4604_switch_mode(struct usb4604 *hub, enum usb4604_mode mode)
+{
+       struct device *dev = hub->dev;
+       int err = 0;
+
+       switch (mode) {
+       case USB4604_MODE_HUB:
+               err = usb4604_connect(hub);
+               break;
+
+       case USB4604_MODE_STANDBY:
+               usb4604_reset(hub, 0);
+               dev_dbg(dev, "switched to STANDBY mode\n");
+               break;
+
+       default:
+               dev_err(dev, "unknown mode is requested\n");
+               err = -EINVAL;
+               break;
+       }
+
+       return err;
+}
+
+static int usb4604_probe(struct usb4604 *hub)
+{
+       struct device *dev = hub->dev;
+       struct device_node *np = dev->of_node;
+       struct gpio_desc *gpio;
+       u32 mode = USB4604_MODE_HUB;
+
+       gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+       if (IS_ERR(gpio))
+               return PTR_ERR(gpio);
+       hub->gpio_reset = gpio;
+
+       if (of_property_read_u32(np, "initial-mode", &hub->mode))
+               hub->mode = mode;
+
+       return usb4604_switch_mode(hub, hub->mode);
+}
+
+static int usb4604_i2c_probe(struct i2c_client *i2c,
+                            const struct i2c_device_id *id)
+{
+       struct usb4604 *hub;
+
+       hub = devm_kzalloc(&i2c->dev, sizeof(*hub), GFP_KERNEL);
+       if (!hub)
+               return -ENOMEM;
+
+       i2c_set_clientdata(i2c, hub);
+       hub->dev = &i2c->dev;
+
+       return usb4604_probe(hub);
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int usb4604_i2c_suspend(struct device *dev)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct usb4604 *hub = i2c_get_clientdata(client);
+
+       usb4604_switch_mode(hub, USB4604_MODE_STANDBY);
+
+       return 0;
+}
+
+static int usb4604_i2c_resume(struct device *dev)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct usb4604 *hub = i2c_get_clientdata(client);
+
+       usb4604_switch_mode(hub, hub->mode);
+
+       return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(usb4604_i2c_pm_ops, usb4604_i2c_suspend,
+               usb4604_i2c_resume);
+
+static const struct i2c_device_id usb4604_id[] = {
+       { "usb4604", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, usb4604_id);
+
+#ifdef CONFIG_OF
+static const struct of_device_id usb4604_of_match[] = {
+       { .compatible = "smsc,usb4604" },
+       {}
+};
+MODULE_DEVICE_TABLE(of, usb4604_of_match);
+#endif
+
+static struct i2c_driver usb4604_i2c_driver = {
+       .driver = {
+               .name = "usb4604",
+               .pm = &usb4604_i2c_pm_ops,
+               .of_match_table = of_match_ptr(usb4604_of_match),
+       },
+       .probe          = usb4604_i2c_probe,
+       .id_table       = usb4604_id,
+};
+module_i2c_driver(usb4604_i2c_driver);
+
+MODULE_DESCRIPTION("USB4604 USB HUB driver");
+MODULE_LICENSE("GPL v2");
index 1184390508e9832a20d2a2ec41a9362b2766014c..9f48419abc46b97ebdb562fa4a0b606e7223d67e 100644 (file)
@@ -321,10 +321,8 @@ static int lcd_probe(struct usb_interface *interface,
 
        /* allocate memory for our device state and initialize it */
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-       if (dev == NULL) {
-               dev_err(&interface->dev, "Out of memory\n");
+       if (!dev)
                goto error;
-       }
        kref_init(&dev->kref);
        sema_init(&dev->limit_sem, USB_LCD_CONCURRENT_WRITES);
        init_usb_anchor(&dev->submitted);
@@ -351,11 +349,8 @@ static int lcd_probe(struct usb_interface *interface,
                        dev->bulk_in_size = buffer_size;
                        dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
                        dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
-                       if (!dev->bulk_in_buffer) {
-                               dev_err(&interface->dev,
-                                       "Could not allocate bulk_in_buffer\n");
+                       if (!dev->bulk_in_buffer)
                                goto error;
-                       }
                }
 
                if (!dev->bulk_out_endpointAddr &&
index 1fe6b73c22f3007993611984369c40f76c25a181..a0ba5298160c562f6938da6758db431d9c40c8cd 100644 (file)
@@ -128,10 +128,8 @@ static void update_display_visual(struct usb_sevsegdev *mydev, gfp_t mf)
                return;
 
        buffer = kzalloc(MAXLEN, mf);
-       if (!buffer) {
-               dev_err(&mydev->udev->dev, "out of memory\n");
+       if (!buffer)
                return;
-       }
 
        /* The device is right to left, where as you write left to right */
        for (i = 0; i < mydev->textlength; i++)
@@ -346,10 +344,8 @@ static int sevseg_probe(struct usb_interface *interface,
        int rc = -ENOMEM;
 
        mydev = kzalloc(sizeof(struct usb_sevsegdev), GFP_KERNEL);
-       if (mydev == NULL) {
-               dev_err(&interface->dev, "Out of memory\n");
+       if (!mydev)
                goto error_mem;
-       }
 
        mydev->udev = usb_get_dev(udev);
        mydev->intf = interface;
index bbd029c9c7255a84d0b28124101a9e7322e76462..356d312add57793aa92587571d0b398264166a25 100644 (file)
@@ -150,10 +150,8 @@ static struct uss720_async_request *submit_async_request(struct parport_uss720_p
        if (!usbdev)
                return NULL;
        rq = kzalloc(sizeof(struct uss720_async_request), mem_flags);
-       if (!rq) {
-               dev_err(&usbdev->dev, "submit_async_request out of memory\n");
+       if (!rq)
                return NULL;
-       }
        kref_init(&rq->ref_count);
        INIT_LIST_HEAD(&rq->asynclist);
        init_completion(&rq->compl);
@@ -162,7 +160,6 @@ static struct uss720_async_request *submit_async_request(struct parport_uss720_p
        rq->urb = usb_alloc_urb(0, mem_flags);
        if (!rq->urb) {
                kref_put(&rq->ref_count, destroy_async);
-               dev_err(&usbdev->dev, "submit_async_request out of memory\n");
                return NULL;
        }
        rq->dr = kmalloc(sizeof(*rq->dr), mem_flags);
index 343fa6ff9f4badbf47b38c1f0f867057d0d089f7..54e53ac4c08fd7c47ebf1d271083d2313b92ade0 100644 (file)
@@ -200,10 +200,8 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
 
        /* allocate memory for our device state and initialize it */
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-       if (!dev) {
-               dev_err(&interface->dev, "Out of memory\n");
+       if (!dev)
                goto error;
-       }
        kref_init(&dev->kref);
        mutex_init(&dev->io_mutex);
        spin_lock_init(&dev->lock);
@@ -231,17 +229,13 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
 
        /* allocate control URB */
        dev->cntl_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!dev->cntl_urb) {
-               dev_err(&interface->dev, "Could not allocate control URB\n");
+       if (!dev->cntl_urb)
                goto error;
-       }
 
        /* allocate buffer for control req */
        dev->cntl_req = kmalloc(YUREX_BUF_SIZE, GFP_KERNEL);
-       if (!dev->cntl_req) {
-               dev_err(&interface->dev, "Could not allocate cntl_req\n");
+       if (!dev->cntl_req)
                goto error;
-       }
 
        /* allocate buffer for control msg */
        dev->cntl_buffer = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
@@ -269,10 +263,8 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
 
        /* allocate interrupt URB */
        dev->urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!dev->urb) {
-               dev_err(&interface->dev, "Could not allocate URB\n");
+       if (!dev->urb)
                goto error;
-       }
 
        /* allocate buffer for interrupt in */
        dev->int_buffer = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
index c41fe588d14d97f75ef3d57729bc75b37891cdce..c14577dbedf71a39344329d7ef658718c3a540d0 100644 (file)
@@ -474,10 +474,8 @@ static int am35x_probe(struct platform_device *pdev)
        int                             ret = -ENOMEM;
 
        glue = kzalloc(sizeof(*glue), GFP_KERNEL);
-       if (!glue) {
-               dev_err(&pdev->dev, "failed to allocate glue context\n");
+       if (!glue)
                goto err0;
-       }
 
        phy_clk = clk_get(&pdev->dev, "fck");
        if (IS_ERR(phy_clk)) {
index b03d3b867fca2f8b06f2340c3fffaf5c53a4da13..3c4dd1658f28dbb4eeeb401ed7939ecb6b7006d8 100644 (file)
@@ -494,10 +494,8 @@ static int da8xx_probe(struct platform_device *pdev)
        int                             ret = -ENOMEM;
 
        glue = kzalloc(sizeof(*glue), GFP_KERNEL);
-       if (!glue) {
-               dev_err(&pdev->dev, "failed to allocate glue context\n");
+       if (!glue)
                goto err0;
-       }
 
        clk = clk_get(&pdev->dev, "usb20");
        if (IS_ERR(clk)) {
index c4c64740a3e72ebdfd0f74a190e2d44f4ec10b47..86b37a8eedd445d9559c35bec1bead959bb22f1f 100644 (file)
@@ -335,7 +335,6 @@ static void __usbhsg_recip_send_status(struct usbhsg_gpriv *gpriv,
        buf = kmalloc(sizeof(*buf), GFP_ATOMIC);
        if (!buf) {
                usb_ep_free_request(&dcp->ep, req);
-               dev_err(dev, "recip data allocation fail\n");
                return;
        }
 
@@ -1062,14 +1061,11 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
        int ret;
 
        gpriv = kzalloc(sizeof(struct usbhsg_gpriv), GFP_KERNEL);
-       if (!gpriv) {
-               dev_err(dev, "Could not allocate gadget priv\n");
+       if (!gpriv)
                return -ENOMEM;
-       }
 
        uep = kzalloc(sizeof(struct usbhsg_uep) * pipe_size, GFP_KERNEL);
        if (!uep) {
-               dev_err(dev, "Could not allocate ep\n");
                ret = -ENOMEM;
                goto usbhs_mod_gadget_probe_err_gpriv;
        }
index 3bf0b72eb359f192422fca689159b2b71669dcdc..165e81bfd93a6632457dc0a278036f70f2a9ed05 100644 (file)
@@ -166,14 +166,10 @@ static struct usbhsh_request *usbhsh_ureq_alloc(struct usbhsh_hpriv *hpriv,
                                               gfp_t mem_flags)
 {
        struct usbhsh_request *ureq;
-       struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv);
-       struct device *dev = usbhs_priv_to_dev(priv);
 
        ureq = kzalloc(sizeof(struct usbhsh_request), mem_flags);
-       if (!ureq) {
-               dev_err(dev, "ureq alloc fail\n");
+       if (!ureq)
                return NULL;
-       }
 
        usbhs_pkt_init(&ureq->pkt);
        ureq->urb = urb;
@@ -388,10 +384,8 @@ static int usbhsh_endpoint_attach(struct usbhsh_hpriv *hpriv,
        unsigned long flags;
 
        uep = kzalloc(sizeof(struct usbhsh_ep), mem_flags);
-       if (!uep) {
-               dev_err(dev, "usbhsh_ep alloc fail\n");
+       if (!uep)
                return -ENOMEM;
-       }
 
        /********************  spin lock ********************/
        usbhs_lock(priv, flags);
index c238772b9e9e1a87bb2d43f6c2a85f95bef6e4e8..9396a8c14af80104e8841d98ca30d27ffb1fd88d 100644 (file)
@@ -804,10 +804,8 @@ int usbhs_pipe_probe(struct usbhs_priv *priv)
        }
 
        info->pipe = kzalloc(sizeof(struct usbhs_pipe) * pipe_size, GFP_KERNEL);
-       if (!info->pipe) {
-               dev_err(dev, "Could not allocate pipe\n");
+       if (!info->pipe)
                return -ENOMEM;
-       }
 
        info->size = pipe_size;
 
index 1d8b03c8103053ddc786a01774143d8a88fb7b19..878b4b8761f5a6f7d2025ebee5a470074e13f7be 100644 (file)
@@ -939,10 +939,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address,
 
        len = min(sectors, blocksize) * (pagesize + 64);
        buffer = kmalloc(len, GFP_NOIO);
-       if (buffer == NULL) {
-               printk(KERN_WARNING "alauda_read_data: Out of memory\n");
+       if (!buffer)
                return USB_STOR_TRANSPORT_ERROR;
-       }
 
        /* Figure out the initial LBA and page */
        lba = address >> blockshift;
@@ -1033,18 +1031,15 @@ static int alauda_write_data(struct us_data *us, unsigned long address,
 
        len = min(sectors, blocksize) * pagesize;
        buffer = kmalloc(len, GFP_NOIO);
-       if (buffer == NULL) {
-               printk(KERN_WARNING "alauda_write_data: Out of memory\n");
+       if (!buffer)
                return USB_STOR_TRANSPORT_ERROR;
-       }
 
        /*
         * We also need a temporary block buffer, where we read in the old data,
         * overwrite parts with the new data, and manipulate the redundancy data
         */
        blockbuffer = kmalloc((pagesize + 64) * blocksize, GFP_NOIO);
-       if (blockbuffer == NULL) {
-               printk(KERN_WARNING "alauda_write_data: Out of memory\n");
+       if (!blockbuffer) {
                kfree(buffer);
                return USB_STOR_TRANSPORT_ERROR;
        }
index c5797fa2125e94fa232311bb880c96f1bedb9110..3aeaa536c44f9e2a67967025a33d03d091603d4f 100644 (file)
@@ -766,10 +766,8 @@ sddr09_read_data(struct us_data *us,
 
        len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
        buffer = kmalloc(len, GFP_NOIO);
-       if (buffer == NULL) {
-               printk(KERN_WARNING "sddr09_read_data: Out of memory\n");
+       if (!buffer)
                return -ENOMEM;
-       }
 
        // This could be made much more efficient by checking for
        // contiguous LBA's. Another exercise left to the student.
@@ -1004,10 +1002,8 @@ sddr09_write_data(struct us_data *us,
        pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT);
        blocklen = (pagelen << info->blockshift);
        blockbuffer = kmalloc(blocklen, GFP_NOIO);
-       if (!blockbuffer) {
-               printk(KERN_WARNING "sddr09_write_data: Out of memory\n");
+       if (!blockbuffer)
                return -ENOMEM;
-       }
 
        /*
         * Since we don't write the user data directly to the device,
@@ -1017,8 +1013,7 @@ sddr09_write_data(struct us_data *us,
 
        len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
        buffer = kmalloc(len, GFP_NOIO);
-       if (buffer == NULL) {
-               printk(KERN_WARNING "sddr09_write_data: Out of memory\n");
+       if (!buffer) {
                kfree(blockbuffer);
                return -ENOMEM;
        }
@@ -1241,8 +1236,7 @@ sddr09_read_map(struct us_data *us) {
        alloc_blocks = min(numblocks, SDDR09_READ_MAP_BUFSZ >> CONTROL_SHIFT);
        alloc_len = (alloc_blocks << CONTROL_SHIFT);
        buffer = kmalloc(alloc_len, GFP_NOIO);
-       if (buffer == NULL) {
-               printk(KERN_WARNING "sddr09_read_map: out of memory\n");
+       if (!buffer) {
                result = -1;
                goto done;
        }
index ef2d8cde6ef700bda2e97b6d9fbce99e9be0c872..c8afd2d4c40b70a245615c08471ac1ae3d6a6fc2 100644 (file)
@@ -794,10 +794,8 @@ static int usb_stor_acquire_resources(struct us_data *us)
        struct task_struct *th;
 
        us->current_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!us->current_urb) {
-               usb_stor_dbg(us, "URB allocation failed\n");
+       if (!us->current_urb)
                return -ENOMEM;
-       }
 
        /*
         * Just before we start our control thread, initialize
@@ -1070,17 +1068,17 @@ int usb_stor_probe2(struct us_data *us)
        result = usb_stor_acquire_resources(us);
        if (result)
                goto BadDevice;
+       usb_autopm_get_interface_no_resume(us->pusb_intf);
        snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s",
                                        dev_name(&us->pusb_intf->dev));
        result = scsi_add_host(us_to_host(us), dev);
        if (result) {
                dev_warn(dev,
                                "Unable to add the scsi host\n");
-               goto BadDevice;
+               goto HostAddErr;
        }
 
        /* Submit the delayed_work for SCSI-device scanning */
-       usb_autopm_get_interface_no_resume(us->pusb_intf);
        set_bit(US_FLIDX_SCAN_PENDING, &us->dflags);
 
        if (delay_use > 0)
@@ -1090,6 +1088,8 @@ int usb_stor_probe2(struct us_data *us)
        return 0;
 
        /* We come here if there are any problems */
+HostAddErr:
+       usb_autopm_put_interface_no_suspend(us->pusb_intf);
 BadDevice:
        usb_stor_dbg(us, "storage_probe() failed\n");
        release_everything(us);
index 545d09b8081d55ff843bc59e918d96865eaf6849..5133a0792eb0418391f74e4f56486731dc7e62fc 100644 (file)
@@ -499,10 +499,8 @@ static int skel_probe(struct usb_interface *interface,
 
        /* allocate memory for our device state and initialize it */
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-       if (!dev) {
-               dev_err(&interface->dev, "Out of memory\n");
+       if (!dev)
                goto error;
-       }
        kref_init(&dev->kref);
        sema_init(&dev->limit_sem, WRITES_IN_FLIGHT);
        mutex_init(&dev->io_mutex);
@@ -526,17 +524,11 @@ static int skel_probe(struct usb_interface *interface,
                        dev->bulk_in_size = buffer_size;
                        dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
                        dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
-                       if (!dev->bulk_in_buffer) {
-                               dev_err(&interface->dev,
-                                       "Could not allocate bulk_in_buffer\n");
+                       if (!dev->bulk_in_buffer)
                                goto error;
-                       }
                        dev->bulk_in_urb = usb_alloc_urb(0, GFP_KERNEL);
-                       if (!dev->bulk_in_urb) {
-                               dev_err(&interface->dev,
-                                       "Could not allocate bulk_in_urb\n");
+                       if (!dev->bulk_in_urb)
                                goto error;
-                       }
                }
 
                if (!dev->bulk_out_endpointAddr &&
index 17646b25343f280c977a038ce9bbc4a0f178f1b0..29492c70e0e681f3dc08bd1c8c918a1bf90b7c35 100644 (file)
@@ -24,6 +24,27 @@ config USBIP_VHCI_HCD
          To compile this driver as a module, choose M here: the
          module will be called vhci-hcd.
 
+config USBIP_VHCI_HC_PORTS
+       int "Number of ports per USB/IP virtual host controller"
+       range 1 31
+       default 8
+       depends on USBIP_VHCI_HCD
+       ---help---
+         To increase number of ports available for USB/IP virtual
+         host controller driver, this defines number of ports per
+         USB/IP virtual host controller.
+
+config USBIP_VHCI_NR_HCS
+       int "Number of USB/IP virtual host controllers"
+       range 1 128
+       default 1
+       depends on USBIP_VHCI_HCD
+       ---help---
+         To increase number of ports available for USB/IP virtual
+         host controller driver, this defines number of USB/IP
+         virtual host controllers as if adding physical host
+         controllers.
+
 config USBIP_HOST
        tristate "Host driver"
        depends on USBIP_CORE && USB
index 2df63e305722e4a21a8f2543d4f8a985b5e9eb3a..191b176ffedfdaa119df7f4d31b8941e388b2299 100644 (file)
@@ -461,7 +461,6 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
                priv->urb = usb_alloc_urb(0, GFP_KERNEL);
 
        if (!priv->urb) {
-               dev_err(&udev->dev, "malloc urb\n");
                usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC);
                return;
        }
index a863a98a91ce01afa0e12e8d86eec5b8c696e58d..88b71c4e068fec6c1f63c9b74664b9e3f3721b92 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2003-2008 Takahiro Hirofuchi
+ * Copyright (C) 2015 Nobuo Iwata
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -72,13 +73,25 @@ struct vhci_unlink {
 };
 
 /* Number of supported ports. Value has an upperbound of USB_MAXCHILDREN */
-#define VHCI_NPORTS 8
+#ifdef CONFIG_USBIP_VHCI_HC_PORTS
+#define VHCI_HC_PORTS CONFIG_USBIP_VHCI_HC_PORTS
+#else
+#define VHCI_HC_PORTS 8
+#endif
+
+#ifdef CONFIG_USBIP_VHCI_NR_HCS
+#define VHCI_NR_HCS CONFIG_USBIP_VHCI_NR_HCS
+#else
+#define VHCI_NR_HCS 1
+#endif
+
+#define MAX_STATUS_NAME 16
 
 /* for usb_bus.hcpriv */
 struct vhci_hcd {
        spinlock_t lock;
 
-       u32 port_status[VHCI_NPORTS];
+       u32 port_status[VHCI_HC_PORTS];
 
        unsigned resuming:1;
        unsigned long re_timeout;
@@ -90,14 +103,19 @@ struct vhci_hcd {
         * wIndex shows the port number and begins from 1.
         * But, the index of this array begins from 0.
         */
-       struct vhci_device vdev[VHCI_NPORTS];
+       struct vhci_device vdev[VHCI_HC_PORTS];
 };
 
-extern struct vhci_hcd *the_controller;
-extern const struct attribute_group dev_attr_group;
+extern int vhci_num_controllers;
+extern struct platform_device **vhci_pdevs;
+extern struct attribute_group vhci_attr_group;
 
 /* vhci_hcd.c */
-void rh_port_connect(int rhport, enum usb_device_speed speed);
+void rh_port_connect(struct vhci_device *vdev, enum usb_device_speed speed);
+
+/* vhci_sysfs.c */
+int vhci_init_attr_group(void);
+void vhci_finish_attr_group(void);
 
 /* vhci_rx.c */
 struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum);
@@ -106,9 +124,14 @@ int vhci_rx_loop(void *data);
 /* vhci_tx.c */
 int vhci_tx_loop(void *data);
 
-static inline struct vhci_device *port_to_vdev(__u32 port)
+static inline __u32 port_to_rhport(__u32 port)
+{
+       return port % VHCI_HC_PORTS;
+}
+
+static inline int port_to_pdev_nr(__u32 port)
 {
-       return &the_controller->vdev[port];
+       return port / VHCI_HC_PORTS;
 }
 
 static inline struct vhci_hcd *hcd_to_vhci(struct usb_hcd *hcd)
@@ -116,14 +139,25 @@ static inline struct vhci_hcd *hcd_to_vhci(struct usb_hcd *hcd)
        return (struct vhci_hcd *) (hcd->hcd_priv);
 }
 
+static inline struct device *hcd_dev(struct usb_hcd *hcd)
+{
+       return (hcd)->self.controller;
+}
+
+static inline const char *hcd_name(struct usb_hcd *hcd)
+{
+       return (hcd)->self.bus_name;
+}
+
 static inline struct usb_hcd *vhci_to_hcd(struct vhci_hcd *vhci)
 {
        return container_of((void *) vhci, struct usb_hcd, hcd_priv);
 }
 
-static inline struct device *vhci_dev(struct vhci_hcd *vhci)
+static inline struct vhci_hcd *vdev_to_vhci(struct vhci_device *vdev)
 {
-       return vhci_to_hcd(vhci)->self.controller;
+       return container_of(
+                       (void *)(vdev - vdev->rhport), struct vhci_hcd, vdev);
 }
 
 #endif /* __USBIP_VHCI_H */
index 2e0450bec1b13014cd257066a138a66e1ddd306d..03eccf29ace068f07597931799fb6b57254c5d7b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2003-2008 Takahiro Hirofuchi
+ * Copyright (C) 2015-2016 Nobuo Iwata
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -56,7 +57,9 @@ static int vhci_get_frame_number(struct usb_hcd *hcd);
 static const char driver_name[] = "vhci_hcd";
 static const char driver_desc[] = "USB/IP Virtual Host Controller";
 
-struct vhci_hcd *the_controller;
+int vhci_num_controllers = VHCI_NR_HCS;
+
+struct platform_device **vhci_pdevs;
 
 static const char * const bit_desc[] = {
        "CONNECTION",           /*0*/
@@ -119,47 +122,59 @@ static void dump_port_status_diff(u32 prev_status, u32 new_status)
        pr_debug("\n");
 }
 
-void rh_port_connect(int rhport, enum usb_device_speed speed)
+void rh_port_connect(struct vhci_device *vdev, enum usb_device_speed speed)
 {
+       struct vhci_hcd *vhci = vdev_to_vhci(vdev);
+       int             rhport = vdev->rhport;
+       u32             status;
        unsigned long   flags;
 
        usbip_dbg_vhci_rh("rh_port_connect %d\n", rhport);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock_irqsave(&vhci->lock, flags);
+
+       status = vhci->port_status[rhport];
 
-       the_controller->port_status[rhport] |= USB_PORT_STAT_CONNECTION
-               | (1 << USB_PORT_FEAT_C_CONNECTION);
+       status |= USB_PORT_STAT_CONNECTION | (1 << USB_PORT_FEAT_C_CONNECTION);
 
        switch (speed) {
        case USB_SPEED_HIGH:
-               the_controller->port_status[rhport] |= USB_PORT_STAT_HIGH_SPEED;
+               status |= USB_PORT_STAT_HIGH_SPEED;
                break;
        case USB_SPEED_LOW:
-               the_controller->port_status[rhport] |= USB_PORT_STAT_LOW_SPEED;
+               status |= USB_PORT_STAT_LOW_SPEED;
                break;
        default:
                break;
        }
 
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       vhci->port_status[rhport] = status;
+
+       spin_unlock_irqrestore(&vhci->lock, flags);
 
-       usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
+       usb_hcd_poll_rh_status(vhci_to_hcd(vhci));
 }
 
-static void rh_port_disconnect(int rhport)
+static void rh_port_disconnect(struct vhci_device *vdev)
 {
+       struct vhci_hcd *vhci = vdev_to_vhci(vdev);
+       int             rhport = vdev->rhport;
+       u32             status;
        unsigned long   flags;
 
        usbip_dbg_vhci_rh("rh_port_disconnect %d\n", rhport);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock_irqsave(&vhci->lock, flags);
+
+       status = vhci->port_status[rhport];
+
+       status &= ~USB_PORT_STAT_CONNECTION;
+       status |= (1 << USB_PORT_FEAT_C_CONNECTION);
 
-       the_controller->port_status[rhport] &= ~USB_PORT_STAT_CONNECTION;
-       the_controller->port_status[rhport] |=
-                                       (1 << USB_PORT_FEAT_C_CONNECTION);
+       vhci->port_status[rhport] = status;
 
-       spin_unlock_irqrestore(&the_controller->lock, flags);
-       usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
+       spin_unlock_irqrestore(&vhci->lock, flags);
+       usb_hcd_poll_rh_status(vhci_to_hcd(vhci));
 }
 
 #define PORT_C_MASK                            \
@@ -188,7 +203,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
        int             changed = 0;
        unsigned long   flags;
 
-       retval = DIV_ROUND_UP(VHCI_NPORTS + 1, 8);
+       retval = DIV_ROUND_UP(VHCI_HC_PORTS + 1, 8);
        memset(buf, 0, retval);
 
        vhci = hcd_to_vhci(hcd);
@@ -200,7 +215,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
        }
 
        /* check pseudo status register for each port */
-       for (rhport = 0; rhport < VHCI_NPORTS; rhport++) {
+       for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++) {
                if ((vhci->port_status[rhport] & PORT_C_MASK)) {
                        /* The status of a port has been changed, */
                        usbip_dbg_vhci_rh("port %d status changed\n", rhport);
@@ -225,7 +240,7 @@ static inline void hub_descriptor(struct usb_hub_descriptor *desc)
        desc->bDescLength = 9;
        desc->wHubCharacteristics = cpu_to_le16(
                HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
-       desc->bNbrPorts = VHCI_NPORTS;
+       desc->bNbrPorts = VHCI_HC_PORTS;
        desc->u.hs.DeviceRemovable[0] = 0xff;
        desc->u.hs.DeviceRemovable[1] = 0xff;
 }
@@ -238,7 +253,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
        int             rhport;
        unsigned long   flags;
 
-       u32 prev_port_status[VHCI_NPORTS];
+       u32 prev_port_status[VHCI_HC_PORTS];
 
        if (!HCD_HW_ACCESSIBLE(hcd))
                return -ETIMEDOUT;
@@ -249,7 +264,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
         */
        usbip_dbg_vhci_rh("typeReq %x wValue %x wIndex %x\n", typeReq, wValue,
                          wIndex);
-       if (wIndex > VHCI_NPORTS)
+       if (wIndex > VHCI_HC_PORTS)
                pr_err("invalid port number %d\n", wIndex);
        rhport = ((__u8)(wIndex & 0x00ff)) - 1;
 
@@ -315,7 +330,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                break;
        case GetPortStatus:
                usbip_dbg_vhci_rh(" GetPortStatus port %x\n", wIndex);
-               if (wIndex > VHCI_NPORTS || wIndex < 1) {
+               if (wIndex > VHCI_HC_PORTS || wIndex < 1) {
                        pr_err("invalid port number %d\n", wIndex);
                        retval = -EPIPE;
                }
@@ -416,14 +431,27 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 
 static struct vhci_device *get_vdev(struct usb_device *udev)
 {
-       int i;
+       struct platform_device *pdev;
+       struct usb_hcd *hcd;
+       struct vhci_hcd *vhci;
+       int pdev_nr, rhport;
 
        if (!udev)
                return NULL;
 
-       for (i = 0; i < VHCI_NPORTS; i++)
-               if (the_controller->vdev[i].udev == udev)
-                       return port_to_vdev(i);
+       for (pdev_nr = 0; pdev_nr < vhci_num_controllers; pdev_nr++) {
+               pdev = *(vhci_pdevs + pdev_nr);
+               if (pdev == NULL)
+                       continue;
+               hcd = platform_get_drvdata(pdev);
+               if (hcd == NULL)
+                       continue;
+               vhci = hcd_to_vhci(hcd);
+               for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++) {
+                       if (vhci->vdev[rhport].udev == udev)
+                               return &vhci->vdev[rhport];
+               }
+       }
 
        return NULL;
 }
@@ -432,6 +460,7 @@ static void vhci_tx_urb(struct urb *urb)
 {
        struct vhci_device *vdev = get_vdev(urb->dev);
        struct vhci_priv *priv;
+       struct vhci_hcd *vhci = vdev_to_vhci(vdev);
        unsigned long flags;
 
        if (!vdev) {
@@ -447,7 +476,7 @@ static void vhci_tx_urb(struct urb *urb)
 
        spin_lock_irqsave(&vdev->priv_lock, flags);
 
-       priv->seqnum = atomic_inc_return(&the_controller->seqnum);
+       priv->seqnum = atomic_inc_return(&vhci->seqnum);
        if (priv->seqnum == 0xffff)
                dev_info(&urb->dev->dev, "seqnum max\n");
 
@@ -465,7 +494,9 @@ static void vhci_tx_urb(struct urb *urb)
 static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
                            gfp_t mem_flags)
 {
+       struct vhci_hcd *vhci = hcd_to_vhci(hcd);
        struct device *dev = &urb->dev->dev;
+       u8 portnum = urb->dev->portnum;
        int ret = 0;
        struct vhci_device *vdev;
        unsigned long flags;
@@ -473,26 +504,30 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
        usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n",
                          hcd, urb, mem_flags);
 
+       if (portnum > VHCI_HC_PORTS) {
+               pr_err("invalid port number %d\n", portnum);
+               return -ENODEV;
+       }
+       vdev = &vhci->vdev[portnum-1];
+
        /* patch to usb_sg_init() is in 2.5.60 */
        BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock_irqsave(&vhci->lock, flags);
 
        if (urb->status != -EINPROGRESS) {
                dev_err(dev, "URB already unlinked!, status %d\n", urb->status);
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock_irqrestore(&vhci->lock, flags);
                return urb->status;
        }
 
-       vdev = port_to_vdev(urb->dev->portnum-1);
-
        /* refuse enqueue for dead connection */
        spin_lock(&vdev->ud.lock);
        if (vdev->ud.status == VDEV_ST_NULL ||
            vdev->ud.status == VDEV_ST_ERROR) {
                dev_err(dev, "enqueue for inactive port %d\n", vdev->rhport);
                spin_unlock(&vdev->ud.lock);
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock_irqrestore(&vhci->lock, flags);
                return -ENODEV;
        }
        spin_unlock(&vdev->ud.lock);
@@ -565,17 +600,16 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 
 out:
        vhci_tx_urb(urb);
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock_irqrestore(&vhci->lock, flags);
 
        return 0;
 
 no_need_xmit:
        usb_hcd_unlink_urb_from_ep(hcd, urb);
 no_need_unlink:
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock_irqrestore(&vhci->lock, flags);
        if (!ret)
-               usb_hcd_giveback_urb(vhci_to_hcd(the_controller),
-                                    urb, urb->status);
+               usb_hcd_giveback_urb(hcd, urb, urb->status);
        return ret;
 }
 
@@ -627,19 +661,20 @@ no_need_unlink:
  */
 static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 {
+       struct vhci_hcd *vhci = hcd_to_vhci(hcd);
        struct vhci_priv *priv;
        struct vhci_device *vdev;
        unsigned long flags;
 
        pr_info("dequeue a urb %p\n", urb);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock_irqsave(&vhci->lock, flags);
 
        priv = urb->hcpriv;
        if (!priv) {
                /* URB was never linked! or will be soon given back by
                 * vhci_rx. */
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock_irqrestore(&vhci->lock, flags);
                return -EIDRM;
        }
 
@@ -648,7 +683,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 
                ret = usb_hcd_check_unlink_urb(hcd, urb, status);
                if (ret) {
-                       spin_unlock_irqrestore(&the_controller->lock, flags);
+                       spin_unlock_irqrestore(&vhci->lock, flags);
                        return ret;
                }
        }
@@ -676,10 +711,9 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 
                usb_hcd_unlink_urb_from_ep(hcd, urb);
 
-               spin_unlock_irqrestore(&the_controller->lock, flags);
-               usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
-                                    urb->status);
-               spin_lock_irqsave(&the_controller->lock, flags);
+               spin_unlock_irqrestore(&vhci->lock, flags);
+               usb_hcd_giveback_urb(vhci_to_hcd(vhci), urb, urb->status);
+               spin_lock_irqsave(&vhci->lock, flags);
 
        } else {
                /* tcp connection is alive */
@@ -691,12 +725,12 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
                unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC);
                if (!unlink) {
                        spin_unlock(&vdev->priv_lock);
-                       spin_unlock_irqrestore(&the_controller->lock, flags);
+                       spin_unlock_irqrestore(&vhci->lock, flags);
                        usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
                        return -ENOMEM;
                }
 
-               unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
+               unlink->seqnum = atomic_inc_return(&vhci->seqnum);
                if (unlink->seqnum == 0xffff)
                        pr_info("seqnum max\n");
 
@@ -712,7 +746,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
                spin_unlock(&vdev->priv_lock);
        }
 
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock_irqrestore(&vhci->lock, flags);
 
        usbip_dbg_vhci_hc("leave\n");
        return 0;
@@ -720,10 +754,12 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 
 static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
 {
+       struct vhci_hcd *vhci = vdev_to_vhci(vdev);
+       struct usb_hcd *hcd = vhci_to_hcd(vhci);
        struct vhci_unlink *unlink, *tmp;
        unsigned long flags;
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock_irqsave(&vhci->lock, flags);
        spin_lock(&vdev->priv_lock);
 
        list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {
@@ -752,24 +788,23 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
 
                urb->status = -ENODEV;
 
-               usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
+               usb_hcd_unlink_urb_from_ep(hcd, urb);
 
                list_del(&unlink->list);
 
                spin_unlock(&vdev->priv_lock);
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock_irqrestore(&vhci->lock, flags);
 
-               usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
-                                    urb->status);
+               usb_hcd_giveback_urb(hcd, urb, urb->status);
 
-               spin_lock_irqsave(&the_controller->lock, flags);
+               spin_lock_irqsave(&vhci->lock, flags);
                spin_lock(&vdev->priv_lock);
 
                kfree(unlink);
        }
 
        spin_unlock(&vdev->priv_lock);
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock_irqrestore(&vhci->lock, flags);
 }
 
 /*
@@ -827,7 +862,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
         * is actually given back by vhci_rx after receiving its return pdu.
         *
         */
-       rh_port_disconnect(vdev->rhport);
+       rh_port_disconnect(vdev);
 
        pr_info("disconnect device\n");
 }
@@ -866,7 +901,7 @@ static void vhci_device_unusable(struct usbip_device *ud)
 
 static void vhci_device_init(struct vhci_device *vdev)
 {
-       memset(vdev, 0, sizeof(*vdev));
+       memset(vdev, 0, sizeof(struct vhci_device));
 
        vdev->ud.side   = USBIP_VHCI;
        vdev->ud.status = VDEV_ST_NULL;
@@ -887,17 +922,34 @@ static void vhci_device_init(struct vhci_device *vdev)
        usbip_start_eh(&vdev->ud);
 }
 
+static int hcd_name_to_id(const char *name)
+{
+       char *c;
+       long val;
+       int ret;
+
+       c = strchr(name, '.');
+       if (c == NULL)
+               return 0;
+
+       ret = kstrtol(c+1, 10, &val);
+       if (ret < 0)
+               return ret;
+
+       return val;
+}
+
 static int vhci_start(struct usb_hcd *hcd)
 {
        struct vhci_hcd *vhci = hcd_to_vhci(hcd);
-       int rhport;
+       int id, rhport;
        int err = 0;
 
        usbip_dbg_vhci_hc("enter vhci_start\n");
 
        /* initialize private data of usb_hcd */
 
-       for (rhport = 0; rhport < VHCI_NPORTS; rhport++) {
+       for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++) {
                struct vhci_device *vdev = &vhci->vdev[rhport];
 
                vhci_device_init(vdev);
@@ -910,11 +962,26 @@ static int vhci_start(struct usb_hcd *hcd)
        hcd->power_budget = 0; /* no limit */
        hcd->uses_new_polling = 1;
 
+       id = hcd_name_to_id(hcd_name(hcd));
+       if (id < 0) {
+               pr_err("invalid vhci name %s\n", hcd_name(hcd));
+               return -EINVAL;
+       }
+
        /* vhci_hcd is now ready to be controlled through sysfs */
-       err = sysfs_create_group(&vhci_dev(vhci)->kobj, &dev_attr_group);
-       if (err) {
-               pr_err("create sysfs files\n");
-               return err;
+       if (id == 0) {
+               err = vhci_init_attr_group();
+               if (err) {
+                       pr_err("init attr group\n");
+                       return err;
+               }
+               err = sysfs_create_group(&hcd_dev(hcd)->kobj, &vhci_attr_group);
+               if (err) {
+                       pr_err("create sysfs files\n");
+                       vhci_finish_attr_group();
+                       return err;
+               }
+               pr_info("created sysfs %s\n", hcd_name(hcd));
        }
 
        return 0;
@@ -923,15 +990,19 @@ static int vhci_start(struct usb_hcd *hcd)
 static void vhci_stop(struct usb_hcd *hcd)
 {
        struct vhci_hcd *vhci = hcd_to_vhci(hcd);
-       int rhport = 0;
+       int id, rhport;
 
        usbip_dbg_vhci_hc("stop VHCI controller\n");
 
        /* 1. remove the userland interface of vhci_hcd */
-       sysfs_remove_group(&vhci_dev(vhci)->kobj, &dev_attr_group);
+       id = hcd_name_to_id(hcd_name(hcd));
+       if (id == 0) {
+               sysfs_remove_group(&hcd_dev(hcd)->kobj, &vhci_attr_group);
+               vhci_finish_attr_group();
+       }
 
        /* 2. shutdown all the ports of vhci_hcd */
-       for (rhport = 0; rhport < VHCI_NPORTS; rhport++) {
+       for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++) {
                struct vhci_device *vdev = &vhci->vdev[rhport];
 
                usbip_event_add(&vdev->ud, VDEV_EVENT_REMOVED);
@@ -1025,9 +1096,6 @@ static int vhci_hcd_probe(struct platform_device *pdev)
        }
        hcd->has_tt = 1;
 
-       /* this is private data for vhci_hcd */
-       the_controller = hcd_to_vhci(hcd);
-
        /*
         * Finish generic HCD structure initialization and register.
         * Call the driver's reset() and start() routines.
@@ -1036,7 +1104,6 @@ static int vhci_hcd_probe(struct platform_device *pdev)
        if (ret != 0) {
                pr_err("usb_add_hcd failed %d\n", ret);
                usb_put_hcd(hcd);
-               the_controller = NULL;
                return ret;
        }
 
@@ -1059,7 +1126,6 @@ static int vhci_hcd_remove(struct platform_device *pdev)
         */
        usb_remove_hcd(hcd);
        usb_put_hcd(hcd);
-       the_controller = NULL;
 
        return 0;
 }
@@ -1070,21 +1136,24 @@ static int vhci_hcd_remove(struct platform_device *pdev)
 static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state)
 {
        struct usb_hcd *hcd;
-       int rhport = 0;
+       struct vhci_hcd *vhci;
+       int rhport;
        int connected = 0;
        int ret = 0;
        unsigned long flags;
 
        hcd = platform_get_drvdata(pdev);
+       if (!hcd)
+               return 0;
+       vhci = hcd_to_vhci(hcd);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock_irqsave(&vhci->lock, flags);
 
-       for (rhport = 0; rhport < VHCI_NPORTS; rhport++)
-               if (the_controller->port_status[rhport] &
-                   USB_PORT_STAT_CONNECTION)
+       for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++)
+               if (vhci->port_status[rhport] & USB_PORT_STAT_CONNECTION)
                        connected += 1;
 
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock_irqrestore(&vhci->lock, flags);
 
        if (connected > 0) {
                dev_info(&pdev->dev,
@@ -1106,6 +1175,8 @@ static int vhci_hcd_resume(struct platform_device *pdev)
        dev_dbg(&pdev->dev, "%s\n", __func__);
 
        hcd = platform_get_drvdata(pdev);
+       if (!hcd)
+               return 0;
        set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
        usb_hcd_poll_rh_status(hcd);
 
@@ -1129,52 +1200,78 @@ static struct platform_driver vhci_driver = {
        },
 };
 
-/*
- * The VHCI 'device' is 'virtual'; not a real plug&play hardware.
- * We need to add this virtual device as a platform device arbitrarily:
- *     1. platform_device_register()
- */
-static void the_pdev_release(struct device *dev)
+static int add_platform_device(int id)
 {
+       struct platform_device *pdev;
+       int dev_nr;
+
+       if (id == 0)
+               dev_nr = -1;
+       else
+               dev_nr = id;
+
+       pdev = platform_device_register_simple(driver_name, dev_nr, NULL, 0);
+       if (IS_ERR(pdev))
+               return PTR_ERR(pdev);
+
+       *(vhci_pdevs + id) = pdev;
+       return 0;
 }
 
-static struct platform_device the_pdev = {
-       /* should be the same name as driver_name */
-       .name = driver_name,
-       .id = -1,
-       .dev = {
-               .release = the_pdev_release,
-       },
-};
+static void del_platform_devices(void)
+{
+       struct platform_device *pdev;
+       int i;
+
+       for (i = 0; i < vhci_num_controllers; i++) {
+               pdev = *(vhci_pdevs + i);
+               if (pdev != NULL)
+                       platform_device_unregister(pdev);
+               *(vhci_pdevs + i) = NULL;
+       }
+       sysfs_remove_link(&platform_bus.kobj, driver_name);
+}
 
 static int __init vhci_hcd_init(void)
 {
-       int ret;
+       int i, ret;
 
        if (usb_disabled())
                return -ENODEV;
 
+       if (vhci_num_controllers < 1)
+               vhci_num_controllers = 1;
+
+       vhci_pdevs = kcalloc(vhci_num_controllers, sizeof(void *), GFP_KERNEL);
+       if (vhci_pdevs == NULL)
+               return -ENOMEM;
+
        ret = platform_driver_register(&vhci_driver);
        if (ret)
                goto err_driver_register;
 
-       ret = platform_device_register(&the_pdev);
-       if (ret)
-               goto err_platform_device_register;
+       for (i = 0; i < vhci_num_controllers; i++) {
+               ret = add_platform_device(i);
+               if (ret)
+                       goto err_platform_device_register;
+       }
 
        pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
        return ret;
 
 err_platform_device_register:
+       del_platform_devices();
        platform_driver_unregister(&vhci_driver);
 err_driver_register:
+       kfree(vhci_pdevs);
        return ret;
 }
 
 static void __exit vhci_hcd_exit(void)
 {
-       platform_device_unregister(&the_pdev);
+       del_platform_devices();
        platform_driver_unregister(&vhci_driver);
+       kfree(vhci_pdevs);
 }
 
 module_init(vhci_hcd_init);
index d656e0edc3d50104617785da0d559943532ac1a8..fc2d319e2360b87c8d05c0b1a4f0e68a2895fa52 100644 (file)
@@ -70,6 +70,7 @@ struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum)
 static void vhci_recv_ret_submit(struct vhci_device *vdev,
                                 struct usbip_header *pdu)
 {
+       struct vhci_hcd *vhci = vdev_to_vhci(vdev);
        struct usbip_device *ud = &vdev->ud;
        struct urb *urb;
        unsigned long flags;
@@ -81,7 +82,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
        if (!urb) {
                pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
                pr_info("max seqnum %d\n",
-                       atomic_read(&the_controller->seqnum));
+                       atomic_read(&vhci->seqnum));
                usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
                return;
        }
@@ -105,11 +106,11 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
 
        usbip_dbg_vhci_rx("now giveback urb %p\n", urb);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
-       usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_lock_irqsave(&vhci->lock, flags);
+       usb_hcd_unlink_urb_from_ep(vhci_to_hcd(vhci), urb);
+       spin_unlock_irqrestore(&vhci->lock, flags);
 
-       usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
+       usb_hcd_giveback_urb(vhci_to_hcd(vhci), urb, urb->status);
 
        usbip_dbg_vhci_rx("Leave\n");
 }
@@ -142,6 +143,7 @@ static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev,
 static void vhci_recv_ret_unlink(struct vhci_device *vdev,
                                 struct usbip_header *pdu)
 {
+       struct vhci_hcd *vhci = vdev_to_vhci(vdev);
        struct vhci_unlink *unlink;
        struct urb *urb;
        unsigned long flags;
@@ -174,12 +176,11 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
                urb->status = pdu->u.ret_unlink.status;
                pr_info("urb->status %d\n", urb->status);
 
-               spin_lock_irqsave(&the_controller->lock, flags);
-               usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_lock_irqsave(&vhci->lock, flags);
+               usb_hcd_unlink_urb_from_ep(vhci_to_hcd(vhci), urb);
+               spin_unlock_irqrestore(&vhci->lock, flags);
 
-               usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
-                                    urb->status);
+               usb_hcd_giveback_urb(vhci_to_hcd(vhci), urb, urb->status);
        }
 
        kfree(unlink);
index 5b5462eb16657b03d30b293caac2e6facfbb2226..c404017c1b5ae26aa1df115c0ac1652284ed21b4 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2003-2008 Takahiro Hirofuchi
+ * Copyright (C) 2015-2016 Nobuo Iwata
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,6 +21,8 @@
 #include <linux/kthread.h>
 #include <linux/file.h>
 #include <linux/net.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "usbip_common.h"
 #include "vhci.h"
 /* TODO: refine locking ?*/
 
 /* Sysfs entry to show port status */
-static ssize_t status_show(struct device *dev, struct device_attribute *attr,
-                          char *out)
+static ssize_t status_show_vhci(int pdev_nr, char *out)
 {
+       struct platform_device *pdev = *(vhci_pdevs + pdev_nr);
+       struct vhci_hcd *vhci;
        char *s = out;
        int i = 0;
        unsigned long flags;
 
-       BUG_ON(!the_controller || !out);
+       if (!pdev || !out) {
+               usbip_dbg_vhci_sysfs("show status error\n");
+               return 0;
+       }
+
+       vhci = hcd_to_vhci(platform_get_drvdata(pdev));
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock_irqsave(&vhci->lock, flags);
 
        /*
         * output example:
-        * prt sta spd dev socket           local_busid
-        * 000 004 000 000         c5a7bb80 1-2.3
-        * 001 004 000 000         d8cee980 2-3.4
+        * port sta spd dev      socket           local_busid
+        * 0000 004 000 00000000         c5a7bb80 1-2.3
+        * 0001 004 000 00000000         d8cee980 2-3.4
         *
         * IP address can be retrieved from a socket pointer address by looking
         * up /proc/net/{tcp,tcp6}. Also, a userland program may remember a
         * port number and its peer IP address.
         */
-       out += sprintf(out,
-                      "prt sta spd bus dev socket           local_busid\n");
-
-       for (i = 0; i < VHCI_NPORTS; i++) {
-               struct vhci_device *vdev = port_to_vdev(i);
+       for (i = 0; i < VHCI_HC_PORTS; i++) {
+               struct vhci_device *vdev = &vhci->vdev[i];
 
                spin_lock(&vdev->ud.lock);
-               out += sprintf(out, "%03u %03u ", i, vdev->ud.status);
+               out += sprintf(out, "%04u %03u ",
+                                   (pdev_nr * VHCI_HC_PORTS) + i,
+                                   vdev->ud.status);
 
                if (vdev->ud.status == VDEV_ST_USED) {
                        out += sprintf(out, "%03u %08x ",
-                                      vdev->speed, vdev->devid);
-                       out += sprintf(out, "%16p ", vdev->ud.tcp_socket);
-                       out += sprintf(out, "%s", dev_name(&vdev->udev->dev));
+                                           vdev->speed, vdev->devid);
+                       out += sprintf(out, "%16p %s",
+                                           vdev->ud.tcp_socket,
+                                           dev_name(&vdev->udev->dev));
 
                } else {
-                       out += sprintf(out, "000 000 000 0000000000000000 0-0");
+                       out += sprintf(out, "000 00000000 ");
+                       out += sprintf(out, "0000000000000000 0-0");
                }
 
                out += sprintf(out, "\n");
                spin_unlock(&vdev->ud.lock);
        }
 
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock_irqrestore(&vhci->lock, flags);
+
+       return out - s;
+}
+
+static ssize_t status_show_not_ready(int pdev_nr, char *out)
+{
+       char *s = out;
+       int i = 0;
+
+       for (i = 0; i < VHCI_HC_PORTS; i++) {
+               out += sprintf(out, "%04u %03u ",
+                                   (pdev_nr * VHCI_HC_PORTS) + i,
+                                   VDEV_ST_NOTASSIGNED);
+               out += sprintf(out, "000 00000000 0000000000000000 0-0");
+               out += sprintf(out, "\n");
+       }
+       return out - s;
+}
+
+static int status_name_to_id(const char *name)
+{
+       char *c;
+       long val;
+       int ret;
+
+       c = strchr(name, '.');
+       if (c == NULL)
+               return 0;
 
+       ret = kstrtol(c+1, 10, &val);
+       if (ret < 0)
+               return ret;
+
+       return val;
+}
+
+static ssize_t status_show(struct device *dev,
+                          struct device_attribute *attr, char *out)
+{
+       char *s = out;
+       int pdev_nr;
+
+       out += sprintf(out,
+                      "port sta spd dev      socket           local_busid\n");
+
+       pdev_nr = status_name_to_id(attr->attr.name);
+       if (pdev_nr < 0)
+               out += status_show_not_ready(pdev_nr, out);
+       else
+               out += status_show_vhci(pdev_nr, out);
+
+       return out - s;
+}
+
+static ssize_t nports_show(struct device *dev, struct device_attribute *attr,
+                          char *out)
+{
+       char *s = out;
+
+       out += sprintf(out, "%d\n", VHCI_HC_PORTS * vhci_num_controllers);
        return out - s;
 }
-static DEVICE_ATTR_RO(status);
+static DEVICE_ATTR_RO(nports);
 
 /* Sysfs entry to shutdown a virtual connection */
-static int vhci_port_disconnect(__u32 rhport)
+static int vhci_port_disconnect(struct vhci_hcd *vhci, __u32 rhport)
 {
-       struct vhci_device *vdev;
+       struct vhci_device *vdev = &vhci->vdev[rhport];
        unsigned long flags;
 
        usbip_dbg_vhci_sysfs("enter\n");
 
        /* lock */
-       spin_lock_irqsave(&the_controller->lock, flags);
-
-       vdev = port_to_vdev(rhport);
-
+       spin_lock_irqsave(&vhci->lock, flags);
        spin_lock(&vdev->ud.lock);
+
        if (vdev->ud.status == VDEV_ST_NULL) {
                pr_err("not connected %d\n", vdev->ud.status);
 
                /* unlock */
                spin_unlock(&vdev->ud.lock);
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock_irqrestore(&vhci->lock, flags);
 
                return -EINVAL;
        }
 
        /* unlock */
        spin_unlock(&vdev->ud.lock);
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock_irqrestore(&vhci->lock, flags);
 
        usbip_event_add(&vdev->ud, VDEV_EVENT_DOWN);
 
        return 0;
 }
 
+static int valid_port(__u32 pdev_nr, __u32 rhport)
+{
+       if (pdev_nr >= vhci_num_controllers) {
+               pr_err("pdev %u\n", pdev_nr);
+               return 0;
+       }
+       if (rhport >= VHCI_HC_PORTS) {
+               pr_err("rhport %u\n", rhport);
+               return 0;
+       }
+       return 1;
+}
+
 static ssize_t store_detach(struct device *dev, struct device_attribute *attr,
                            const char *buf, size_t count)
 {
-       int err;
-       __u32 rhport = 0;
+       __u32 port = 0, pdev_nr = 0, rhport = 0;
+       struct usb_hcd *hcd;
+       int ret;
 
-       if (sscanf(buf, "%u", &rhport) != 1)
+       if (kstrtoint(buf, 10, &port) < 0)
                return -EINVAL;
 
-       /* check rhport */
-       if (rhport >= VHCI_NPORTS) {
-               dev_err(dev, "invalid port %u\n", rhport);
+       pdev_nr = port_to_pdev_nr(port);
+       rhport = port_to_rhport(port);
+
+       if (!valid_port(pdev_nr, rhport))
                return -EINVAL;
+
+       hcd = platform_get_drvdata(*(vhci_pdevs + pdev_nr));
+       if (hcd == NULL) {
+               dev_err(dev, "port is not ready %u\n", port);
+               return -EAGAIN;
        }
 
-       err = vhci_port_disconnect(rhport);
-       if (err < 0)
+       ret = vhci_port_disconnect(hcd_to_vhci(hcd), rhport);
+       if (ret < 0)
                return -EINVAL;
 
        usbip_dbg_vhci_sysfs("Leave\n");
@@ -135,16 +222,12 @@ static ssize_t store_detach(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR(detach, S_IWUSR, NULL, store_detach);
 
-/* Sysfs entry to establish a virtual connection */
-static int valid_args(__u32 rhport, enum usb_device_speed speed)
+static int valid_args(__u32 pdev_nr, __u32 rhport, enum usb_device_speed speed)
 {
-       /* check rhport */
-       if (rhport >= VHCI_NPORTS) {
-               pr_err("port %u\n", rhport);
-               return -EINVAL;
+       if (!valid_port(pdev_nr, rhport)) {
+               return 0;
        }
 
-       /* check speed */
        switch (speed) {
        case USB_SPEED_LOW:
        case USB_SPEED_FULL:
@@ -154,12 +237,13 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed)
        default:
                pr_err("Failed attach request for unsupported USB speed: %s\n",
                        usb_speed_string(speed));
-               return -EINVAL;
+               return 0;
        }
 
-       return 0;
+       return 1;
 }
 
+/* Sysfs entry to establish a virtual connection */
 /*
  * To start a new USB/IP attachment, a userland program needs to setup a TCP
  * connection and then write its socket descriptor with remote device
@@ -174,10 +258,12 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed)
 static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
                            const char *buf, size_t count)
 {
-       struct vhci_device *vdev;
        struct socket *socket;
        int sockfd = 0;
-       __u32 rhport = 0, devid = 0, speed = 0;
+       __u32 port = 0, pdev_nr = 0, rhport = 0, devid = 0, speed = 0;
+       struct usb_hcd *hcd;
+       struct vhci_hcd *vhci;
+       struct vhci_device *vdev;
        int err;
        unsigned long flags;
 
@@ -187,16 +273,28 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
         * @devid: unique device identifier in a remote host
         * @speed: usb device speed in a remote host
         */
-       if (sscanf(buf, "%u %u %u %u", &rhport, &sockfd, &devid, &speed) != 4)
+       if (sscanf(buf, "%u %u %u %u", &port, &sockfd, &devid, &speed) != 4)
                return -EINVAL;
+       pdev_nr = port_to_pdev_nr(port);
+       rhport = port_to_rhport(port);
 
-       usbip_dbg_vhci_sysfs("rhport(%u) sockfd(%u) devid(%u) speed(%u)\n",
-                            rhport, sockfd, devid, speed);
+       usbip_dbg_vhci_sysfs("port(%u) pdev(%d) rhport(%u)\n",
+                            port, pdev_nr, rhport);
+       usbip_dbg_vhci_sysfs("sockfd(%u) devid(%u) speed(%u)\n",
+                            sockfd, devid, speed);
 
        /* check received parameters */
-       if (valid_args(rhport, speed) < 0)
+       if (!valid_args(pdev_nr, rhport, speed))
                return -EINVAL;
 
+       hcd = platform_get_drvdata(*(vhci_pdevs + pdev_nr));
+       if (hcd == NULL) {
+               dev_err(dev, "port %d is not ready\n", port);
+               return -EAGAIN;
+       }
+       vhci = hcd_to_vhci(hcd);
+       vdev = &vhci->vdev[rhport];
+
        /* Extract socket from fd. */
        socket = sockfd_lookup(sockfd, &err);
        if (!socket)
@@ -205,14 +303,13 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
        /* now need lock until setting vdev status as used */
 
        /* begin a lock */
-       spin_lock_irqsave(&the_controller->lock, flags);
-       vdev = port_to_vdev(rhport);
+       spin_lock_irqsave(&vhci->lock, flags);
        spin_lock(&vdev->ud.lock);
 
        if (vdev->ud.status != VDEV_ST_NULL) {
                /* end of the lock */
                spin_unlock(&vdev->ud.lock);
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock_irqrestore(&vhci->lock, flags);
 
                sockfd_put(socket);
 
@@ -220,9 +317,10 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
                return -EINVAL;
        }
 
-       dev_info(dev,
-                "rhport(%u) sockfd(%d) devid(%u) speed(%u) speed_str(%s)\n",
-                rhport, sockfd, devid, speed, usb_speed_string(speed));
+       dev_info(dev, "pdev(%u) rhport(%u) sockfd(%d)\n",
+                pdev_nr, rhport, sockfd);
+       dev_info(dev, "devid(%u) speed(%u) speed_str(%s)\n",
+                devid, speed, usb_speed_string(speed));
 
        vdev->devid         = devid;
        vdev->speed         = speed;
@@ -230,26 +328,92 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
        vdev->ud.status     = VDEV_ST_NOTASSIGNED;
 
        spin_unlock(&vdev->ud.lock);
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock_irqrestore(&vhci->lock, flags);
        /* end the lock */
 
        vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx");
        vdev->ud.tcp_tx = kthread_get_run(vhci_tx_loop, &vdev->ud, "vhci_tx");
 
-       rh_port_connect(rhport, speed);
+       rh_port_connect(vdev, speed);
 
        return count;
 }
 static DEVICE_ATTR(attach, S_IWUSR, NULL, store_attach);
 
-static struct attribute *dev_attrs[] = {
-       &dev_attr_status.attr,
-       &dev_attr_detach.attr,
-       &dev_attr_attach.attr,
-       &dev_attr_usbip_debug.attr,
-       NULL,
+#define MAX_STATUS_NAME 16
+
+struct status_attr {
+       struct device_attribute attr;
+       char name[MAX_STATUS_NAME+1];
 };
 
-const struct attribute_group dev_attr_group = {
-       .attrs = dev_attrs,
+static struct status_attr *status_attrs;
+
+static void set_status_attr(int id)
+{
+       struct status_attr *status;
+
+       status = status_attrs + id;
+       if (id == 0)
+               strcpy(status->name, "status");
+       else
+               snprintf(status->name, MAX_STATUS_NAME+1, "status.%d", id);
+       status->attr.attr.name = status->name;
+       status->attr.attr.mode = S_IRUGO;
+       status->attr.show = status_show;
+}
+
+static int init_status_attrs(void)
+{
+       int id;
+
+       status_attrs = kcalloc(vhci_num_controllers, sizeof(struct status_attr),
+                              GFP_KERNEL);
+       if (status_attrs == NULL)
+               return -ENOMEM;
+
+       for (id = 0; id < vhci_num_controllers; id++)
+               set_status_attr(id);
+
+       return 0;
+}
+
+static void finish_status_attrs(void)
+{
+       kfree(status_attrs);
+}
+
+struct attribute_group vhci_attr_group = {
+       .attrs = NULL,
 };
+
+int vhci_init_attr_group(void)
+{
+       struct attribute **attrs;
+       int ret, i;
+
+       attrs = kcalloc((vhci_num_controllers + 5), sizeof(struct attribute *),
+                       GFP_KERNEL);
+       if (attrs == NULL)
+               return -ENOMEM;
+
+       ret = init_status_attrs();
+       if (ret) {
+               kfree(attrs);
+               return ret;
+       }
+       *attrs = &dev_attr_nports.attr;
+       *(attrs + 1) = &dev_attr_detach.attr;
+       *(attrs + 2) = &dev_attr_attach.attr;
+       *(attrs + 3) = &dev_attr_usbip_debug.attr;
+       for (i = 0; i < vhci_num_controllers; i++)
+               *(attrs + i + 4) = &((status_attrs + i)->attr.attr);
+       vhci_attr_group.attrs = attrs;
+       return 0;
+}
+
+void vhci_finish_attr_group(void)
+{
+       finish_status_attrs();
+       kfree(vhci_attr_group.attrs);
+}
index 8994a13819ab96563e08714fd447a39a8d29ab64..7091848df6c8b54579c231181cfb8be32fa30498 100644 (file)
@@ -450,7 +450,7 @@ static void vudc_shutdown(struct usbip_device *ud)
        if (ud->tcp_socket)
                kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR);
 
-       if (ud->tcp_tx) {
+       if (ud->tcp_rx) {
                kthread_stop_put(ud->tcp_rx);
                ud->tcp_rx = NULL;
        }
index 344bd9473475619020335ffdc9b392c9bc606e82..e429b59f6f8a634f66900f367feeb782bec10de5 100644 (file)
@@ -142,7 +142,7 @@ static int v_recv_cmd_submit(struct vudc *udc,
        urb_p->urb->status = -EINPROGRESS;
 
        /* FIXME: more pipe setup to please usbip_common */
-       urb_p->urb->pipe &= ~(11 << 30);
+       urb_p->urb->pipe &= ~(3 << 30);
        switch (urb_p->ep->type) {
        case USB_ENDPOINT_XFER_BULK:
                urb_p->urb->pipe |= (PIPE_BULK << 30);
index 33acd1599e99e92cc819d6332bd61ff7ee69665b..79b2b628066d81c5e5c6ceda10f707587c55b1c8 100644 (file)
@@ -229,10 +229,8 @@ static int wusb_ccm_mac(struct crypto_skcipher *tfm_cbc,
                zero_padding = sizeof(struct aes_ccm_block) - zero_padding;
        dst_size = blen + sizeof(b0) + sizeof(b1) + zero_padding;
        dst_buf = kzalloc(dst_size, GFP_KERNEL);
-       if (dst_buf == NULL) {
-               printk(KERN_ERR "E: can't alloc destination buffer\n");
+       if (!dst_buf)
                goto error_dst_buf;
-       }
 
        memset(iv, 0, sizeof(iv));
 
index b66faaf3e842e8338c8a6528fb260ad1ef75d16e..8c9421b69da00adb560dc7d18719591065c0f8d8 100644 (file)
@@ -374,10 +374,8 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
        struct wusb_keydvt_out keydvt_out;
 
        hs = kcalloc(3, sizeof(hs[0]), GFP_KERNEL);
-       if (hs == NULL) {
-               dev_err(dev, "can't allocate handshake data\n");
+       if (!hs)
                goto error_kzalloc;
-       }
 
        /* We need to turn encryption before beginning the 4way
         * hshake (WUSB1.0[.3.2.2]) */
index 60a10d21947d460b62b3187676a21692e2078b8f..ed4622279c63c0bb4abc76e90fba8cca4493e537 100644 (file)
@@ -271,16 +271,11 @@ int wa_nep_create(struct wahc *wa, struct usb_interface *iface)
        epd = &iface->cur_altsetting->endpoint[0].desc;
        wa->nep_buffer_size = 1024;
        wa->nep_buffer = kmalloc(wa->nep_buffer_size, GFP_KERNEL);
-       if (wa->nep_buffer == NULL) {
-               dev_err(dev,
-                       "Unable to allocate notification's read buffer\n");
+       if (!wa->nep_buffer)
                goto error_nep_buffer;
-       }
        wa->nep_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (wa->nep_urb == NULL) {
-               dev_err(dev, "Unable to allocate notification URB\n");
+       if (wa->nep_urb == NULL)
                goto error_urb_alloc;
-       }
        usb_fill_int_urb(wa->nep_urb, usb_dev,
                         usb_rcvintpipe(usb_dev, epd->bEndpointAddress),
                         wa->nep_buffer, wa->nep_buffer_size,
index 69af4fd9e07220b29edeeec2b46fbde469d7d2ac..167fcc71f5f6e95b16f49028a1852d216a0b9e64 100644 (file)
@@ -2865,10 +2865,8 @@ int wa_dti_start(struct wahc *wa)
                goto out;
 
        wa->dti_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (wa->dti_urb == NULL) {
-               dev_err(dev, "Can't allocate DTI URB\n");
+       if (wa->dti_urb == NULL)
                goto error_dti_urb_alloc;
-       }
        usb_fill_bulk_urb(
                wa->dti_urb, wa->usb_dev,
                usb_rcvbulkpipe(wa->usb_dev, 0x80 | dti_epd->bEndpointAddress),
index 0257f35cfb9d01983fa738358b54f4b600af568c..0aa6c3c29d17260f684b8bf79944eff43af04427 100644 (file)
@@ -701,10 +701,8 @@ static int hwarc_neep_init(struct uwb_rc *rc)
                goto error_rd_buffer;
        }
        hwarc->neep_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (hwarc->neep_urb == NULL) {
-               dev_err(dev, "Unable to allocate notification URB\n");
+       if (hwarc->neep_urb == NULL)
                goto error_urb_alloc;
-       }
        usb_fill_int_urb(hwarc->neep_urb, usb_dev,
                         usb_rcvintpipe(usb_dev, epd->bEndpointAddress),
                         hwarc->rd_buffer, PAGE_SIZE,
index 68952d9ccf8394412654d76fc2c14edef3f74124..99ebf6ea3de648d881de4ef1f609d1f4d29f5ca0 100644 (file)
@@ -666,10 +666,8 @@ static int usb_pcwd_probe(struct usb_interface *interface,
 
        /* allocate the urb's */
        usb_pcwd->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!usb_pcwd->intr_urb) {
-               pr_err("Out of memory\n");
+       if (!usb_pcwd->intr_urb)
                goto error;
-       }
 
        /* initialise the intr urb's */
        usb_fill_int_urb(usb_pcwd->intr_urb, udev, pipe,
index c607fce6aadd59aa765ae255d24e741a4b8458fa..9986f8288d01ae2fc22273f7aad6c86ac6cc8be5 100644 (file)
@@ -10,6 +10,7 @@
 #define  BCMA_CLKCTLST_HAVEALPREQ      0x00000008 /* ALP available request */
 #define  BCMA_CLKCTLST_HAVEHTREQ       0x00000010 /* HT available request */
 #define  BCMA_CLKCTLST_HWCROFF         0x00000020 /* Force HW clock request off */
+#define  BCMA_CLKCTLST_HQCLKREQ                0x00000040 /* HQ Clock */
 #define  BCMA_CLKCTLST_EXTRESREQ       0x00000700 /* Mask of external resource requests */
 #define  BCMA_CLKCTLST_EXTRESREQ_SHIFT 8
 #define  BCMA_CLKCTLST_HAVEALP         0x00010000 /* ALP available */
index 388f6e08b9d451dfbb360b544e766834d57d3398..80b36ca12e80ec9aec1cff524475e7195526c1a1 100644 (file)
@@ -47,7 +47,11 @@ struct ulpi_driver {
 
 #define to_ulpi_driver(d) container_of(d, struct ulpi_driver, driver)
 
-int ulpi_register_driver(struct ulpi_driver *drv);
+/*
+ * use a macro to avoid include chaining to get THIS_MODULE
+ */
+#define ulpi_register_driver(drv) __ulpi_register_driver(drv, THIS_MODULE)
+int __ulpi_register_driver(struct ulpi_driver *drv, struct module *module);
 void ulpi_unregister_driver(struct ulpi_driver *drv);
 
 #define module_ulpi_driver(__ulpi_driver) \
index 2f9bb984a4df5301386af2c61e753a9736a761c7..506ea8ffda1995436750b05bde1ebe37605de2a7 100644 (file)
 #ifndef _LINUX_MFD_SYSCON_ATMEL_SFR_H
 #define _LINUX_MFD_SYSCON_ATMEL_SFR_H
 
+#define AT91_SFR_DDRCFG                0x04    /* DDR Configuration Register */
+/* 0x08 ~ 0x0c: Reserved */
+#define AT91_SFR_OHCIICR       0x10    /* OHCI INT Configuration Register */
+#define AT91_SFR_OHCIISR       0x14    /* OHCI INT Status Register */
 #define AT91_SFR_I2SCLKSEL     0x90    /* I2SC Register */
 
+/* Field definitions */
+#define AT91_OHCIICR_SUSPEND_A BIT(8)
+#define AT91_OHCIICR_SUSPEND_B BIT(9)
+#define AT91_OHCIICR_SUSPEND_C BIT(10)
+
+#define AT91_OHCIICR_USB_SUSPEND       (AT91_OHCIICR_SUSPEND_A | \
+                                        AT91_OHCIICR_SUSPEND_B | \
+                                        AT91_OHCIICR_SUSPEND_C)
+
+
 #endif /* _LINUX_MFD_SYSCON_ATMEL_SFR_H */
This page took 0.099712 seconds and 5 git commands to generate.