Skip to contentSkip to conversation

usb: typec: ucsi: fix gpio-based orientation detection

PATCH In review Johan Hovold 3 participants 3 messages Dec 8, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: typec: ucsi: fix gpio-based orientation detection

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 Neil Armstrong <[email protected]>

---

I found this one through inspection when skimming the driver.

Johan

 drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi_glink.c +1 -1
index db6e248f8208..4853141cd10c 100644
@@ -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]);
 
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Johan Hovold

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 Neil Armstrong <[email protected]>
Quoted 26 lines

---

I found this one through inspection when skimming the driver.

Johan

 drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi_glink.c +1 -2
index db6e248f8208..4853141cd10c 100644
@@ -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]);
 
--

2.41.0

Signature · 2 lines
With best wishes
Dmitry
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Johan Hovold
Quoted 7 lines · Johan Hovold

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 Neil Armstrong <[email protected]>
Quoted 25 lines

---

I found this one through inspection when skimming the driver.

Johan

 drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi_glink.c +1 -1
index db6e248f8208..4853141cd10c 100644
@@ -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]);
 
Signature · 1 line
2.41.0
Signature · 1 line
heikki