Skip to contentSkip to conversation

usb: core: skip interfaces disabled in devicetree

PATCH Superseded Mans Rullgard 2 participants 5 messages Feb 16, 2019 – Feb 19, 2019 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: core: skip interfaces disabled in devicetree

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.

---
 drivers/usb/core/message.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/core/message.c +4 -0
index bfa5eda0cc26..6b45d4835e41 100644
@@ -2007,6 +2007,10 @@ 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))
+			continue;
+
 		dev_dbg(&dev->dev,
 			"adding %s (config #%d, interface %d)\n",
 			dev_name(&intf->dev), configuration,
#1 lore raw
Quoted 15 lines · Mans Rullgard

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.

---
 drivers/usb/core/message.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/core/message.c +0 -0
index bfa5eda0cc26..6b45d4835e41 100644

drivers/usb/core/message.c int usb_set_configuration(struct usb_device *dev, int configuration) · line 2012

Quoted 6 lines
drivers/usb/core/message.c +3 -0
@@ -2007,6 +2007,10 @@ 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))
+			continue;

Shouldn't you at least print some message out saying you are skipping this? Odds are this is going to cause regressions in devices that were not expecting this, right? So pointing them at why their devices now no longer work would be good :)

thanks,

greg k-h

#2 lore raw
Quoted 19 lines · Greg Kroah-Hartman
Quoted 18 lines · Mans Rullgard

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.

---
 drivers/usb/core/message.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/core/message.c +0 -0
index bfa5eda0cc26..6b45d4835e41 100644
@@ -2007,6 +2007,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
 	for (i = 0; i < nintf; ++i) {
 		struct usb_interface *intf = cp->interface[i];
 
Quoted 8 lines

drivers/usb/core/message.c int usb_set_configuration(struct usb_device *dev, int configuration) · line 2012

Quoted 3 lines
drivers/usb/core/message.c +3 -0
+		if (intf->dev.of_node &&
+		    !of_device_is_available(intf->dev.of_node))
+			continue;

Shouldn't you at least print some message out saying you are skipping this? Odds are this is going to cause regressions in devices that were not expecting this, right? So pointing them at why their devices now no longer work would be good :)

They will only be skipped if there is a device tree node for the interface _and_ it has and explicit status = "disabled" property. The default is still to create devices for all interfaces.

That said, printing a message is probably a good idea anyway. Would "info" level be appropriate for this?

#3 lore raw
Quoted 30 lines · Måns Rullgård
Quoted 19 lines · Greg Kroah-Hartman
Quoted 18 lines · Mans Rullgard

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.

---
 drivers/usb/core/message.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/core/message.c +0 -0
index bfa5eda0cc26..6b45d4835e41 100644
@@ -2007,6 +2007,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
 	for (i = 0; i < nintf; ++i) {
 		struct usb_interface *intf = cp->interface[i];
 
Quoted 8 lines

drivers/usb/core/message.c int usb_set_configuration(struct usb_device *dev, int configuration) · line 2012

Quoted 3 lines
drivers/usb/core/message.c +3 -0
+		if (intf->dev.of_node &&
+		    !of_device_is_available(intf->dev.of_node))
+			continue;

Shouldn't you at least print some message out saying you are skipping this? Odds are this is going to cause regressions in devices that were not expecting this, right? So pointing them at why their devices now no longer work would be good :)

Quoted 3 lines

They will only be skipped if there is a device tree node for the interface _and_ it has and explicit status = "disabled" property. The default is still to create devices for all interfaces.

Yes, but today if you have such a status field set, it will not skip them, so who knows who has their DT messed up :)

Quoted 2 lines

That said, printing a message is probably a good idea anyway. Would "info" level be appropriate for this?

That is a good idea.

thanks,

greg k-h

#4 lore raw

PATCH v2 1/1 usb: core: skip interfaces disabled in devicetree

In reply to Mans Rullgard

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.

---
Changed in v2:
- print message about skipped interfaces

---
 drivers/usb/core/message.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/usb/core/message.c +7 -0
index bfa5eda0cc26..46bf79bc03ad 100644
@@ -2007,6 +2007,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,