usb: typec: hd3ss3220: Check if regulator needs to be switched
authorJan Remmet <j.remmet@phytec.de>
Fri, 6 Feb 2026 08:34:31 +0000 (09:34 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Feb 2026 10:23:50 +0000 (11:23 +0100)
Check regulator state as peripheral and detach can disable vbus.
Without this check we will try to disable the regulator twice if
we disconnect host and then connect as device.

Fixes: 27fbc19e52b9 ("usb: typec: hd3ss3220: Enable VBUS based on role state")
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linu.intel.com>
Link: https://patch.msgid.link/20260206-wip-jremmet-hd3ss3220_vbus_split-v4-1-ee5b4e402187@phytec.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/hd3ss3220.c

index a7c54aa..3e39b80 100644 (file)
@@ -208,6 +208,9 @@ static void hd3ss3220_regulator_control(struct hd3ss3220 *hd3ss3220, bool on)
 {
        int ret;
 
+       if (regulator_is_enabled(hd3ss3220->vbus) == on)
+               return;
+
        if (on)
                ret = regulator_enable(hd3ss3220->vbus);
        else