diff mbox series

[v1,1/1] usb: typec: wcove: Use LE to CPU conversion when accessing msg->header

Message ID 20210519085534.48732-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Superseded
Headers show
Series [v1,1/1] usb: typec: wcove: Use LE to CPU conversion when accessing msg->header | expand

Commit Message

Andy Shevchenko May 19, 2021, 8:55 a.m. UTC
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")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/usb/typec/tcpm/wcove.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Heikki Krogerus May 20, 2021, 9:26 a.m. UTC | #1
On Wed, May 19, 2021 at 11:55:34AM +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")
> 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>

> ---
>  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 79ae63950050..5d125339687a 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
Andy Shevchenko June 7, 2021, 3:28 p.m. UTC | #2
On Thu, May 20, 2021 at 12:26:25PM +0300, Heikki Krogerus wrote:
> On Wed, May 19, 2021 at 11:55:34AM +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")
> > 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>

Thanks!

Greg, should I amend or resend this?
Greg Kroah-Hartman June 9, 2021, 8:56 a.m. UTC | #3
On Mon, Jun 07, 2021 at 06:28:55PM +0300, Andy Shevchenko wrote:
> On Thu, May 20, 2021 at 12:26:25PM +0300, Heikki Krogerus wrote:
> > On Wed, May 19, 2021 at 11:55:34AM +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")
> > > 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>
> 
> Thanks!
> 
> Greg, should I amend or resend this?

Both please.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/typec/tcpm/wcove.c b/drivers/usb/typec/tcpm/wcove.c
index 79ae63950050..5d125339687a 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)