Skip to content

Commit c58bbe3

Browse files
andy-shevgregkh
authored andcommitted
usb: typec: tcpm: Use LE to CPU conversion when accessing msg->header
Sparse is not happy about strict type handling: .../typec/tcpm/tcpm.c:2720:27: warning: restricted __le16 degrades to integer .../typec/tcpm/tcpm.c:2814:32: warning: restricted __le16 degrades to integer Fix this by converting LE to CPU before use. Fixes: ae8a2ca ("usb: typec: Group all TCPCI/TCPM code together") Fixes: 64f7c49 ("typec: tcpm: Add support for sink PPS related messages") Cc: stable <[email protected]> Cc: Adam Thomson <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Reviewed-by: Adam Thomson <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8c9b3ca commit c58bbe3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/usb/typec/tcpm/tcpm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,7 +2717,7 @@ static void tcpm_pd_ext_msg_request(struct tcpm_port *port,
27172717
enum pd_ext_msg_type type = pd_header_type_le(msg->header);
27182718
unsigned int data_size = pd_ext_header_data_size_le(msg->ext_msg.header);
27192719

2720-
if (!(msg->ext_msg.header & PD_EXT_HDR_CHUNKED)) {
2720+
if (!(le16_to_cpu(msg->ext_msg.header) & PD_EXT_HDR_CHUNKED)) {
27212721
tcpm_pd_handle_msg(port, PD_MSG_CTRL_NOT_SUPP, NONE_AMS);
27222722
tcpm_log(port, "Unchunked extended messages unsupported");
27232723
return;
@@ -2811,7 +2811,7 @@ static void tcpm_pd_rx_handler(struct kthread_work *work)
28112811
"Data role mismatch, initiating error recovery");
28122812
tcpm_set_state(port, ERROR_RECOVERY, 0);
28132813
} else {
2814-
if (msg->header & PD_HEADER_EXT_HDR)
2814+
if (le16_to_cpu(msg->header) & PD_HEADER_EXT_HDR)
28152815
tcpm_pd_ext_msg_request(port, msg);
28162816
else if (cnt)
28172817
tcpm_pd_data_request(port, msg);

0 commit comments

Comments
 (0)