All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] usb: typec: wcove: Use LE to CPU conversion when accessing msg->header
@ 2021-06-09 17:22 Andy Shevchenko
  2021-06-09 17:46 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2021-06-09 17:22 UTC (permalink / raw)
  To: Andy Shevchenko, linux-usb, linux-kernel
  Cc: Guenter Roeck, Heikki Krogerus, Greg Kroah-Hartman, kernel test robot

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")
Fixes: 3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: added Rb tag (Heikki), amend Fixes tags (Greg)
 drivers/usb/typec/tcpm/wcove.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/wcove.c b/drivers/usb/typec/tcpm/wcove.c
index 8072e222eb99..20917d85d6f4 100644
--- a/drivers/usb/typec/tcpm/wcove.c
+++ b/drivers/usb/typec/tcpm/wcove.c
@@ -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)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 1/1] usb: typec: wcove: Use LE to CPU conversion when accessing msg->header
  2021-06-09 17:22 [PATCH v2 1/1] usb: typec: wcove: Use LE to CPU conversion when accessing msg->header Andy Shevchenko
@ 2021-06-09 17:46 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-06-09 17:46 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-usb, linux-kernel, Heikki Krogerus, Greg Kroah-Hartman,
	kernel test robot

On Wed, Jun 09, 2021 at 08:22:02PM +0300, Andy Shevchenko wrote:
> 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")
> Fixes: 3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
> v2: added Rb tag (Heikki), amend Fixes tags (Greg)
>  drivers/usb/typec/tcpm/wcove.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/wcove.c b/drivers/usb/typec/tcpm/wcove.c
> index 8072e222eb99..20917d85d6f4 100644
> --- a/drivers/usb/typec/tcpm/wcove.c
> +++ b/drivers/usb/typec/tcpm/wcove.c
> @@ -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)
> -- 
> 2.30.2
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-09 17:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 17:22 [PATCH v2 1/1] usb: typec: wcove: Use LE to CPU conversion when accessing msg->header Andy Shevchenko
2021-06-09 17:46 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.