]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: Add nonblock argument to submit_int_msg
authorMichal Suchanek <msuchanek@suse.de>
Sun, 18 Aug 2019 08:55:27 +0000 (10:55 +0200)
committermarex <marex@chi.lan>
Wed, 11 Sep 2019 08:11:29 +0000 (10:11 +0200)
This will be used to implement non-blocking keyboard polling in case of
errors.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
14 files changed:
common/usb.c
common/usb_kbd.c
common/usb_storage.c
drivers/usb/emul/sandbox_keyb.c
drivers/usb/emul/usb-emul-uclass.c
drivers/usb/host/dwc2.c
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ohci-hcd.c
drivers/usb/host/sl811-hcd.c
drivers/usb/host/usb-sandbox.c
drivers/usb/host/usb-uclass.c
drivers/usb/host/xhci.c
drivers/usb/musb-new/musb_uboot.c
include/usb.h

index 14b27521395c257c47c2091ec4910c36c934e1bf..d9bcb5a57e89f5922aaba1e353a120d82490ef34 100644 (file)
@@ -192,12 +192,15 @@ int usb_disable_asynch(int disable)
  */
 
 /*
- * submits an Interrupt Message
+ * submits an Interrupt Message. Some drivers may implement non-blocking
+ * polling: when non-block is true and the device is not responding return
+ * -EAGAIN instead of waiting for device to respond.
  */
 int usb_int_msg(struct usb_device *dev, unsigned long pipe,
-               void *buffer, int transfer_len, int interval)
+               void *buffer, int transfer_len, int interval, bool nonblock)
 {
-       return submit_int_msg(dev, pipe, buffer, transfer_len, interval);
+       return submit_int_msg(dev, pipe, buffer, transfer_len, interval,
+                             nonblock);
 }
 
 /*
index ebfd972bea0371b0c6afdd995caa9e9693f4f75b..d178af248af0d5ad0b93892f00ec2dc778fbbb63 100644 (file)
@@ -341,7 +341,7 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev)
 
        /* Submit a interrupt transfer request */
        if (usb_int_msg(dev, data->intpipe, &data->new[0],
-                       data->intpktsize, data->intinterval) >= 0)
+                       data->intpktsize, data->intinterval, true) >= 0)
                usb_kbd_irq_worker(dev);
 #elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP) || \
       defined(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE)
@@ -505,7 +505,7 @@ static int usb_kbd_probe_dev(struct usb_device *dev, unsigned int ifnum)
                           1, 0, data->new, USB_KBD_BOOT_REPORT_SIZE) < 0) {
 #else
        if (usb_int_msg(dev, data->intpipe, data->new, data->intpktsize,
-                       data->intinterval) < 0) {
+                       data->intinterval, false) < 0) {
 #endif
                printf("Failed to get keyboard state from device %04x:%04x\n",
                       dev->descriptor.idVendor, dev->descriptor.idProduct);
index 9a4155c08a16e66733d402b020b9c0f8bb35fff6..54f8e53c63076cec6dc5a5ba27b746c9edec1908 100644 (file)
@@ -651,7 +651,7 @@ static int usb_stor_CBI_get_status(struct scsi_cmd *srb, struct us_data *us)
 
        us->ip_wanted = 1;
        usb_int_msg(us->pusb_dev, us->irqpipe,
-                   (void *)&us->ip_data, us->irqmaxp, us->irqinterval);
+                   (void *)&us->ip_data, us->irqmaxp, us->irqinterval, false);
        timeout = 1000;
        while (timeout--) {
                if (us->ip_wanted == 0)
index 635945179efcc038965407fd4709202282d9589c..dc43880d27e69bc9882ddd3847303bd4e9544b91 100644 (file)
@@ -178,7 +178,8 @@ static int sandbox_keyb_control(struct udevice *dev, struct usb_device *udev,
 }
 
 static int sandbox_keyb_interrupt(struct udevice *dev, struct usb_device *udev,
-               unsigned long pipe, void *buffer, int length, int interval)
+               unsigned long pipe, void *buffer, int length, int interval,
+               bool nonblock)
 {
        struct sandbox_keyb_priv *priv = dev_get_priv(dev);
        uint8_t *data = buffer;
index 973981545b91a23c71004c45f5744e7e48148bed..50da6bda8e4eda036aae71bdd04727840a6fa49a 100644 (file)
@@ -245,7 +245,8 @@ int usb_emul_bulk(struct udevice *emul, struct usb_device *udev,
 }
 
 int usb_emul_int(struct udevice *emul, struct usb_device *udev,
-                 unsigned long pipe, void *buffer, int length, int interval)
+                 unsigned long pipe, void *buffer, int length, int interval,
+                 bool nonblock)
 {
        struct dm_usb_ops *ops = usb_get_emul_ops(emul);
 
@@ -253,7 +254,8 @@ int usb_emul_int(struct udevice *emul, struct usb_device *udev,
                return -ENOSYS;
        debug("%s: dev=%s\n", __func__, emul->name);
 
-       return ops->interrupt(emul, udev, pipe, buffer, length, interval);
+       return ops->interrupt(emul, udev, pipe, buffer, length, interval,
+                             nonblock);
 }
 
 int usb_emul_setup_device(struct udevice *dev, struct usb_string *strings,
index a62a2f8a951d1ecd8572db56647dcc4b748491fd..bc6166283c63d6150011d215a17a0f7fb49c10db 100644 (file)
@@ -1108,7 +1108,8 @@ static int _submit_control_msg(struct dwc2_priv *priv, struct usb_device *dev,
 }
 
 int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev,
-                   unsigned long pipe, void *buffer, int len, int interval)
+                   unsigned long pipe, void *buffer, int len, int interval,
+                   bool nonblock)
 {
        unsigned long timeout;
        int ret;
@@ -1236,9 +1237,10 @@ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
 }
 
 int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
