phy: rockchip-inno-usb2: Return zero after otg sync
Subsystems (2)
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.
--- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 + 1 file changed, 1 insertion(+)
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 ; } }
Signature · 7 lines
2.25.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
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")Reported-by Markus Reichl <[email protected]>Reported-by Michael Riesch <[email protected]>Signed-off-by Peter Geis <[email protected]>Tested-by Michael Riesch <[email protected]>Tested-by Markus Reichl <[email protected]>--- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 + 1 file changed, 1 insertion(+)drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0
-0
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
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")Reported-by Markus Reichl <[email protected]>Reported-by Michael Riesch <[email protected]>Signed-off-by Peter Geis <[email protected]>Tested-by Michael Riesch <[email protected]>Tested-by Markus Reichl <[email protected]>--- 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@@ -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
Heiko Stübner
maintainerAm 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")Reported-by Markus Reichl <[email protected]>Reported-by Michael Riesch <[email protected]>Signed-off-by Peter Geis <[email protected]>Tested-by Michael Riesch <[email protected]>Tested-by Markus Reichl <[email protected]>--- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 1 + 1 file changed, 1 insertion(+)drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0
-0
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