diff mbox series

[v1,1/6] usb: gadget: pch_udc: Drop unneeded cpu_to_le32() call

Message ID 20210322211149.6658-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/6] usb: gadget: pch_udc: Drop unneeded cpu_to_le32() call | expand

Commit Message

Andy Shevchenko March 22, 2021, 9:11 p.m. UTC
Either way ~0 will be in the correct byte order,
hence drop unneeded cpu_to_le32() call. Moreover,
it makes sparse happy, otherwise it complains:

pch_udc.c:1813:27: warning: incorrect type in assignment (different base types)
pch_udc.c:1813:27:    expected unsigned int [usertype] dataptr
pch_udc.c:1813:27:    got restricted __le32 [usertype]

Fixes: f646cf94520e ("USB device driver of Topcliff PCH")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/usb/gadget/udc/pch_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Greg Kroah-Hartman March 23, 2021, 11:58 a.m. UTC | #1
On Mon, Mar 22, 2021 at 11:11:44PM +0200, Andy Shevchenko wrote:
> Either way ~0 will be in the correct byte order,
> hence drop unneeded cpu_to_le32() call. Moreover,
> it makes sparse happy, otherwise it complains:
> 
> pch_udc.c:1813:27: warning: incorrect type in assignment (different base types)
> pch_udc.c:1813:27:    expected unsigned int [usertype] dataptr
> pch_udc.c:1813:27:    got restricted __le32 [usertype]
> 
> Fixes: f646cf94520e ("USB device driver of Topcliff PCH")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/usb/gadget/udc/pch_udc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
> index a3c1fc924268..2e2dca391007 100644
> --- a/drivers/usb/gadget/udc/pch_udc.c
> +++ b/drivers/usb/gadget/udc/pch_udc.c
> @@ -1756,7 +1756,7 @@ static struct usb_request *pch_udc_alloc_request(struct usb_ep *usbep,
>  	}
>  	/* prevent from using desc. - set HOST BUSY */
>  	dma_desc->status |= PCH_UDC_BS_HST_BSY;
> -	dma_desc->dataptr = cpu_to_le32(DMA_ADDR_INVALID);
> +	dma_desc->dataptr = DMA_ADDR_INVALID;
>  	req->td_data = dma_desc;
>  	req->td_data_last = dma_desc;
>  	req->chain_len = 1;

With this series applied, I get the following build warning:

drivers/usb/gadget/udc/pch_udc.c: In function ‘pch_udc_alloc_request’:
drivers/usb/gadget/udc/pch_udc.c:208:26: warning: conversion from ‘long long unsigned int’ to ‘u32’ {aka ‘unsigned int’} changes value from ‘18446744073709551615’ to ‘4294967295’ [-Woverflow]
  208 | #define DMA_ADDR_INVALID (~(dma_addr_t)0)
      |                          ^
drivers/usb/gadget/udc/pch_udc.c:1813:22: note: in expansion of macro ‘DMA_ADDR_INVALID’
 1813 |  dma_desc->dataptr = DMA_ADDR_INVALID;
      |                      ^~~~~~~~~~~~~~~~


Please fix up and resend a new version of this series.

thanks,

greg k-h
Andy Shevchenko March 23, 2021, 12:24 p.m. UTC | #2
On Tue, Mar 23, 2021 at 12:58:44PM +0100, Greg Kroah-Hartman wrote:
> On Mon, Mar 22, 2021 at 11:11:44PM +0200, Andy Shevchenko wrote:
> > Either way ~0 will be in the correct byte order,
> > hence drop unneeded cpu_to_le32() call. Moreover,
> > it makes sparse happy, otherwise it complains:
> > 
> > pch_udc.c:1813:27: warning: incorrect type in assignment (different base types)
> > pch_udc.c:1813:27:    expected unsigned int [usertype] dataptr
> > pch_udc.c:1813:27:    got restricted __le32 [usertype]
> > 
> > Fixes: f646cf94520e ("USB device driver of Topcliff PCH")
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  drivers/usb/gadget/udc/pch_udc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
> > index a3c1fc924268..2e2dca391007 100644
> > --- a/drivers/usb/gadget/udc/pch_udc.c
> > +++ b/drivers/usb/gadget/udc/pch_udc.c
> > @@ -1756,7 +1756,7 @@ static struct usb_request *pch_udc_alloc_request(struct usb_ep *usbep,
> >  	}
> >  	/* prevent from using desc. - set HOST BUSY */
> >  	dma_desc->status |= PCH_UDC_BS_HST_BSY;
> > -	dma_desc->dataptr = cpu_to_le32(DMA_ADDR_INVALID);
> > +	dma_desc->dataptr = DMA_ADDR_INVALID;
> >  	req->td_data = dma_desc;
> >  	req->td_data_last = dma_desc;
> >  	req->chain_len = 1;
> 
> With this series applied, I get the following build warning:
> 
> drivers/usb/gadget/udc/pch_udc.c: In function ‘pch_udc_alloc_request’:
> drivers/usb/gadget/udc/pch_udc.c:208:26: warning: conversion from ‘long long unsigned int’ to ‘u32’ {aka ‘unsigned int’} changes value from ‘18446744073709551615’ to ‘4294967295’ [-Woverflow]
>   208 | #define DMA_ADDR_INVALID (~(dma_addr_t)0)
>       |                          ^
> drivers/usb/gadget/udc/pch_udc.c:1813:22: note: in expansion of macro ‘DMA_ADDR_INVALID’
>  1813 |  dma_desc->dataptr = DMA_ADDR_INVALID;
>       |                      ^~~~~~~~~~~~~~~~
> 
> 
> Please fix up and resend a new version of this series.

Oops, thanks! Now I understand how I missed this (I have another patch to test
that effectively removed that line AFAIR. In any case, I will retest and
resend.
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index a3c1fc924268..2e2dca391007 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -1756,7 +1756,7 @@  static struct usb_request *pch_udc_alloc_request(struct usb_ep *usbep,
 	}
 	/* prevent from using desc. - set HOST BUSY */
 	dma_desc->status |= PCH_UDC_BS_HST_BSY;
-	dma_desc->dataptr = cpu_to_le32(DMA_ADDR_INVALID);
+	dma_desc->dataptr = DMA_ADDR_INVALID;
 	req->td_data = dma_desc;
 	req->td_data_last = dma_desc;
 	req->chain_len = 1;