* [PATCH] usb: cdns3: Fixes for sparse warnings
@ 2020-12-14 11:04 Pawel Laszczak
2020-12-14 11:26 ` David Laight
0 siblings, 1 reply; 3+ messages in thread
From: Pawel Laszczak @ 2020-12-14 11:04 UTC (permalink / raw)
To: peter.chen
Cc: rogerq, a-govindraju, nsekhar, gregkh, linux-usb, linux-kernel,
kurahul, Pawel Laszczak
Patch fixes the following warnings:
cdns3-gadget.c:1203: sparse: warning: incorrect type
in assignment (different base types)
cdns3-gadget.c:1203: sparse: expected restricted __le32 [usertype] length
cdns3-gadget.c:1203: sparse: got unsigned long
cdns3-gadget.c:1250: sparse: warning: invalid assignment: |=
cdns3-gadget.c:1250: sparse: left side has type restricted __le32
cdns3-gadget.c:1250: sparse: right side has type unsigned long
cdns3-gadget.c:1253: sparse: warning: invalid assignment: |=
cdns3-gadget.c:1253: sparse: left side has type restricted __le32
cdns3-gadget.c:1253: sparse: right side has type unsigned long
cdns3-ep0.c:367: sparse: warning: restricted __le16 degrades to integer
cdns3-ep0.c:792: sparse: warning: symbol 'cdns3_gadget_ep0_ops' was not
declared. Should it be static?
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Reported-by: kernel test robot <lkp@intel.com>
---
drivers/usb/cdns3/cdns3-ep0.c | 4 ++--
drivers/usb/cdns3/cdns3-gadget.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/cdns3/cdns3-ep0.c b/drivers/usb/cdns3/cdns3-ep0.c
index b0390fe9a396..9a17802275d5 100644
--- a/drivers/usb/cdns3/cdns3-ep0.c
+++ b/drivers/usb/cdns3/cdns3-ep0.c
@@ -364,7 +364,7 @@ static int cdns3_ep0_feature_handle_endpoint(struct cdns3_device *priv_dev,
if (le16_to_cpu(ctrl->wValue) != USB_ENDPOINT_HALT)
return -EINVAL;
- if (!(ctrl->wIndex & ~USB_DIR_IN))
+ if (!(le16_to_cpu(ctrl->wIndex) & ~USB_DIR_IN))
return 0;
index = cdns3_ep_addr_to_index(le16_to_cpu(ctrl->wIndex));
@@ -789,7 +789,7 @@ int cdns3_gadget_ep_set_wedge(struct usb_ep *ep)
return 0;
}
-const struct usb_ep_ops cdns3_gadget_ep0_ops = {
+static const struct usb_ep_ops cdns3_gadget_ep0_ops = {
.enable = cdns3_gadget_ep0_enable,
.disable = cdns3_gadget_ep0_disable,
.alloc_request = cdns3_gadget_ep_alloc_request,
diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 9b8b0cd3d2c2..582bfeceedb4 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -1200,7 +1200,7 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep,
td_size = DIV_ROUND_UP(request->length,
priv_ep->endpoint.maxpacket);
if (priv_dev->gadget.speed == USB_SPEED_SUPER)
- trb->length = TRB_TDL_SS_SIZE(td_size);
+ trb->length = cpu_to_le32(TRB_TDL_SS_SIZE(td_size));
else
control |= TRB_TDL_HS_SIZE(td_size);
}
@@ -1247,10 +1247,10 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep,
priv_req->trb->control = cpu_to_le32(control);
if (sg_supported) {
- trb->control |= TRB_ISP;
+ trb->control |= cpu_to_le32(TRB_ISP);
/* Don't set chain bit for last TRB */
if (sg_iter < num_trb - 1)
- trb->control |= TRB_CHAIN;
+ trb->control |= cpu_to_le32(TRB_CHAIN);
s = sg_next(s);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] usb: cdns3: Fixes for sparse warnings
2020-12-14 11:04 [PATCH] usb: cdns3: Fixes for sparse warnings Pawel Laszczak
@ 2020-12-14 11:26 ` David Laight
2020-12-14 12:08 ` gregkh
0 siblings, 1 reply; 3+ messages in thread
From: David Laight @ 2020-12-14 11:26 UTC (permalink / raw)
To: 'Pawel Laszczak', peter.chen
Cc: rogerq, a-govindraju, nsekhar, gregkh, linux-usb, linux-kernel, kurahul
From: Pawel Laszczak
> Sent: 14 December 2020 11:05
>
> Patch fixes the following warnings:
...
> cdns3-ep0.c:367: sparse: warning: restricted __le16 degrades to integer
...
> diff --git a/drivers/usb/cdns3/cdns3-ep0.c b/drivers/usb/cdns3/cdns3-ep0.c
> index b0390fe9a396..9a17802275d5 100644
> --- a/drivers/usb/cdns3/cdns3-ep0.c
> +++ b/drivers/usb/cdns3/cdns3-ep0.c
> @@ -364,7 +364,7 @@ static int cdns3_ep0_feature_handle_endpoint(struct cdns3_device *priv_dev,
> if (le16_to_cpu(ctrl->wValue) != USB_ENDPOINT_HALT)
> return -EINVAL;
>
> - if (!(ctrl->wIndex & ~USB_DIR_IN))
> + if (!(le16_to_cpu(ctrl->wIndex) & ~USB_DIR_IN))
> return 0;
It's generally best to byteswap the constant.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: cdns3: Fixes for sparse warnings
2020-12-14 11:26 ` David Laight
@ 2020-12-14 12:08 ` gregkh
0 siblings, 0 replies; 3+ messages in thread
From: gregkh @ 2020-12-14 12:08 UTC (permalink / raw)
To: David Laight
Cc: 'Pawel Laszczak',
peter.chen, rogerq, a-govindraju, nsekhar, linux-usb,
linux-kernel, kurahul
On Mon, Dec 14, 2020 at 11:26:22AM +0000, David Laight wrote:
> From: Pawel Laszczak
> > Sent: 14 December 2020 11:05
> >
> > Patch fixes the following warnings:
> ...
> > cdns3-ep0.c:367: sparse: warning: restricted __le16 degrades to integer
> ...
> > diff --git a/drivers/usb/cdns3/cdns3-ep0.c b/drivers/usb/cdns3/cdns3-ep0.c
> > index b0390fe9a396..9a17802275d5 100644
> > --- a/drivers/usb/cdns3/cdns3-ep0.c
> > +++ b/drivers/usb/cdns3/cdns3-ep0.c
> > @@ -364,7 +364,7 @@ static int cdns3_ep0_feature_handle_endpoint(struct cdns3_device *priv_dev,
> > if (le16_to_cpu(ctrl->wValue) != USB_ENDPOINT_HALT)
> > return -EINVAL;
> >
> > - if (!(ctrl->wIndex & ~USB_DIR_IN))
> > + if (!(le16_to_cpu(ctrl->wIndex) & ~USB_DIR_IN))
> > return 0;
>
> It's generally best to byteswap the constant.
Why? This is fine, it's better to operate on the value that needs to be
operated on.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-14 12:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 11:04 [PATCH] usb: cdns3: Fixes for sparse warnings Pawel Laszczak
2020-12-14 11:26 ` David Laight
2020-12-14 12:08 ` gregkh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).