Skip to contentSkip to conversation

usb: typec: ucsi: Fix a missing bits to bytes conversion in ucsi_init()

PATCH In review Heikki Krogerus 2 participants 2 messages Nov 11, 2024

Subsystems (2)
lore
Share & tools
lore

Heikki Krogerus

author maintainer
#0 lore raw

PATCH 1/1 usb: typec: ucsi: Fix a missing bits to bytes conversion in ucsi_init()

The GET_CAPABILITY size is wrong. The definitions for the command sizes are for bitfieds and therefore in bits, not bytes.

This fixes an issue that prevents the interface from being registered with UCSI versions older than 2.0 because the command size exceeds the MESSAGE_IN field size.

Fixes 226ff2e681d0 ("usb: typec: ucsi: Convert connector specific commands to bitmaps")
---
 drivers/usb/typec/ucsi/ucsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +2 -1
index 974a441155e1..c435c0835744 100644
@@ -1775,7 +1775,8 @@ static int ucsi_init(struct ucsi *ucsi)
 
 	/* Get PPM capabilities */
 	command = UCSI_GET_CAPABILITY;
-	ret = ucsi_send_command(ucsi, command, &ucsi->cap, UCSI_GET_CAPABILITY_SIZE);
+	ret = ucsi_send_command(ucsi, command, &ucsi->cap,
+				BITS_TO_BYTES(UCSI_GET_CAPABILITY_SIZE));
 	if (ret < 0)
 		goto err_reset;
 
Signature · 1 line
2.45.2
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 4 lines · Heikki Krogerus

The GET_CAPABILITY size is wrong. The definitions for the command sizes are for bitfieds and therefore in bits, not bytes.

Quoted 8 lines

This fixes an issue that prevents the interface from being registered with UCSI versions older than 2.0 because the command size exceeds the MESSAGE_IN field size.

Fixes 226ff2e681d0 ("usb: typec: ucsi: Convert connector specific commands to bitmaps")
Quoted 21 lines
---
 drivers/usb/typec/ucsi/ucsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +2 -1
index 974a441155e1..c435c0835744 100644
@@ -1775,7 +1775,8 @@ static int ucsi_init(struct ucsi *ucsi)
 
 	/* Get PPM capabilities */
 	command = UCSI_GET_CAPABILITY;
-	ret = ucsi_send_command(ucsi, command, &ucsi->cap, UCSI_GET_CAPABILITY_SIZE);
+	ret = ucsi_send_command(ucsi, command, &ucsi->cap,
+				BITS_TO_BYTES(UCSI_GET_CAPABILITY_SIZE));
 	if (ret < 0)
 		goto err_reset;
 
Signature · 1 line
2.45.2