phy: rockchip-inno-usb2: Return zero after otg sync
Subsystems (2)
PATCH v2 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. It also fails to account for a failure to register the extcon notifier. Fix this by using our own variable and skipping otg sync in case of failure.
--- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +4 -3
@@ -1124,7 +1124,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,struct rockchip_usb2phy_port *rport, struct device_node *child_np) { - int ret; + int ret, id; rport->port_id =USB2PHY_PORT_OTG ; rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG ];
@@ -1164,11 +1164,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, EXTCON_USB_HOST, &rport->event_nb);if (ret)dev_err (rphy->dev,"register USB HOST notifier failed\n" ); + goto out;if (!of_property_read_bool (rphy->dev->of_node,"extcon" )) {/* 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); + id =property_enabled (rphy->grf, &rport->port_cfg->utmi_id); +extcon_set_state_sync (rphy->edev,EXTCON_USB_HOST , !id); } }
Signature · 7 lines
2.25.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Am Dienstag, 23. August 2022, 16:47:28 CEST schrieb Peter Geis:
Quoted 6 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. It also fails to account for a failure to register the extcon notifier. Fix this by using our own variable and skipping otg sync in case of failure.
Quoted 7 lines
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]>
Quoted 33 lines
--- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/phy/rockchip/phy-rockchip-inno-usb2.c +4
-3@@ -1124,7 +1124,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,struct rockchip_usb2phy_port *rport, struct device_node *child_np) { - int ret; + int ret, id; rport->port_id =USB2PHY_PORT_OTG ; rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG ];@@ -1164,11 +1164,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, EXTCON_USB_HOST, &rport->event_nb);if (ret)dev_err (rphy->dev,"register USB HOST notifier failed\n" ); + goto out;if (!of_property_read_bool (rphy->dev->of_node,"extcon" )) {/* 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); + id =property_enabled (rphy->grf, &rport->port_cfg->utmi_id); +extcon_set_state_sync (rphy->edev,EXTCON_USB_HOST , !id); } }
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Hi Peter,
Quoted 31 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. It also fails to account for a failure to register the extcon notifier. Fix this by using our own variable and skipping otg sync in case of failure.
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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1
-1@@ -1124,7 +1124,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,struct rockchip_usb2phy_port *rport, struct device_node *child_np) { - int ret; + int ret, id; rport->port_id =USB2PHY_PORT_OTG ; rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG ];
drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1165
Quoted 2 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0
-0@@ -1164,11 +1164,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, EXTCON_USB_HOST, &rport->event_nb);if (ret)
This needs braces, right?
if (ret) {drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1167
Quoted 2 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1
-0dev_err (rphy->dev,"register USB HOST notifier failed\n" ); + goto out;
}
With the braces the patch works as expected.
Thanks and best regards,
Michael
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +2
-2if (!of_property_read_bool (rphy->dev->of_node,"extcon" )) {/* 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); + id =property_enabled (rphy->grf, &rport->port_cfg->utmi_id); +extcon_set_state_sync (rphy->edev,EXTCON_USB_HOST , !id); } }
Quoted 40 lines · Michael Riesch
Hi Peter,
Quoted 31 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. It also fails to account for a failure to register the extcon notifier. Fix this by using our own variable and skipping otg sync in case of failure.
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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1
-1@@ -1124,7 +1124,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,struct rockchip_usb2phy_port *rport, struct device_node *child_np) { - int ret; + int ret, id; rport->port_id =USB2PHY_PORT_OTG ; rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG ];drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1165
Quoted 2 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0
-0@@ -1164,11 +1164,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, EXTCON_USB_HOST, &rport->event_nb);if (ret)This needs braces, right?
Quoted 7 lines
if (ret) {drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1167
Quoted 2 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1
-0dev_err (rphy->dev,"register USB HOST notifier failed\n" ); + goto out;}With the braces the patch works as expected.
Yup, thanks for that. I hate working without access to my hardware.
Quoted 14 lines
Thanks and best regards,
MichaelQuoted 10 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +2
-2if (!of_property_read_bool (rphy->dev->of_node,"extcon" )) {/* 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); + id =property_enabled (rphy->grf, &rport->port_cfg->utmi_id); +extcon_set_state_sync (rphy->edev,EXTCON_USB_HOST , !id); } }