Skip to content

Commit 4ca651d

Browse files
nkapronvinodkoul
authored andcommitted
phy: rockchip-typec: fix tcphy_get_mode error case
The existing logic in tcphy_get_mode() can cause the phy to be incorrectly configured to USB UFP or DisplayPort mode when extcon_get_state returns an error code. extcon_get_state() can return 0, 1, or a negative error code. It is possible to get into the failing state with an extcon driver which does not support the extcon connector id specified as the second argument to extcon_get_state(). tcphy_get_mode() ->extcon_get_state() -->find_cable_index_by_id() --->return -EINVAL; Fixes: e96be45 ("phy: Add USB Type-C PHY driver for rk3399") Signed-off-by: Neill Kapron <[email protected]> Reviewed-by: Lee Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 037d05a commit 4ca651d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/phy/rockchip/phy-rockchip-typec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,10 +821,10 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy)
821821
mode = MODE_DFP_USB;
822822
id = EXTCON_USB_HOST;
823823

824-
if (ufp) {
824+
if (ufp > 0) {
825825
mode = MODE_UFP_USB;
826826
id = EXTCON_USB;
827-
} else if (dp) {
827+
} else if (dp > 0) {
828828
mode = MODE_DFP_DP;
829829
id = EXTCON_DISP_DP;
830830

0 commit comments

Comments
 (0)