[PATCH v3] usb: typec: hd3ss3220: Check if regulator needs to be switched

Jan Remmet posted 1 patch 1 week, 3 days ago
There is a newer version of this series
drivers/usb/typec/hd3ss3220.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH v3] usb: typec: hd3ss3220: Check if regulator needs to be switched
Posted by Jan Remmet 1 week, 3 days ago
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>
---
This is a fixup from
- Link to v1: https://lore.kernel.org/r/20260115-wip-jremmet-hd3ss3220_vbus-v1-1-b7d9adfbe346@phytec.de
To
- Link to v2: https://lore.kernel.org/r/20260123-wip-jremmet-hd3ss3220_vbus-v2-1-bcad313ce92b@phytec.de
---
Changes in v3:
- Fixed the fixme reference, sorry again...
- Link to v2: https://lore.kernel.org/r/20260127-wip-jremmet-hd3ss3220_vbus_split-v2-1-f615d4e88634@phytec.de

Changes in v2:
- added Fixes tag for the patch applied on usb-next
- Link to v1: https://lore.kernel.org/r/20260126-wip-jremmet-hd3ss3220_vbus_split-v1-1-b2f946f1a4ae@phytec.de
---
 drivers/usb/typec/hd3ss3220.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c
index a7c54aa8635f70d6979d98c95f80d4dac277fef2..3e39b800e6b5f4d0cbba957c0dd66c18f781ff38 100644
--- a/drivers/usb/typec/hd3ss3220.c
+++ b/drivers/usb/typec/hd3ss3220.c
@@ -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

---
base-commit: 8acc379b664ec987dcc7eca25a5f5c4a9a4eb9c4
change-id: 20260126-wip-jremmet-hd3ss3220_vbus_split-946802479e89

Best regards,
-- 
Jan Remmet <j.remmet@phytec.de>
Re: [PATCH v3] usb: typec: hd3ss3220: Check if regulator needs to be switched
Posted by Heikki Krogerus 21 hours ago
On Tue, Jan 27, 2026 at 04:37:16PM +0100, Jan Remmet wrote:
> 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>

You probable should remove the empty line after the Fixes tag.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linu.intel.com>

> ---
> This is a fixup from
> - Link to v1: https://lore.kernel.org/r/20260115-wip-jremmet-hd3ss3220_vbus-v1-1-b7d9adfbe346@phytec.de
> To
> - Link to v2: https://lore.kernel.org/r/20260123-wip-jremmet-hd3ss3220_vbus-v2-1-bcad313ce92b@phytec.de
> ---
> Changes in v3:
> - Fixed the fixme reference, sorry again...
> - Link to v2: https://lore.kernel.org/r/20260127-wip-jremmet-hd3ss3220_vbus_split-v2-1-f615d4e88634@phytec.de
> 
> Changes in v2:
> - added Fixes tag for the patch applied on usb-next
> - Link to v1: https://lore.kernel.org/r/20260126-wip-jremmet-hd3ss3220_vbus_split-v1-1-b2f946f1a4ae@phytec.de
> ---
>  drivers/usb/typec/hd3ss3220.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c
> index a7c54aa8635f70d6979d98c95f80d4dac277fef2..3e39b800e6b5f4d0cbba957c0dd66c18f781ff38 100644
> --- a/drivers/usb/typec/hd3ss3220.c
> +++ b/drivers/usb/typec/hd3ss3220.c
> @@ -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
> 
> ---
> base-commit: 8acc379b664ec987dcc7eca25a5f5c4a9a4eb9c4
> change-id: 20260126-wip-jremmet-hd3ss3220_vbus_split-946802479e89
> 
> Best regards,
> -- 
> Jan Remmet <j.remmet@phytec.de>

-- 
heikki