From: Johan Hovold Date: Fri, 8 Dec 2023 12:36:02 +0000 (+0100) Subject: usb: typec: ucsi: fix gpio-based orientation detection X-Git-Tag: v6.6.14~954 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=847f8f529a13bd880aa271a76aa1c19408d03fa5;p=platform%2Fkernel%2Flinux-starfive.git usb: typec: ucsi: fix gpio-based orientation detection commit c994cb596bf7ef5928f06331c76f46e071b16f09 upstream. Fix the recently added connector sanity check which was off by one and prevented orientation notifications from being handled correctly for the second port when using GPIOs to determine orientation. Fixes: c6165ed2f425 ("usb: ucsi: glink: use the connector orientation GPIO to provide switch events") Cc: stable Cc: Neil Armstrong Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus Link: https://lore.kernel.org/r/20231208123603.29957-1-johan+linaro@kernel.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c index db6e248..4853141 100644 --- a/drivers/usb/typec/ucsi/ucsi_glink.c +++ b/drivers/usb/typec/ucsi/ucsi_glink.c @@ -228,7 +228,7 @@ static void pmic_glink_ucsi_notify(struct work_struct *work) con_num = UCSI_CCI_CONNECTOR(cci); if (con_num) { - if (con_num < PMIC_GLINK_MAX_PORTS && + if (con_num <= PMIC_GLINK_MAX_PORTS && ucsi->port_orientation[con_num - 1]) { int orientation = gpiod_get_value(ucsi->port_orientation[con_num - 1]);