mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] i2c: mediatek: fix probe when vbus supply exists in subnode
@ 2026-11-21 16:20 Roman Vivchar via B4 Relay
  0 siblings, 0 replies; only message in thread
From: Roman Vivchar via B4 Relay @ 2026-11-21 16:20 UTC (permalink / raw)
  To: Qii Wang, Andi Shyti, Matthias Brugger,
	AngeloGioacchino Del Regno, Liam Girdwood, Mark Brown,
	Hsin-Yi Wang, Wolfram Sang
  Cc: linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	stable, Roman Vivchar

From: Roman Vivchar <rva333@protonmail.com>

Commit 9029b9b2ae13 ("i2c: mediatek: mt65xx: add optional vbus-supply")
added an optional vbus-supply lookup in mtk_i2c_probe(). However, when
the i2c controller node itself doesn't define vbus-supply,
devm_regulator_get_optional() falls back to of_get_child_regulator(),
which recursively searches all children nodes for a matching vbus-supply
property.

If a device on the i2c bus (such as a USB-C connector) defines
vbus-supply, the i2c controller mistakenly binds to that regulator.
When that regulator is provided by another device on the same i2c bus,
probe fails permanently with a circular -EPROBE_DEFER dependency:

For example:
&i2c7 {
	charger@55 {
		smb1351_otg_vbus: usb-vbus { };
	};

	typec@60 {
		connector {
			vbus-supply = <&smb1351_otg_vbus>;
		};
	};
};

Ensure that i2c bus has its own regulator using of_property_present()
before calling devm_regulator_get_optional(). This resolves the issue
and makes both devices probe correctly.

Fixes: 9029b9b2ae13 ("i2c: mediatek: mt65xx: add optional vbus-supply")
Cc: stable@vger.kernel.org
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
 drivers/i2c/busses/i2c-mt65xx.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index 45d0d7156d6e..042244c7d89d 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -1415,12 +1415,14 @@ static int mtk_i2c_probe(struct platform_device *pdev)
 	i2c->adap.quirks = i2c->dev_comp->quirks;
 	i2c->adap.timeout = 2 * HZ;
 	i2c->adap.retries = 1;
-	i2c->adap.bus_regulator = devm_regulator_get_optional(&pdev->dev, "vbus");
-	if (IS_ERR(i2c->adap.bus_regulator)) {
-		if (PTR_ERR(i2c->adap.bus_regulator) == -ENODEV)
-			i2c->adap.bus_regulator = NULL;
-		else
-			return PTR_ERR(i2c->adap.bus_regulator);
+	if (of_property_present(pdev->dev.of_node, "vbus-supply")) {
+		i2c->adap.bus_regulator = devm_regulator_get_optional(&pdev->dev, "vbus");
+		if (IS_ERR(i2c->adap.bus_regulator)) {
+			if (PTR_ERR(i2c->adap.bus_regulator) == -ENODEV)
+				i2c->adap.bus_regulator = NULL;
+			else
+				return PTR_ERR(i2c->adap.bus_regulator);
+		}
 	}
 
 	ret = mtk_i2c_parse_dt(pdev->dev.of_node, i2c);

---
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
change-id: 20261121-6768-i2c-ba9ed08f68a6

Best regards,
--  
Roman Vivchar <rva333@protonmail.com>



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-21 16:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-21 16:20 [PATCH] i2c: mediatek: fix probe when vbus supply exists in subnode Roman Vivchar via B4 Relay

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

all inboxes | Powered by JetHome®