-                  int len, int interval)
+                  int len, int interval, bool nonblock)
 {
-       return _submit_int_msg(&local, dev, pipe, buffer, len, interval);
+       return _submit_int_msg(&local, dev, pipe, buffer, len, interval,
+                              nonblock);
 }
 
 /* U-Boot USB control interface */
@@ -1292,13 +1294,14 @@ static int dwc2_submit_bulk_msg(struct udevice *dev, struct usb_device *udev,
 
 static int dwc2_submit_int_msg(struct udevice *dev, struct usb_device *udev,
                               unsigned long pipe, void *buffer, int length,
-                              int interval)
+                              int interval, bool nonblock)
 {
        struct dwc2_priv *priv = dev_get_priv(dev);
 
        debug("%s: dev='%s', udev=%p\n", __func__, dev->name, udev);
 
-       return _submit_int_msg(priv, udev, pipe, buffer, length, interval);
+       return _submit_int_msg(priv, udev, pipe, buffer, length, interval,
+                              nonblock);
 }
 
 static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
index 4b28db70a5665f744920280118ad7aa2aff504bb..61a61abb21129ed0a2c6e3d5c70e6ba47231af78 100644 (file)
@@ -1482,7 +1482,8 @@ out:
 }
 
 static int _ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe,
-                               void *buffer, int length, int interval)
+                               void *buffer, int length, int interval,
+                               bool nonblock)
 {
        void *backbuffer;
        struct int_queue *queue;
@@ -1532,9 +1533,10 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
 }
 
 int submit_int_msg(struct usb_device *dev, unsigned long pipe,
-                  void *buffer, int length, int interval)
+                  void *buffer, int length, int interval, bool nonblock)
 {
-       return _ehci_submit_int_msg(dev, pipe, buffer, length, interval);
+       return _ehci_submit_int_msg(dev, pipe, buffer, length, interval,
+                                   nonblock);
 }
 
 struct int_queue *create_int_queue(struct usb_device *dev,
@@ -1576,10 +1578,11 @@ static int ehci_submit_bulk_msg(struct udevice *dev, struct usb_device *udev,
 
 static int ehci_submit_int_msg(struct udevice *dev, struct usb_device *udev,
                               unsigned long pipe, void *buffer, int length,
-                              int interval)
+                              int interval, bool nonblock)
 {
        debug("%s: dev='%s', udev=%p\n", __func__, dev->name, udev);
-       return _ehci_submit_int_msg(udev, pipe, buffer, length, interval);
+       return _ehci_submit_int_msg(udev, pipe, buffer, length, interval,
+                                   nonblock);
 }
 
 static struct int_queue *ehci_create_int_queue(struct udevice *dev,
index 58aa824ec0347685e0b08fac304eb6db6e46cf41..57e92a9c89317b5d100f68f5f4670a97ed932931 100644 (file)
@@ -1703,7 +1703,7 @@ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
 }
 
 int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
-               int transfer_len, int interval)
+               int transfer_len, int interval, bool nonblock)
 {
        info("submit_int_msg");
        return submit_common_msg(&gohci, dev, pipe, buffer, transfer_len, NULL,
@@ -2155,7 +2155,7 @@ static int ohci_submit_bulk_msg(struct udevice *dev, struct usb_device *udev,
 
 static int ohci_submit_int_msg(struct udevice *dev, struct usb_device *udev,
                               unsigned long pipe, void *buffer, int length,
-                              int interval)
+                              int interval, bool nonblock)
 {
        ohci_t *ohci = dev_get_priv(usb_get_bus(dev));
 
index daba0dcd1aeea4a885c2537c80c46f0b905cfc2e..e08da6130bd5ca7d53f71c688c4250d41aad79ee 100644 (file)
@@ -384,7 +384,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
 }
 
 int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
-                  int len, int interval)
+                  int len, int interval, bool nonblock)
 {
        PDEBUG(0, "dev = %p pipe = %#lx buf = %p size = %d int = %d\n", dev, pipe,
               buffer, len, interval);
index ff9d5b7231e82090b09f1e3bc719755eedc961d8..28ee4b093b64820250ae7e72e7997cac9ff04eaf 100644 (file)
@@ -99,7 +99,7 @@ static int sandbox_submit_bulk(struct udevice *bus, struct usb_device *udev,
 
 static int sandbox_submit_int(struct udevice *bus, struct usb_device *udev,
                              unsigned long pipe, void *buffer, int length,
-                             int interval)
+                             int interval, bool nonblock)
 {
        struct udevice *emul;
        int ret;
@@ -110,7 +110,8 @@ static int sandbox_submit_int(struct udevice *bus, struct usb_device *udev,
        usbmon_trace(bus, pipe, NULL, emul);
        if (ret)
                return ret;
-       ret = usb_emul_int(emul, udev, pipe, buffer, length, interval);
+       ret = usb_emul_int(emul, udev, pipe, buffer, length, interval,
+                          nonblock);
 
        return ret;
 }
index 6e118b5a8ffa408fd8b9c7f5595e0ae47b200b58..852165158869f7031c48b76d11281f3e5d519aef 100644 (file)
@@ -31,7 +31,7 @@ int usb_disable_asynch(int disable)
 }
 
 int submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer,
-                  int length, int interval)
+                  int length, int interval, bool nonblock)
 {
        struct udevice *bus = udev->controller_dev;
        struct dm_usb_ops *ops = usb_get_ops(bus);
@@ -39,7 +39,8 @@ int submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer,
        if (!ops->interrupt)
                return -ENOSYS;
 
-       return ops->interrupt(bus, udev, pipe, buffer, length, interval);
+       return ops->interrupt(bus, udev, pipe, buffer, length, interval,
+                             nonblock);
 }
 
 int submit_control_msg(struct usb_device *udev, unsigned long pipe,
index 44c5f2d264c16cd3e8c1ff433fff7f89a21ca467..b3e4dcd66fa1b611ab743fe63a39b1afa8d6f919 100644 (file)
@@ -1109,7 +1109,8 @@ unknown:
  * @return 0
  */
 static int _xhci_submit_int_msg(struct usb_device *udev, unsigned long pipe,
-                               void *buffer, int length, int interval)
+                               void *buffer, int length, int interval,
+                               bool nonblock)
 {
        if (usb_pipetype(pipe) != PIPE_INTERRUPT) {
                printf("non-interrupt pipe (type=%lu)", usb_pipetype(pipe));
@@ -1277,9 +1278,10 @@ int submit_bulk_msg(struct usb_device *udev, unsigned long pipe, void *buffer,
 }
 
 int submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer,
-                  int length, int interval)
+                  int length, int interval, bool nonblock)
 {
-       return _xhci_submit_int_msg(udev, pipe, buffer, length, interval);
+       return _xhci_submit_int_msg(udev, pipe, buffer, length, interval,
+                                   nonblock);
 }
 
 /**
@@ -1386,10 +1388,11 @@ static int xhci_submit_bulk_msg(struct udevice *dev, struct usb_device *udev,
 
 static int xhci_submit_int_msg(struct udevice *dev, struct usb_device *udev,
                               unsigned long pipe, void *buffer, int length,
-                              int interval)
+                              int interval, bool nonblock)
 {
        debug("%s: dev='%s', udev=%p\n", __func__, dev->name, udev);
-       return _xhci_submit_int_msg(udev, pipe, buffer, length, interval);
+       return _xhci_submit_int_msg(udev, pipe, buffer, length, interval,
+                                   nonblock);
 }
 
 static int xhci_alloc_device(struct udevice *dev, struct usb_device *udev)
index 9c8cc6e584439850310ee126c268346cadcbc613..9eb593402ea0c55c625adc09b052a38805e11995 100644 (file)
@@ -110,7 +110,7 @@ static int _musb_submit_bulk_msg(struct musb_host_data *host,
 
 static int _musb_submit_int_msg(struct musb_host_data *host,
        struct usb_device *dev, unsigned long pipe,
-       void *buffer, int len, int interval)
+       void *buffer, int len, int interval, bool nonblock)
 {
        construct_urb(&host->urb, &host->hep, dev, USB_ENDPOINT_XFER_INT, pipe,
                      buffer, len, NULL, interval);
@@ -268,9 +268,10 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe,
 }
 
 int submit_int_msg(struct usb_device *dev, unsigned long pipe,
-                  void *buffer, int length, int interval)
+                  void *buffer, int length, int interval, bool nonblock)
 {
-       return _musb_submit_int_msg(&musb_host, dev, pipe, buffer, length, interval);
+       return _musb_submit_int_msg(&musb_host, dev, pipe, buffer, length,
+                                   interval, nonblock);
 }
 
 struct int_queue *create_int_queue(struct usb_device *dev,
@@ -320,10 +321,11 @@ static int musb_submit_bulk_msg(struct udevice *dev, struct usb_device *udev,
 
 static int musb_submit_int_msg(struct udevice *dev, struct usb_device *udev,
                               unsigned long pipe, void *buffer, int length,
-                              int interval)
+                              int interval, bool nonblock)
 {
        struct musb_host_data *host = dev_get_priv(dev);
-       return _musb_submit_int_msg(host, udev, pipe, buffer, length, interval);
+       return _musb_submit_int_msg(host, udev, pipe, buffer, length, interval,
+                                   nonblock);
 }
 
 static struct int_queue *musb_create_int_queue(struct udevice *dev,
index 0d38d8333a98567734247e187f6ac049d6605272..bcad552f85f033009a3a436c9b0e593501ffa0bd 100644 (file)
@@ -184,7 +184,7 @@ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe,
 int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
                        int transfer_len, struct devrequest *setup);
 int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
-                       int transfer_len, int interval);
+                       int transfer_len, int interval, bool nonblock);
 
 #if defined CONFIG_USB_EHCI_HCD || defined CONFIG_USB_MUSB_HOST \
        || CONFIG_IS_ENABLED(DM_USB)
@@ -262,7 +262,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
 int usb_bulk_msg(struct usb_device *dev, unsigned int pipe,
                        void *data, int len, int *actual_length, int timeout);
 int usb_int_msg(struct usb_device *dev, unsigned long pipe,
-               void *buffer, int transfer_len, int interval);
+               void *buffer, int transfer_len, int interval, bool nonblock);
 int usb_disable_asynch(int disable);
 int usb_maxpacket(struct usb_device *dev, unsigned long pipe);
 int usb_get_configuration_no(struct usb_device *dev, int cfgno,
@@ -708,7 +708,7 @@ struct dm_usb_ops {
         */
        int (*interrupt)(struct udevice *bus, struct usb_device *udev,
                         unsigned long pipe, void *buffer, int length,
-                        int interval);
+                        int interval, bool nonblock);
 
        /**
         * create_int_queue() - Create and queue interrupt packets
@@ -1029,7 +1029,8 @@ int usb_emul_bulk(struct udevice *emul, struct usb_device *udev,
  * @return 0 if OK, -ve on error
  */
 int usb_emul_int(struct udevice *emul, struct usb_device *udev,
-                 unsigned long pipe, void *buffer, int length, int interval);
+                 unsigned long pipe, void *buffer, int length, int interval,
+                 bool nonblock);
 
 /**
  * usb_emul_find() - Find an emulator for a particular device