Skip to contentSkip to conversation

phy: rockchip-inno-usb2: Return zero after otg sync

PATCH Superseded Peter Geis 3 participants 4 messages Aug 22, 2022 – Aug 23, 2022

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Peter Geis

author
#0 lore raw

PATCH 1/1 phy: rockchip-inno-usb2: Return zero after otg sync

The otg sync state patch reuses the ret variable, but fails to set it to zero after use. This leads to a situation when the otg port is in peripheral mode where the otg phy aborts halfway through setup. Fix this by setting ret to zero after use.

Fixes 8dc60f8da22f ("phy: rockchip-inno-usb2: Sync initial otg state")
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1 -0
index 0b1e9337ee8e..5fc7c374a6b4 100644
@@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
 			/* do initial sync of usb state */
 			ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
 			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+			ret = 0;
 		}
 	}
 
Signature · 7 lines
2.25.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#1 lore raw
Quoted 21 lines · Peter Geis

The otg sync state patch reuses the ret variable, but fails to set it to zero after use. This leads to a situation when the otg port is in peripheral mode where the otg phy aborts halfway through setup. Fix this by setting ret to zero after use.

Fixes 8dc60f8da22f ("phy: rockchip-inno-usb2: Sync initial otg state")
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
index 0b1e9337ee8e..5fc7c374a6b4 100644

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1172

Quoted 4 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1 -0
@@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
 			/* do initial sync of usb state */
 			ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
 			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+			ret = 0;

The bug was caused by the unexpected consequence of (mis|re)using the "ret" variable for a temporary value. Please introduce a new variable here, else the use of "ret" is even more confusing. This code also wipes out any error returned by devm_extcon_register_notifier().

Regards,
Samuel

author
#2 lore raw
Quoted 18 lines · Samuel Holland
Quoted 16 lines · Peter Geis

The otg sync state patch reuses the ret variable, but fails to set it to zero after use. This leads to a situation when the otg port is in peripheral mode where the otg phy aborts halfway through setup. Fix this by setting ret to zero after use.

Fixes 8dc60f8da22f ("phy: rockchip-inno-usb2: Sync initial otg state")
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1172

Quoted 9 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1 -0
index 0b1e9337ee8e..5fc7c374a6b4 100644
@@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
                      /* do initial sync of usb state */
                      ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
                      extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+                     ret = 0;

The bug was caused by the unexpected consequence of (mis|re)using the "ret" variable for a temporary value. Please introduce a new variable here, else the use of "ret" is even more confusing. This code also wipes out any error returned by devm_extcon_register_notifier().

I see your point here, I also need to skip this if devm_extcon_register_notifier() fails as well. I'll spin up a v2.

Thanks for catching that!

Quoted 3 lines

Regards,
Samuel

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
maintainer
#3 lore raw
In reply to Peter Geis

Am Montag, 22. August 2022, 12:32:18 CEST schrieb Peter Geis:

Quoted 21 lines

The otg sync state patch reuses the ret variable, but fails to set it to zero after use. This leads to a situation when the otg port is in peripheral mode where the otg phy aborts halfway through setup. Fix this by setting ret to zero after use.

Fixes 8dc60f8da22f ("phy: rockchip-inno-usb2: Sync initial otg state")
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
index 0b1e9337ee8e..5fc7c374a6b4 100644

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1174

Quoted 6 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1 -0
@@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
 			/* do initial sync of usb state */
 			ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
 			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+			ret = 0;
 		}
 	}

I also ran into that issue just now :-) .
So am looking forward to v2.

Thanks
Heiko

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy