Thread (52 messages) 52 messages, 4 authors, 2021-05-20
STALE1838d

[PATCH 5.10 22/47] platform/chrome: cros_ec_typec: Add DP mode check

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: 2021-05-20 09:31:58
Also in: lkml
Subsystem: chrome hardware platform support, chromeos ec usb type-c driver, the rest · Maintainers: Benson Leung, Tzung-Bi Shih, Abhishek Pandit-Subedi, Jameson Thies, Andrei Kuchynski, Linus Torvalds

From: Prashant Malani <redacted>

[ Upstream commit c5bb32f57bf3a30ed03be51f7be0840325ba8b4a ]

There are certain transitional situations where the dp_mode field in the
PD_CONTROL response might not be populated with the right DP pin
assignment value yet. Add a check for that to avoid sending an invalid
value to the Type C mode switch.

Signed-off-by: Prashant Malani <redacted>
Signed-off-by: Enric Balletbo i Serra <redacted>
Link: https://lore.kernel.org/r/20210421042108.2002-1-pmalani@chromium.org (local)
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/platform/chrome/cros_ec_typec.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 31be31161350..036d54dc52e2 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -475,6 +475,11 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec,
 		return -ENOTSUPP;
 	}
 
+	if (!pd_ctrl->dp_mode) {
+		dev_err(typec->dev, "No valid DP mode provided.\n");
+		return -EINVAL;
+	}
+
 	/* Status VDO. */
 	dp_data.status = DP_STATUS_ENABLED;
 	if (port->mux_flags & USB_PD_MUX_HPD_IRQ)
-- 
2.30.2


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help