Skip to contentSkip to conversation

usb: typec: wcove: Use LE to CPU conversion when accessing msg->header

PATCH In review Andy Shevchenko 3 participants 4 messages May 19, 2021 – Jun 9, 2021

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

PATCH 1/1 usb: typec: wcove: Use LE to CPU conversion when accessing msg->header

As LKP noticed the Sparse is not happy about strict type handling:
.../typec/tcpm/wcove.c:380:50: sparse: expected unsigned short [usertype] header
.../typec/tcpm/wcove.c:380:50: sparse: got restricted __le16 const [usertype] header

Fix this by switching to use pd_header_cnt_le() instead of pd_header_cnt() in the affected code.

Fixes ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
---
 drivers/usb/typec/tcpm/wcove.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/wcove.c +1 -1
index 79ae63950050..5d125339687a 100644
@@ -378,7 +378,7 @@ static int wcove_pd_transmit(struct tcpc_dev *tcpc,
 		const u8 *data = (void *)msg;
 		int i;
 
-		for (i = 0; i < pd_header_cnt(msg->header) * 4 + 2; i++) {
+		for (i = 0; i < pd_header_cnt_le(msg->header) * 4 + 2; i++) {
 			ret = regmap_write(wcove->regmap, USBC_TX_DATA + i,
 					   data[i]);
 			if (ret)
Signature · 1 line
2.30.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Andy Shevchenko

As LKP noticed the Sparse is not happy about strict type handling:
.../typec/tcpm/wcove.c:380:50: sparse: expected unsigned short [usertype] header
.../typec/tcpm/wcove.c:380:50: sparse: got restricted __le16 const [usertype] header

Fix this by switching to use pd_header_cnt_le() instead of pd_header_cnt() in the affected code.

Fixes ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
Quoted 19 lines
---
 drivers/usb/typec/tcpm/wcove.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/wcove.c +1 -1
index 79ae63950050..5d125339687a 100644
@@ -378,7 +378,7 @@ static int wcove_pd_transmit(struct tcpc_dev *tcpc,
 		const u8 *data = (void *)msg;
 		int i;
 
-		for (i = 0; i < pd_header_cnt(msg->header) * 4 + 2; i++) {
+		for (i = 0; i < pd_header_cnt_le(msg->header) * 4 + 2; i++) {
 			ret = regmap_write(wcove->regmap, USBC_TX_DATA + i,
 					   data[i]);
 			if (ret)
Signature · 1 line
2.30.2
Signature · 1 line
heikki
#2 lore raw
Quoted 5 lines · Heikki Krogerus
Quoted 4 lines · Andy Shevchenko

As LKP noticed the Sparse is not happy about strict type handling:
.../typec/tcpm/wcove.c:380:50: sparse: expected unsigned short [usertype] header
.../typec/tcpm/wcove.c:380:50: sparse: got restricted __le16 const [usertype] header

Quoted 8 lines
Quoted 6 lines

Fix this by switching to use pd_header_cnt_le() instead of pd_header_cnt() in the affected code.

Fixes ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")

Thanks!

Greg, should I amend or resend this?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 13 lines · Andy Shevchenko
Quoted 12 lines · Heikki Krogerus
Quoted 10 lines · Andy Shevchenko

As LKP noticed the Sparse is not happy about strict type handling:
.../typec/tcpm/wcove.c:380:50: sparse: expected unsigned short [usertype] header
.../typec/tcpm/wcove.c:380:50: sparse: got restricted __le16 const [usertype] header

Fix this by switching to use pd_header_cnt_le() instead of pd_header_cnt() in the affected code.

Fixes ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together")
Quoted 5 lines
Quoted 1 line

Thanks!

Greg, should I amend or resend this?

Both please.

thanks,

greg k-h