public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: core: support interface node for simple USB devices
@ 2025-01-22 13:47 Catalin Popescu
  2025-01-22 13:53 ` Greg KH
  2025-01-23 11:15 ` Johan Hovold
  0 siblings, 2 replies; 9+ messages in thread
From: Catalin Popescu @ 2025-01-22 13:47 UTC (permalink / raw)
  To: gregkh, johan
  Cc: linux-usb, linux-kernel, m.felsch, bsp-development.geo,
	Catalin Popescu

A simple usb device has a single configuration and a single interface
and is considered as a "combined node" when defined in the devicetree.
If available, its interface node is simply ignored which is a problem
whenever the interface node has subnodes. To prevent that from happening
first check for any subnode and ignore the interface node only if no
subnode was found.

Example: FTDI chip FT234XD that has only one UART interface which is
being used as a serdev by other driver.

device@1 {
	compatible = "usb403,6015";
	reg = <1>;

	#address-cells = <2>;
	#size-cells = <0>;

	interface@0 {
		compatible = "usbif403,6015.config1.0";
		reg = <0 1>;

		bluetooth {
			compatible = "nxp,88w8987-bt";
		};
	};
};

Signed-off-by: Catalin Popescu <catalin.popescu@leica-geosystems.com>
---
 drivers/usb/core/message.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index d2b2787be409..f4a9d1831f6a 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -2102,6 +2102,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
 		struct usb_interface_cache *intfc;
 		struct usb_interface *intf;
 		struct usb_host_interface *alt;
+		struct device_node *np;
 		u8 ifnum;
 
 		cp->interface[i] = intf = new_interfaces[i];
@@ -2126,12 +2127,11 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
 		intf->cur_altsetting = alt;
 		usb_enable_interface(dev, intf, true);
 		intf->dev.parent = &dev->dev;
-		if (usb_of_has_combined_node(dev)) {
+		np = usb_of_get_interface_node(dev, configuration, ifnum);
+		if (!of_get_child_count(np) && usb_of_has_combined_node(dev))
 			device_set_of_node_from_dev(&intf->dev, &dev->dev);
-		} else {
-			intf->dev.of_node = usb_of_get_interface_node(dev,
-					configuration, ifnum);
-		}
+		else
+			intf->dev.of_node = np;
 		ACPI_COMPANION_SET(&intf->dev, ACPI_COMPANION(&dev->dev));
 		intf->dev.driver = NULL;
 		intf->dev.bus = &usb_bus_type;

base-commit: f066b5a6c7a06adfb666b7652cc99b4ff264f4ed
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-01-23 16:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22 13:47 [PATCH] usb: core: support interface node for simple USB devices Catalin Popescu
2025-01-22 13:53 ` Greg KH
2025-01-22 17:17   ` POPESCU Catalin
2025-01-23 11:18     ` Johan Hovold
2025-01-23 11:52       ` POPESCU Catalin
2025-01-23 11:15 ` Johan Hovold
2025-01-23 14:01   ` POPESCU Catalin
2025-01-23 15:20     ` Johan Hovold
2025-01-23 16:33       ` POPESCU Catalin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox