public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 0/6] dm: core: Support same compatible in host/gadget musb drivers
@ 2026-01-08 11:16 Markus Schneider-Pargmann (TI.com)
  2026-01-08 11:16 ` [PATCH v2 1/6] dm: core: lists_bind_fdt: Remove unused variable Markus Schneider-Pargmann (TI.com)
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-08 11:16 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher,
	Markus Schneider-Pargmann (TI.com)

Hi,

musb currently uses a wrapper driver that binds on the parent device of
the actual musb devices to manage the differentiation between gadget and
host modes. However in the upstream devicetree this parent devicetree
node can not be used to match the wrapper driver.

To be able to probe the musb devices in host/gadget mode directly, this
series introduces support for returning -ENODEV in bind functions
resulting in iterating the remaining drivers potentially binding to
other drivers that match the compatible.

It also changes the address parsing of musb-ctrl to be able to parse
relative addresses.

Best
Markus

Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
Changes in v2:
- Added a few patches to remove nearly unused variables
- Changed the inner loop in lists_bind_fdt to support set drv and not
  set entry->of_match.
- Cleanup the loop a bit more
- Link to v1: https://lore.kernel.org/r/20251126-topic-musb-probing-v2026-01-v1-0-ff8d8c487130@baylibre.com

---
Markus Schneider-Pargmann (TI.com) (6):
      dm: core: lists_bind_fdt: Remove unused variable
      dm: core: lists_bind_fdt: Replace found variable
      dm: core: Support multiple drivers with same compatibles
      test: dm: Add compatible multimatch test
      usb: musb-new: Relative ctrl_mod address parsing
      usb: musb-new: Add compatibles for ti,musb-am33xx

 arch/sandbox/dts/test.dts      |  4 +++
 drivers/core/lists.c           | 73 +++++++++++++++++++++---------------------
 drivers/usb/musb-new/ti-musb.c | 36 ++++++++++++++++++++-
 test/dm/core.c                 | 15 +++++++++
 test/dm/test-driver.c          | 25 +++++++++++++++
 5 files changed, 115 insertions(+), 38 deletions(-)
---
base-commit: 127a42c7257a6ffbbd1575ed1cbaa8f5408a44b3
change-id: 20251125-topic-musb-probing-v2026-01-1343fff8176b

Best regards,
-- 
Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>


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

* [PATCH v2 1/6] dm: core: lists_bind_fdt: Remove unused variable
  2026-01-08 11:16 [PATCH v2 0/6] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
@ 2026-01-08 11:16 ` Markus Schneider-Pargmann (TI.com)
  2026-01-09 11:32   ` Simon Glass
  2026-01-08 11:16 ` [PATCH v2 2/6] dm: core: lists_bind_fdt: Replace found variable Markus Schneider-Pargmann (TI.com)
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-08 11:16 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher,
	Markus Schneider-Pargmann (TI.com)

'result' is unused in this function, remove it.

Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 drivers/core/lists.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index c7be504b6fc69ec2870a6766eed35cb9eba46a97..52ba6c7bfa007b660b854de62c97ad3c1761f1a5 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -207,7 +207,6 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 	bool found = false;
 	const char *name, *compat_list, *compat;
 	int compat_length, i;
-	int result = 0;
 	int ret = 0;
 
 	if (devp)
@@ -283,9 +282,9 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 		break;
 	}
 
-	if (!found && !result && ret != -ENODEV)
+	if (!found && ret != -ENODEV)
 		log_debug("No match for node '%s'\n", name);
 
-	return result;
+	return 0;
 }
 #endif

-- 
2.51.0


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

* [PATCH v2 2/6] dm: core: lists_bind_fdt: Replace found variable
  2026-01-08 11:16 [PATCH v2 0/6] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
  2026-01-08 11:16 ` [PATCH v2 1/6] dm: core: lists_bind_fdt: Remove unused variable Markus Schneider-Pargmann (TI.com)
@ 2026-01-08 11:16 ` Markus Schneider-Pargmann (TI.com)
  2026-01-09 11:32   ` Simon Glass
  2026-01-08 11:16 ` [PATCH v2 3/6] dm: core: Support multiple drivers with same compatibles Markus Schneider-Pargmann (TI.com)
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-08 11:16 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher,
	Markus Schneider-Pargmann (TI.com)

'found' is only used at the end of the function to print a debug
message. No need to maintain a variable if we can just return 0
immediately when a driver was bound successfully.

Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 drivers/core/lists.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 52ba6c7bfa007b660b854de62c97ad3c1761f1a5..9d1ca38212ee7f53b8894f964f096611c8ec20a5 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -204,7 +204,6 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 	const struct udevice_id *id;
 	struct driver *entry;
 	struct udevice *dev;
-	bool found = false;
 	const char *name, *compat_list, *compat;
 	int compat_length, i;
 	int ret = 0;
@@ -275,14 +274,14 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 				ret);
 			return log_msg_ret("bind", ret);
 		} else {
-			found = true;
 			if (devp)
 				*devp = dev;
+			return 0;
 		}
 		break;
 	}
 
-	if (!found && ret != -ENODEV)
+	if (ret != -ENODEV)
 		log_debug("No match for node '%s'\n", name);
 
 	return 0;

-- 
2.51.0


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

* [PATCH v2 3/6] dm: core: Support multiple drivers with same compatibles
  2026-01-08 11:16 [PATCH v2 0/6] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
  2026-01-08 11:16 ` [PATCH v2 1/6] dm: core: lists_bind_fdt: Remove unused variable Markus Schneider-Pargmann (TI.com)
  2026-01-08 11:16 ` [PATCH v2 2/6] dm: core: lists_bind_fdt: Replace found variable Markus Schneider-Pargmann (TI.com)
@ 2026-01-08 11:16 ` Markus Schneider-Pargmann (TI.com)
  2026-01-09 11:36   ` Simon Glass
  2026-01-08 11:16 ` [PATCH v2 4/6] test: dm: Add compatible multimatch test Markus Schneider-Pargmann (TI.com)
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-08 11:16 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher,
	Markus Schneider-Pargmann (TI.com)

Currently once a driver matched the compatible string of a device, other
drivers are ignored. If the first matching driver returns -ENODEV, no
other possibly matching drivers are iterated with that compatible of the
device. Instead the next compatible in the list of compatibles is
selected, assuming only one driver matches one compatible at a time.

To be able to use the bind function to return -ENODEV and continue
matching other drivers with the same compatible, move the for loop a bit
to continue the for loop after -ENODEV was returned. The loop had to be
adjusted a bit to still support the 'drv' argument properly. Some
simplifications where done as well.

This is required for ti-musb-host and ti-musb-peripheral which both
match on the same device but differ based on the dr_mode DT property.
Depending on this property, the driver is either UCLASS_USB or
UCLASS_USB_GADGET_GENERIc. By checking the DT property in the bind
function and returning -ENODEV the other driver can probe instead.

Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 drivers/core/lists.c | 65 ++++++++++++++++++++++++++--------------------------
 1 file changed, 33 insertions(+), 32 deletions(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 9d1ca38212ee7f53b8894f964f096611c8ec20a5..3d9f9bc93954efdd624dddb1833f3a855c3c28de 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -235,50 +235,51 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
 		log_debug("   - attempt to match compatible string '%s'\n",
 			  compat);
 
-		id = NULL;
 		for (entry = driver; entry != driver + n_ents; entry++) {
+			/* Search for drivers with matching drv or existing of_match */
 			if (drv) {
 				if (drv != entry)
 					continue;
-				if (!entry->of_match)
-					break;
+			} else if (!entry->of_match) {
+				continue;
 			}
-			ret = driver_check_compatible(entry->of_match, &id,
-						      compat);
-			if (!ret)
-				break;
-		}
-		if (entry == driver + n_ents)
-			continue;
 
-		if (pre_reloc_only) {
-			if (!ofnode_pre_reloc(node) &&
-			    !(entry->flags & DM_FLAG_PRE_RELOC)) {
-				log_debug("Skipping device pre-relocation\n");
-				return 0;
+			id = NULL;
+			if (entry->of_match) {
+				ret = driver_check_compatible(entry->of_match, &id,
+							      compat);
+				if (ret)
+					continue;
+				log_debug("   - found match at driver '%s' for '%s'\n",
+					  entry->name, id->compatible);
+			}
+
+			if (pre_reloc_only) {
+				if (!ofnode_pre_reloc(node) &&
+				    !(entry->flags & DM_FLAG_PRE_RELOC)) {
+					log_debug("   - Skipping device pre-relocation\n");
+					return 0;
+				}
+			}
+
+			ret = device_bind_with_driver_data(parent, entry, name,
+							   id ? id->data : 0, node,
+							   &dev);
+			if (!drv && ret == -ENODEV) {
+				log_debug("   - Driver '%s' refuses to bind\n", entry->name);
+				continue;
+			}
+			if (ret) {
+				dm_warn("Error binding driver '%s': %d\n", entry->name,
+					ret);
+				return log_msg_ret("bind", ret);
 			}
-		}
 
-		if (entry->of_match)
-			log_debug("   - found match at driver '%s' for '%s'\n",
-				  entry->name, id->compatible);
-		ret = device_bind_with_driver_data(parent, entry, name,
-						   id ? id->data : 0, node,
-						   &dev);
-		if (ret == -ENODEV) {
-			log_debug("Driver '%s' refuses to bind\n", entry->name);
-			continue;
-		}
-		if (ret) {
-			dm_warn("Error binding driver '%s': %d\n", entry->name,
-				ret);
-			return log_msg_ret("bind", ret);
-		} else {
 			if (devp)
 				*devp = dev;
+
 			return 0;
 		}
-		break;
 	}
 
 	if (ret != -ENODEV)

-- 
2.51.0


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

* [PATCH v2 4/6] test: dm: Add compatible multimatch test
  2026-01-08 11:16 [PATCH v2 0/6] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
                   ` (2 preceding siblings ...)
  2026-01-08 11:16 ` [PATCH v2 3/6] dm: core: Support multiple drivers with same compatibles Markus Schneider-Pargmann (TI.com)
@ 2026-01-08 11:16 ` Markus Schneider-Pargmann (TI.com)
  2026-01-09 11:32   ` Simon Glass
  2026-01-08 11:16 ` [PATCH v2 5/6] usb: musb-new: Relative ctrl_mod address parsing Markus Schneider-Pargmann (TI.com)
  2026-01-08 11:16 ` [PATCH v2 6/6] usb: musb-new: Add compatibles for ti,musb-am33xx Markus Schneider-Pargmann (TI.com)
  5 siblings, 1 reply; 14+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-08 11:16 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher,
	Markus Schneider-Pargmann (TI.com)

Add a test for binding of multiple drivers with the same compatible. If
one of the drivers returns -ENODEV the other one needs to be bound.

Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 arch/sandbox/dts/test.dts |  4 ++++
 test/dm/core.c            | 15 +++++++++++++++
 test/dm/test-driver.c     | 25 +++++++++++++++++++++++++
 3 files changed, 44 insertions(+)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index a2c739a2044c728a96b5f4acbf439a42d7e12fb5..9cc854ffe80e994e34010e299029a7f1756697e0 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -457,6 +457,10 @@
 		mux-control-names = "mux0";
 	};
 
+	multimatch-test {
+		compatible = "sandbox,multimatch-test";
+	};
+
 	phy_provider0: gen_phy@0 {
 		compatible = "sandbox,phy";
 		#phy-cells = <1>;
diff --git a/test/dm/core.c b/test/dm/core.c
index 53693f4f7ed7c7265218e4154ebf81a044a3a431..78ee14af228ab20a6639bb076260296adaea2c92 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -1410,3 +1410,18 @@ static int dm_test_try_first_device(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_try_first_device, 0);
+
+/* Test that all drivers are iterated when bind returns -ENODEV */
+static int dm_test_multimatch(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+
+	ut_assertok(uclass_find_device_by_name(UCLASS_TEST, "multimatch-test",
+					       &dev));
+	ut_assertnonnull(dev);
+	ut_asserteq_str("test_multimatch_second", dev->driver->name);
+	ut_asserteq(2, dm_testdrv_op_count[DM_TEST_OP_BIND]);
+
+	return 0;
+}
+DM_TEST(dm_test_multimatch, UTF_SCAN_FDT);
diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c
index 759de3a5f77f4b64ea577a293586a737e4623f60..bf953d7814df6a0e6efd6c2a3960a925a3fbe5a7 100644
--- a/test/dm/test-driver.c
+++ b/test/dm/test-driver.c
@@ -197,3 +197,28 @@ U_BOOT_DRIVER(test_act_dma_vital_clk_drv) = {
 	.unbind	= test_manual_unbind,
 	.flags	= DM_FLAG_VITAL | DM_FLAG_ACTIVE_DMA,
 };
+
+static int test_multimatch_first_bind(struct udevice *dev)
+{
+	dm_testdrv_op_count[DM_TEST_OP_BIND]++;
+	return -ENODEV;
+}
+
+static const struct udevice_id test_multimatch_ids[] = {
+	{ .compatible = "sandbox,multimatch-test" },
+	{ }
+};
+
+U_BOOT_DRIVER(test_multimatch_first) = {
+	.name	= "test_multimatch_first",
+	.id	= UCLASS_TEST,
+	.of_match = test_multimatch_ids,
+	.bind	= test_multimatch_first_bind,
+};
+
+U_BOOT_DRIVER(test_multimatch_second) = {
+	.name	= "test_multimatch_second",
+	.id	= UCLASS_TEST,
+	.of_match = test_multimatch_ids,
+	.bind	= test_manual_bind,
+};

-- 
2.51.0


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

* [PATCH v2 5/6] usb: musb-new: Relative ctrl_mod address parsing
  2026-01-08 11:16 [PATCH v2 0/6] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
                   ` (3 preceding siblings ...)
  2026-01-08 11:16 ` [PATCH v2 4/6] test: dm: Add compatible multimatch test Markus Schneider-Pargmann (TI.com)
@ 2026-01-08 11:16 ` Markus Schneider-Pargmann (TI.com)
  2026-01-08 11:16 ` [PATCH v2 6/6] usb: musb-new: Add compatibles for ti,musb-am33xx Markus Schneider-Pargmann (TI.com)
  5 siblings, 0 replies; 14+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-08 11:16 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher,
	Markus Schneider-Pargmann (TI.com)

For the upstream DT the ctrl_mod node is using a relative register
address which is not translated by the current code.

Make address parsing understand relative addresses.

Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 drivers/usb/musb-new/ti-musb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index bcd31adba522fc55190fc43fd2dbd2dec93a2731..d3c3d3057c1df2a5cc62df3c57d8b071bb0f12b8 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -93,7 +93,7 @@ static int ti_musb_of_to_plat(struct udevice *dev)
 
 	phys = fdtdec_lookup_phandle(fdt, node, "phys");
 	ctrl_mod = fdtdec_lookup_phandle(fdt, phys, "ti,ctrl_mod");
-	plat->ctrl_mod_base = (void *)fdtdec_get_addr(fdt, ctrl_mod, "reg");
+	plat->ctrl_mod_base = (void *)ofnode_get_addr(offset_to_ofnode(ctrl_mod));
 	usb_index = ti_musb_get_usb_index(node);
 	switch (usb_index) {
 	case 1:

-- 
2.51.0


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

* [PATCH v2 6/6] usb: musb-new: Add compatibles for ti,musb-am33xx
  2026-01-08 11:16 [PATCH v2 0/6] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
                   ` (4 preceding siblings ...)
  2026-01-08 11:16 ` [PATCH v2 5/6] usb: musb-new: Relative ctrl_mod address parsing Markus Schneider-Pargmann (TI.com)
@ 2026-01-08 11:16 ` Markus Schneider-Pargmann (TI.com)
  5 siblings, 0 replies; 14+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2026-01-08 11:16 UTC (permalink / raw)
  To: u-boot, Mattijs Korpershoek
  Cc: Simon Glass, Tom Rini, Marek Vasut, Andrew Goodbody,
	Kory Maincent, Svyatoslav Ryhel, Christian Marangi,
	Dinesh Maniyam, Heiko Schocher,
	Markus Schneider-Pargmann (TI.com)

The upstream devicetree am33xx.dtsi does not have a "ti,am33xx-usb"
compatible, it uses "ti,sysc-omap4" for the same node. The
implementation of ti-musb uses a wrapper driver that binds to
ti,am33xx-usb and creates new devices ti-musb-host and
ti-musb-peripheral depending on the dr_mode property.

To avoid this wrapper driver with the upstream devicetree, add
compatibles for "ti,musb-am33xx" to both ti-musb-host and
ti-musb-peripheral. Add a bind function that checks for the correct
dr_mode value and rejects binding if it is not the correct driver.

Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
 drivers/usb/musb-new/ti-musb.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index d3c3d3057c1df2a5cc62df3c57d8b071bb0f12b8..3ed6428d09883cf5af28b212c0d614b3d8ef9227 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -183,6 +183,16 @@ static int ti_musb_host_remove(struct udevice *dev)
 }
 
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+static int ti_musb_host_bind(struct udevice *dev)
+{
+	enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+
+	if (dr_mode != USB_DR_MODE_HOST && dr_mode != USB_DR_MODE_OTG)
+		return -ENODEV;
+
+	return 0;
+}
+
 static int ti_musb_host_of_to_plat(struct udevice *dev)
 {
 	struct ti_musb_plat *plat = dev_get_plat(dev);
@@ -200,12 +210,19 @@ static int ti_musb_host_of_to_plat(struct udevice *dev)
 
 	return 0;
 }
+
+static const struct udevice_id ti_musb_host_ids[] = {
+	{ .compatible = "ti,musb-am33xx" },
+	{ }
+};
 #endif
 
 U_BOOT_DRIVER(ti_musb_host) = {
 	.name	= "ti-musb-host",
 	.id	= UCLASS_USB,
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+	.of_match = ti_musb_host_ids,
+	.bind = ti_musb_host_bind,
 	.of_to_plat = ti_musb_host_of_to_plat,
 #endif
 	.probe = ti_musb_host_probe,
@@ -221,6 +238,16 @@ struct ti_musb_peripheral {
 };
 
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+static int ti_musb_peripheral_bind(struct udevice *dev)
+{
+	enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+
+	if (dr_mode != USB_DR_MODE_PERIPHERAL)
+		return -ENODEV;
+
+	return 0;
+}
+
 static int ti_musb_peripheral_of_to_plat(struct udevice *dev)
 {
 	struct ti_musb_plat *plat = dev_get_plat(dev);
@@ -237,6 +264,11 @@ static int ti_musb_peripheral_of_to_plat(struct udevice *dev)
 
 	return 0;
 }
+
+static const struct udevice_id ti_musb_peripheral_ids[] = {
+	{ .compatible = "ti,musb-am33xx" },
+	{ }
+};
 #endif
 
 static int ti_musb_peripheral_probe(struct udevice *dev)
@@ -283,6 +315,8 @@ U_BOOT_DRIVER(ti_musb_peripheral) = {
 	.name	= "ti-musb-peripheral",
 	.id	= UCLASS_USB_GADGET_GENERIC,
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+	.of_match = ti_musb_peripheral_ids,
+	.bind = ti_musb_peripheral_bind,
 	.of_to_plat = ti_musb_peripheral_of_to_plat,
 #endif
 	.ops	= &ti_musb_gadget_ops,

-- 
2.51.0


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

* Re: [PATCH v2 1/6] dm: core: lists_bind_fdt: Remove unused variable
  2026-01-08 11:16 ` [PATCH v2 1/6] dm: core: lists_bind_fdt: Remove unused variable Markus Schneider-Pargmann (TI.com)
@ 2026-01-09 11:32   ` Simon Glass
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Glass @ 2026-01-09 11:32 UTC (permalink / raw)
  To: Markus Schneider-Pargmann (TI.com)
  Cc: u-boot, Mattijs Korpershoek, Tom Rini, Marek Vasut,
	Andrew Goodbody, Kory Maincent, Svyatoslav Ryhel,
	Christian Marangi, Dinesh Maniyam, Heiko Schocher

On Thu, 8 Jan 2026 at 04:17, Markus Schneider-Pargmann (TI.com)
<msp@baylibre.com> wrote:
>
> 'result' is unused in this function, remove it.
>
> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
> ---
>  drivers/core/lists.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass <simon.glass@canonical.com>


>
> diff --git a/drivers/core/lists.c b/drivers/core/lists.c
> index c7be504b6fc69ec2870a6766eed35cb9eba46a97..52ba6c7bfa007b660b854de62c97ad3c1761f1a5 100644
> --- a/drivers/core/lists.c
> +++ b/drivers/core/lists.c
> @@ -207,7 +207,6 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
>         bool found = false;
>         const char *name, *compat_list, *compat;
>         int compat_length, i;
> -       int result = 0;
>         int ret = 0;
>
>         if (devp)
> @@ -283,9 +282,9 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
>                 break;
>         }
>
> -       if (!found && !result && ret != -ENODEV)
> +       if (!found && ret != -ENODEV)
>                 log_debug("No match for node '%s'\n", name);
>
> -       return result;
> +       return 0;
>  }
>  #endif
>
> --
> 2.51.0
>

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

* Re: [PATCH v2 2/6] dm: core: lists_bind_fdt: Replace found variable
  2026-01-08 11:16 ` [PATCH v2 2/6] dm: core: lists_bind_fdt: Replace found variable Markus Schneider-Pargmann (TI.com)
@ 2026-01-09 11:32   ` Simon Glass
  2026-01-12  9:31     ` Markus Schneider-Pargmann
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Glass @ 2026-01-09 11:32 UTC (permalink / raw)
  To: Markus Schneider-Pargmann (TI.com)
  Cc: u-boot, Mattijs Korpershoek, Tom Rini, Marek Vasut,
	Andrew Goodbody, Kory Maincent, Svyatoslav Ryhel,
	Christian Marangi, Dinesh Maniyam, Heiko Schocher

Hi Markus,

On Thu, 8 Jan 2026 at 04:17, Markus Schneider-Pargmann (TI.com)
<msp@baylibre.com> wrote:
>
> 'found' is only used at the end of the function to print a debug
> message. No need to maintain a variable if we can just return 0
> immediately when a driver was bound successfully.
>
> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
> ---
>  drivers/core/lists.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/core/lists.c b/drivers/core/lists.c
> index 52ba6c7bfa007b660b854de62c97ad3c1761f1a5..9d1ca38212ee7f53b8894f964f096611c8ec20a5 100644
> --- a/drivers/core/lists.c
> +++ b/drivers/core/lists.c
> @@ -204,7 +204,6 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
>         const struct udevice_id *id;
>         struct driver *entry;
>         struct udevice *dev;
> -       bool found = false;
>         const char *name, *compat_list, *compat;
>         int compat_length, i;
>         int ret = 0;
> @@ -275,14 +274,14 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
>                                 ret);
>                         return log_msg_ret("bind", ret);
>                 } else {
> -                       found = true;
>                         if (devp)
>                                 *devp = dev;
> +                       return 0;
>                 }
>                 break;
>         }
>
> -       if (!found && ret != -ENODEV)
> +       if (ret != -ENODEV)
>                 log_debug("No match for node '%s'\n", name);
>
>         return 0;
>
> --
> 2.51.0
>

I like to have a single successful return at the end of each function
so that it is easier to follow what is going on. But since you wrote
this patch:

Reviewed-by: Simon Glass <simon.glass@canonical.com>

Regards,
Simon

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

* Re: [PATCH v2 4/6] test: dm: Add compatible multimatch test
  2026-01-08 11:16 ` [PATCH v2 4/6] test: dm: Add compatible multimatch test Markus Schneider-Pargmann (TI.com)
@ 2026-01-09 11:32   ` Simon Glass
  2026-01-12  9:48     ` Markus Schneider-Pargmann
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Glass @ 2026-01-09 11:32 UTC (permalink / raw)
  To: Markus Schneider-Pargmann (TI.com)
  Cc: u-boot, Mattijs Korpershoek, Tom Rini, Marek Vasut,
	Andrew Goodbody, Kory Maincent, Svyatoslav Ryhel,
	Christian Marangi, Dinesh Maniyam, Heiko Schocher

Hi Markus,

On Thu, 8 Jan 2026 at 04:17, Markus Schneider-Pargmann (TI.com)
<msp@baylibre.com> wrote:
>
> Add a test for binding of multiple drivers with the same compatible. If
> one of the drivers returns -ENODEV the other one needs to be bound.
>
> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
> ---
>  arch/sandbox/dts/test.dts |  4 ++++
>  test/dm/core.c            | 15 +++++++++++++++
>  test/dm/test-driver.c     | 25 +++++++++++++++++++++++++
>  3 files changed, 44 insertions(+)
>

Reviewed-by: Simon Glass <simon.glass@canonical.com>

nit below

> diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
> index a2c739a2044c728a96b5f4acbf439a42d7e12fb5..9cc854ffe80e994e34010e299029a7f1756697e0 100644
> --- a/arch/sandbox/dts/test.dts
> +++ b/arch/sandbox/dts/test.dts
> @@ -457,6 +457,10 @@
>                 mux-control-names = "mux0";
>         };
>
> +       multimatch-test {
> +               compatible = "sandbox,multimatch-test";
> +       };
> +
>         phy_provider0: gen_phy@0 {
>                 compatible = "sandbox,phy";
>                 #phy-cells = <1>;
> diff --git a/test/dm/core.c b/test/dm/core.c
> index 53693f4f7ed7c7265218e4154ebf81a044a3a431..78ee14af228ab20a6639bb076260296adaea2c92 100644
> --- a/test/dm/core.c
> +++ b/test/dm/core.c
> @@ -1410,3 +1410,18 @@ static int dm_test_try_first_device(struct unit_test_state *uts)
>         return 0;
>  }
>  DM_TEST(dm_test_try_first_device, 0);
> +
> +/* Test that all drivers are iterated when bind returns -ENODEV */
> +static int dm_test_multimatch(struct unit_test_state *uts)
> +{
> +       struct udevice *dev;
> +
> +       ut_assertok(uclass_find_device_by_name(UCLASS_TEST, "multimatch-test",
> +                                              &dev));
> +       ut_assertnonnull(dev);
> +       ut_asserteq_str("test_multimatch_second", dev->driver->name);
> +       ut_asserteq(2, dm_testdrv_op_count[DM_TEST_OP_BIND]);
> +
> +       return 0;
> +}
> +DM_TEST(dm_test_multimatch, UTF_SCAN_FDT);
> diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c
> index 759de3a5f77f4b64ea577a293586a737e4623f60..bf953d7814df6a0e6efd6c2a3960a925a3fbe5a7 100644
> --- a/test/dm/test-driver.c
> +++ b/test/dm/test-driver.c
> @@ -197,3 +197,28 @@ U_BOOT_DRIVER(test_act_dma_vital_clk_drv) = {
>         .unbind = test_manual_unbind,
>         .flags  = DM_FLAG_VITAL | DM_FLAG_ACTIVE_DMA,
>  };
> +
> +static int test_multimatch_first_bind(struct udevice *dev)
> +{
> +       dm_testdrv_op_count[DM_TEST_OP_BIND]++;

<blank line here>

> +       return -ENODEV;
> +}
> +
> +static const struct udevice_id test_multimatch_ids[] = {
> +       { .compatible = "sandbox,multimatch-test" },
> +       { }
> +};
> +
> +U_BOOT_DRIVER(test_multimatch_first) = {
> +       .name   = "test_multimatch_first",
> +       .id     = UCLASS_TEST,
> +       .of_match = test_multimatch_ids,
> +       .bind   = test_multimatch_first_bind,
> +};
> +
> +U_BOOT_DRIVER(test_multimatch_second) = {
> +       .name   = "test_multimatch_second",
> +       .id     = UCLASS_TEST,
> +       .of_match = test_multimatch_ids,
> +       .bind   = test_manual_bind,
> +};
>
> --
> 2.51.0
>

Regards,
Simon

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

* Re: [PATCH v2 3/6] dm: core: Support multiple drivers with same compatibles
  2026-01-08 11:16 ` [PATCH v2 3/6] dm: core: Support multiple drivers with same compatibles Markus Schneider-Pargmann (TI.com)
@ 2026-01-09 11:36   ` Simon Glass
  2026-01-12  9:41     ` Markus Schneider-Pargmann
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Glass @ 2026-01-09 11:36 UTC (permalink / raw)
  To: Markus Schneider-Pargmann (TI.com)
  Cc: u-boot, Mattijs Korpershoek, Tom Rini, Marek Vasut,
	Andrew Goodbody, Kory Maincent, Svyatoslav Ryhel,
	Christian Marangi, Dinesh Maniyam, Heiko Schocher

Hi Markus,

On Thu, 8 Jan 2026 at 04:17, Markus Schneider-Pargmann (TI.com)
<msp@baylibre.com> wrote:
>
> Currently once a driver matched the compatible string of a device, other
> drivers are ignored. If the first matching driver returns -ENODEV, no
> other possibly matching drivers are iterated with that compatible of the
> device. Instead the next compatible in the list of compatibles is
> selected, assuming only one driver matches one compatible at a time.
>
> To be able to use the bind function to return -ENODEV and continue
> matching other drivers with the same compatible, move the for loop a bit
> to continue the for loop after -ENODEV was returned. The loop had to be
> adjusted a bit to still support the 'drv' argument properly. Some
> simplifications where done as well.
>
> This is required for ti-musb-host and ti-musb-peripheral which both
> match on the same device but differ based on the dr_mode DT property.
> Depending on this property, the driver is either UCLASS_USB or
> UCLASS_USB_GADGET_GENERIc. By checking the DT property in the bind
> function and returning -ENODEV the other driver can probe instead.
>
> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
> ---
>  drivers/core/lists.c | 65 ++++++++++++++++++++++++++--------------------------
>  1 file changed, 33 insertions(+), 32 deletions(-)
>

Reviewed-by: Simon Glass <simon.glass@canonical.com>

I would like to see some discussion about performance here. It seems
that all you are doing here is not exiting the loop early, so the
impact should be small?

> diff --git a/drivers/core/lists.c b/drivers/core/lists.c
> index 9d1ca38212ee7f53b8894f964f096611c8ec20a5..3d9f9bc93954efdd624dddb1833f3a855c3c28de 100644
> --- a/drivers/core/lists.c
> +++ b/drivers/core/lists.c
> @@ -235,50 +235,51 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
>                 log_debug("   - attempt to match compatible string '%s'\n",
>                           compat);
>
> -               id = NULL;
>                 for (entry = driver; entry != driver + n_ents; entry++) {
> +                       /* Search for drivers with matching drv or existing of_match */
>                         if (drv) {
>                                 if (drv != entry)
>                                         continue;
> -                               if (!entry->of_match)
> -                                       break;
> +                       } else if (!entry->of_match) {
> +                               continue;
>                         }
> -                       ret = driver_check_compatible(entry->of_match, &id,
> -                                                     compat);
> -                       if (!ret)
> -                               break;
> -               }
> -               if (entry == driver + n_ents)
> -                       continue;
>
> -               if (pre_reloc_only) {
> -                       if (!ofnode_pre_reloc(node) &&
> -                           !(entry->flags & DM_FLAG_PRE_RELOC)) {
> -                               log_debug("Skipping device pre-relocation\n");
> -                               return 0;
> +                       id = NULL;
> +                       if (entry->of_match) {
> +                               ret = driver_check_compatible(entry->of_match, &id,
> +                                                             compat);
> +                               if (ret)
> +                                       continue;
> +                               log_debug("   - found match at driver '%s' for '%s'\n",
> +                                         entry->name, id->compatible);
> +                       }
> +
> +                       if (pre_reloc_only) {
> +                               if (!ofnode_pre_reloc(node) &&
> +                                   !(entry->flags & DM_FLAG_PRE_RELOC)) {
> +                                       log_debug("   - Skipping device pre-relocation\n");
> +                                       return 0;
> +                               }
> +                       }
> +
> +                       ret = device_bind_with_driver_data(parent, entry, name,
> +                                                          id ? id->data : 0, node,
> +                                                          &dev);
> +                       if (!drv && ret == -ENODEV) {
> +                               log_debug("   - Driver '%s' refuses to bind\n", entry->name);
> +                               continue;
> +                       }
> +                       if (ret) {
> +                               dm_warn("Error binding driver '%s': %d\n", entry->name,
> +                                       ret);
> +                               return log_msg_ret("bind", ret);
>                         }
> -               }
>
> -               if (entry->of_match)
> -                       log_debug("   - found match at driver '%s' for '%s'\n",
> -                                 entry->name, id->compatible);
> -               ret = device_bind_with_driver_data(parent, entry, name,
> -                                                  id ? id->data : 0, node,
> -                                                  &dev);
> -               if (ret == -ENODEV) {
> -                       log_debug("Driver '%s' refuses to bind\n", entry->name);
> -                       continue;
> -               }
> -               if (ret) {
> -                       dm_warn("Error binding driver '%s': %d\n", entry->name,
> -                               ret);
> -                       return log_msg_ret("bind", ret);
> -               } else {
>                         if (devp)
>                                 *devp = dev;
> +
>                         return 0;
>                 }
> -               break;
>         }
>
>         if (ret != -ENODEV)
>
> --
> 2.51.0
>

Regards,
Simon

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

* Re: [PATCH v2 2/6] dm: core: lists_bind_fdt: Replace found variable
  2026-01-09 11:32   ` Simon Glass
@ 2026-01-12  9:31     ` Markus Schneider-Pargmann
  0 siblings, 0 replies; 14+ messages in thread
From: Markus Schneider-Pargmann @ 2026-01-12  9:31 UTC (permalink / raw)
  To: Simon Glass, Markus Schneider-Pargmann (TI.com)
  Cc: u-boot, Mattijs Korpershoek, Tom Rini, Marek Vasut,
	Andrew Goodbody, Kory Maincent, Svyatoslav Ryhel,
	Christian Marangi, Dinesh Maniyam, Heiko Schocher

[-- Attachment #1: Type: text/plain, Size: 2283 bytes --]

Hi Simon,

On Fri Jan 9, 2026 at 12:32 PM CET, Simon Glass wrote:
> Hi Markus,
>
> On Thu, 8 Jan 2026 at 04:17, Markus Schneider-Pargmann (TI.com)
> <msp@baylibre.com> wrote:
>>
>> 'found' is only used at the end of the function to print a debug
>> message. No need to maintain a variable if we can just return 0
>> immediately when a driver was bound successfully.
>>
>> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
>> ---
>>  drivers/core/lists.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/core/lists.c b/drivers/core/lists.c
>> index 52ba6c7bfa007b660b854de62c97ad3c1761f1a5..9d1ca38212ee7f53b8894f964f096611c8ec20a5 100644
>> --- a/drivers/core/lists.c
>> +++ b/drivers/core/lists.c
>> @@ -204,7 +204,6 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
>>         const struct udevice_id *id;
>>         struct driver *entry;
>>         struct udevice *dev;
>> -       bool found = false;
>>         const char *name, *compat_list, *compat;
>>         int compat_length, i;
>>         int ret = 0;
>> @@ -275,14 +274,14 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
>>                                 ret);
>>                         return log_msg_ret("bind", ret);
>>                 } else {
>> -                       found = true;
>>                         if (devp)
>>                                 *devp = dev;
>> +                       return 0;
>>                 }
>>                 break;
>>         }
>>
>> -       if (!found && ret != -ENODEV)
>> +       if (ret != -ENODEV)
>>                 log_debug("No match for node '%s'\n", name);
>>
>>         return 0;
>>
>> --
>> 2.51.0
>>
>
> I like to have a single successful return at the end of each function
> so that it is easier to follow what is going on. But since you wrote
> this patch:
>
> Reviewed-by: Simon Glass <simon.glass@canonical.com>

Thanks for reviewing. If you prefer I can redesign this as well. But
also note that the function already has two early return 0. One if the
device does not have a compatible list and the other for pre_reloc_only
if pre-relocation is skipped.

Best
Markus


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 289 bytes --]

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

* Re: [PATCH v2 3/6] dm: core: Support multiple drivers with same compatibles
  2026-01-09 11:36   ` Simon Glass
