]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
usb: core: skip interfaces disabled in devicetree
authorMans Rullgard <mans@mansr.com>
Tue, 19 Feb 2019 14:52:26 +0000 (14:52 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Feb 2019 10:29:01 +0000 (11:29 +0100)
If an interface has an associated devicetree node with status disabled,
do not register the device.  This is useful for boards with a built-in
multifunction USB device where some functions are broken or otherwise
undesired.

Signed-off-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/message.c

index 4f33eb632a886e3740b70f57e205f030e209bc9d..82239f27c4ccf822daca19fe2e9c6cffb19933c7 100644 (file)
@@ -2006,6 +2006,13 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
        for (i = 0; i < nintf; ++i) {
                struct usb_interface *intf = cp->interface[i];
 
+               if (intf->dev.of_node &&
+                   !of_device_is_available(intf->dev.of_node)) {
+                       dev_info(&dev->dev, "skipping disabled interface %d\n",
+                                intf->cur_altsetting->desc.bInterfaceNumber);
+                       continue;
+               }
+
                dev_dbg(&dev->dev,
                        "adding %s (config #%d, interface %d)\n",
                        dev_name(&intf->dev), configuration,