diff mbox series

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

Message ID 20241111100220.1743872-1-heikki.krogerus@linux.intel.com (mailing list archive)
State Accepted
Commit 65c4c9447bfc5b80b88e4d354d09c8fb86fad07f
Headers show
Series usb: typec: ucsi: Fix a missing bits to bytes conversion in ucsi_init() | expand

Commit Message

Heikki Krogerus Nov. 11, 2024, 10:02 a.m. UTC
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")
Reported-by: Abel Vesa <abel.vesa@linaro.org>
Closes: https://lore.kernel.org/linux-usb/Zy864W7sysWZbCTd@linaro.org/
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/typec/ucsi/ucsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Abel Vesa Nov. 11, 2024, 10:34 a.m. UTC | #1
On 24-11-11 12:02:20, Heikki Krogerus wrote:
> 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")
> Reported-by: Abel Vesa <abel.vesa@linaro.org>
> Closes: https://lore.kernel.org/linux-usb/Zy864W7sysWZbCTd@linaro.org/
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Tested-by: Abel Vesa <abel.vesa@linaro.org>

> ---
>  drivers/usb/typec/ucsi/ucsi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 974a441155e1..c435c0835744 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -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;
>  
> -- 
> 2.45.2
>
diff mbox series

Patch

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 974a441155e1..c435c0835744 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -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;