@ 2026-01-12  9:41     ` Markus Schneider-Pargmann
  0 siblings, 0 replies; 14+ messages in thread
From: Markus Schneider-Pargmann @ 2026-01-12  9:41 UTC (permalink / raw)
  To: Simon Glass, Markus Schneider-Pargmann (TI.com)
  Cc: u-boot, Mattijs Korpershoek, Tom Rini, Marek Vasut,
	Andrew Goodbody, Kory Maincent, Svyatoslav Ryhel,
	Christian Marangi, Dinesh Maniyam, Heiko Schocher

[-- Attachment #1: Type: text/plain, Size: 5279 bytes --]

Hi Simon,

On Fri Jan 9, 2026 at 12:36 PM CET, Simon Glass wrote:
> Hi Markus,
>
> On Thu, 8 Jan 2026 at 04:17, Markus Schneider-Pargmann (TI.com)
> <msp@baylibre.com> wrote:
>>
>> Currently once a driver matched the compatible string of a device, other
>> drivers are ignored. If the first matching driver returns -ENODEV, no
>> other possibly matching drivers are iterated with that compatible of the
>> device. Instead the next compatible in the list of compatibles is
>> selected, assuming only one driver matches one compatible at a time.
>>
>> To be able to use the bind function to return -ENODEV and continue
>> matching other drivers with the same compatible, move the for loop a bit
>> to continue the for loop after -ENODEV was returned. The loop had to be
>> adjusted a bit to still support the 'drv' argument properly. Some
>> simplifications where done as well.
>>
>> This is required for ti-musb-host and ti-musb-peripheral which both
>> match on the same device but differ based on the dr_mode DT property.
>> Depending on this property, the driver is either UCLASS_USB or
>> UCLASS_USB_GADGET_GENERIc. By checking the DT property in the bind
>> function and returning -ENODEV the other driver can probe instead.
>>
>> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
>> ---
>>  drivers/core/lists.c | 65 ++++++++++++++++++++++++++--------------------------
>>  1 file changed, 33 insertions(+), 32 deletions(-)
>>
>
> Reviewed-by: Simon Glass <simon.glass@canonical.com>
>
> I would like to see some discussion about performance here. It seems
> that all you are doing here is not exiting the loop early, so the
> impact should be small?

See inline.

>
>> diff --git a/drivers/core/lists.c b/drivers/core/lists.c
>> index 9d1ca38212ee7f53b8894f964f096611c8ec20a5..3d9f9bc93954efdd624dddb1833f3a855c3c28de 100644
>> --- a/drivers/core/lists.c
>> +++ b/drivers/core/lists.c
>> @@ -235,50 +235,51 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
>>                 log_debug("   - attempt to match compatible string '%s'\n",
>>                           compat);
>>
>> -               id = NULL;
>>                 for (entry = driver; entry != driver + n_ents; entry++) {
>> +                       /* Search for drivers with matching drv or existing of_match */
>>                         if (drv) {
>>                                 if (drv != entry)
>>                                         continue;
>> -                               if (!entry->of_match)
>> -                                       break;
>> +                       } else if (!entry->of_match) {
>> +                               continue;
>>                         }
>> -                       ret = driver_check_compatible(entry->of_match, &id,
>> -                                                     compat);
>> -                       if (!ret)
>> -                               break;
>> -               }
>> -               if (entry == driver + n_ents)
>> -                       continue;
>>
>> -               if (pre_reloc_only) {
>> -                       if (!ofnode_pre_reloc(node) &&
>> -                           !(entry->flags & DM_FLAG_PRE_RELOC)) {
>> -                               log_debug("Skipping device pre-relocation\n");
>> -                               return 0;
>> +                       id = NULL;
>> +                       if (entry->of_match) {
>> +                               ret = driver_check_compatible(entry->of_match, &id,
>> +                                                             compat);
>> +                               if (ret)
>> +                                       continue;
>> +                               log_debug("   - found match at driver '%s' for '%s'\n",
>> +                                         entry->name, id->compatible);
>> +                       }
>> +
>> +                       if (pre_reloc_only) {
>> +                               if (!ofnode_pre_reloc(node) &&
>> +                                   !(entry->flags & DM_FLAG_PRE_RELOC)) {
>> +                                       log_debug("   - Skipping device pre-relocation\n");
>> +                                       return 0;
>> +                               }
>> +                       }
>> +
>> +                       ret = device_bind_with_driver_data(parent, entry, name,
>> +                                                          id ? id->data : 0, node,
>> +                                                          &dev);
>> +                       if (!drv && ret == -ENODEV) {
>> +                               log_debug("   - Driver '%s' refuses to bind\n", entry->name);
>> +                               continue;

So for performance this continue is the only new way to continue this
loop which wasn't done before this patch. And that only happens when the
driver returns -ENODEV. All other ways through this for loop below
return in some way. On error we return, on success we return 0.

Finding the right driver has the same continue and exit conditions as
before.

I will add a short paragraph to the commit message as well.

Best
Markus

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 289 bytes --]

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

* Re: [PATCH v2 4/6] test: dm: Add compatible multimatch test
  2026-01-09 11:32   ` Simon Glass
@ 2026-01-12  9:48     ` Markus Schneider-Pargmann
  0 siblings, 0 replies; 14+ messages in thread
From: Markus Schneider-Pargmann @ 2026-01-12  9:48 UTC (permalink / raw)
  To: Simon Glass, Markus Schneider-Pargmann (TI.com)
  Cc: u-boot, Mattijs Korpershoek, Tom Rini, Marek Vasut,
	Andrew Goodbody, Kory Maincent, Svyatoslav Ryhel,
	Christian Marangi, Dinesh Maniyam, Heiko Schocher

[-- Attachment #1: Type: text/plain, Size: 3524 bytes --]

On Fri Jan 9, 2026 at 12:32 PM CET, Simon Glass wrote:
> Hi Markus,
>
> On Thu, 8 Jan 2026 at 04:17, Markus Schneider-Pargmann (TI.com)
> <msp@baylibre.com> wrote:
>>
>> Add a test for binding of multiple drivers with the same compatible. If
>> one of the drivers returns -ENODEV the other one needs to be bound.
>>
>> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
>> ---
>>  arch/sandbox/dts/test.dts |  4 ++++
>>  test/dm/core.c            | 15 +++++++++++++++
>>  test/dm/test-driver.c     | 25 +++++++++++++++++++++++++
>>  3 files changed, 44 insertions(+)
>>
>
> Reviewed-by: Simon Glass <simon.glass@canonical.com>
>
> nit below

Done, and thanks for your reviews!

Best
Markus

>
>> diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
>> index a2c739a2044c728a96b5f4acbf439a42d7e12fb5..9cc854ffe80e994e34010e299029a7f1756697e0 100644
>> --- a/arch/sandbox/dts/test.dts
>> +++ b/arch/sandbox/dts/test.dts
>> @@ -457,6 +457,10 @@
>>                 mux-control-names = "mux0";
>>         };
>>
>> +       multimatch-test {
>> +               compatible = "sandbox,multimatch-test";
>> +       };
>> +
>>         phy_provider0: gen_phy@0 {
>>                 compatible = "sandbox,phy";
>>                 #phy-cells = <1>;
>> diff --git a/test/dm/core.c b/test/dm/core.c
>> index 53693f4f7ed7c7265218e4154ebf81a044a3a431..78ee14af228ab20a6639bb076260296adaea2c92 100644
>> --- a/test/dm/core.c
>> +++ b/test/dm/core.c
>> @@ -1410,3 +1410,18 @@ static int dm_test_try_first_device(struct unit_test_state *uts)
>>         return 0;
>>  }
>>  DM_TEST(dm_test_try_first_device, 0);
>> +
>> +/* Test that all drivers are iterated when bind returns -ENODEV */
>> +static int dm_test_multimatch(struct unit_test_state *uts)
>> +{
>> +       struct udevice *dev;
>> +
>> +       ut_assertok(uclass_find_device_by_name(UCLASS_TEST, "multimatch-test",
>> +                                              &dev));
>> +       ut_assertnonnull(dev);
>> +       ut_asserteq_str("test_multimatch_second", dev->driver->name);
>> +       ut_asserteq(2, dm_testdrv_op_count[DM_TEST_OP_BIND]);
>> +
>> +       return 0;
>> +}
>> +DM_TEST(dm_test_multimatch, UTF_SCAN_FDT);
>> diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c
>> index 759de3a5f77f4b64ea577a293586a737e4623f60..bf953d7814df6a0e6efd6c2a3960a925a3fbe5a7 100644
>> --- a/test/dm/test-driver.c
>> +++ b/test/dm/test-driver.c
>> @@ -197,3 +197,28 @@ U_BOOT_DRIVER(test_act_dma_vital_clk_drv) = {
>>         .unbind = test_manual_unbind,
>>         .flags  = DM_FLAG_VITAL | DM_FLAG_ACTIVE_DMA,
>>  };
>> +
>> +static int test_multimatch_first_bind(struct udevice *dev)
>> +{
>> +       dm_testdrv_op_count[DM_TEST_OP_BIND]++;
>
> <blank line here>
>
>> +       return -ENODEV;
>> +}
>> +
>> +static const struct udevice_id test_multimatch_ids[] = {
>> +       { .compatible = "sandbox,multimatch-test" },
>> +       { }
>> +};
>> +
>> +U_BOOT_DRIVER(test_multimatch_first) = {
>> +       .name   = "test_multimatch_first",
>> +       .id     = UCLASS_TEST,
>> +       .of_match = test_multimatch_ids,
>> +       .bind   = test_multimatch_first_bind,
>> +};
>> +
>> +U_BOOT_DRIVER(test_multimatch_second) = {
>> +       .name   = "test_multimatch_second",
>> +       .id     = UCLASS_TEST,
>> +       .of_match = test_multimatch_ids,
>> +       .bind   = test_manual_bind,
>> +};
>>
>> --
>> 2.51.0
>>
>
> Regards,
> Simon


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 289 bytes --]

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

end of thread, other threads:[~2026-01-12 13:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 11:16 [PATCH v2 0/6] dm: core: Support same compatible in host/gadget musb drivers Markus Schneider-Pargmann (TI.com)
2026-01-08 11:16 ` [PATCH v2 1/6] dm: core: lists_bind_fdt: Remove unused variable Markus Schneider-Pargmann (TI.com)
2026-01-09 11:32   ` Simon Glass
2026-01-08 11:16 ` [PATCH v2 2/6] dm: core: lists_bind_fdt: Replace found variable Markus Schneider-Pargmann (TI.com)
2026-01-09 11:32   ` Simon Glass
2026-01-12  9:31     ` Markus Schneider-Pargmann
2026-01-08 11:16 ` [PATCH v2 3/6] dm: core: Support multiple drivers with same compatibles Markus Schneider-Pargmann (TI.com)
2026-01-09 11:36   ` Simon Glass
2026-01-12  9:41     ` Markus Schneider-Pargmann
2026-01-08 11:16 ` [PATCH v2 4/6] test: dm: Add compatible multimatch test Markus Schneider-Pargmann (TI.com)
2026-01-09 11:32   ` Simon Glass
2026-01-12  9:48     ` Markus Schneider-Pargmann
2026-01-08 11:16 ` [PATCH v2 5/6] usb: musb-new: Relative ctrl_mod address parsing Markus Schneider-Pargmann (TI.com)
2026-01-08 11:16 ` [PATCH v2 6/6] usb: musb-new: Add compatibles for ti,musb-am33xx Markus Schneider-Pargmann (TI.com)

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