[PATCH] i2c: mediatek: fix probe when vbus supply exists in subnode

Roman Vivchar via B4 Relay devnull+rva333.protonmail.com at kernel.org
Sat Nov 21 08:20:20 PST 2026


From: Roman Vivchar <rva333 at 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 at 55 {
		smb1351_otg_vbus: usb-vbus { };
	};

	typec at 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 at vger.kernel.org
Signed-off-by: Roman Vivchar <rva333 at 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 at protonmail.com>





More information about the Linux-mediatek mailing list