* [PATCH 1/3] usb: gadget: udc-xilinx: fix restricted __le16 degrades to integer warning
2023-08-22 6:31 [PATCH 0/3] usb: gadget: udc-xilinx: fix warnings Piyush Mehta
@ 2023-08-22 6:31 ` Piyush Mehta
2023-08-22 6:32 ` [PATCH 2/3] usb: gadget: udc-xilinx: fix cast from restricted __le16 warning Piyush Mehta
2023-08-22 6:32 ` [PATCH 3/3] usb: gadget: udc-xilinx: fix incorrect type in assignment warning Piyush Mehta
2 siblings, 0 replies; 4+ messages in thread
From: Piyush Mehta @ 2023-08-22 6:31 UTC (permalink / raw)
To: gregkh, michal.simek, u.kleine-koenig, linus.walleij
Cc: linux-usb, linux-arm-kernel, linux-kernel, git, Piyush Mehta
usb_ctrlrequest members wValue and wIndex are of type __le16, so to fix
this warnings we are using le16_to_cpu() macros.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/all/202209020044.CX2PfZzM-lkp@intel.com/
Signed-off-by: Piyush Mehta <piyush.mehta@amd.com>
---
drivers/usb/gadget/udc/udc-xilinx.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
index a4a7b90a97e7..e6308414cd1f 100644
--- a/drivers/usb/gadget/udc/udc-xilinx.c
+++ b/drivers/usb/gadget/udc/udc-xilinx.c
@@ -1617,13 +1617,13 @@ static void xudc_getstatus(struct xusb_udc *udc)
case USB_RECIP_INTERFACE:
break;
case USB_RECIP_ENDPOINT:
- epnum = udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK;
+ epnum = le16_to_cpu(udc->setup.wIndex) & USB_ENDPOINT_NUMBER_MASK;
if (epnum >= XUSB_MAX_ENDPOINTS)
goto stall;
target_ep = &udc->ep[epnum];
epcfgreg = udc->read_fn(udc->addr + target_ep->offset);
halt = epcfgreg & XUSB_EP_CFG_STALL_MASK;
- if (udc->setup.wIndex & USB_DIR_IN) {
+ if (le16_to_cpu(udc->setup.wIndex) & USB_DIR_IN) {
if (!target_ep->is_in)
goto stall;
} else {
@@ -1666,7 +1666,7 @@ static void xudc_set_clear_feature(struct xusb_udc *udc)
switch (udc->setup.bRequestType) {
case USB_RECIP_DEVICE:
- switch (udc->setup.wValue) {
+ switch (le16_to_cpu(udc->setup.wValue)) {
case USB_DEVICE_TEST_MODE:
/*
* The Test Mode will be executed
@@ -1686,13 +1686,15 @@ static void xudc_set_clear_feature(struct xusb_udc *udc)
break;
case USB_RECIP_ENDPOINT:
if (!udc->setup.wValue) {
- endpoint = udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK;
+ endpoint = le16_to_cpu(udc->setup.wIndex) &
+ USB_ENDPOINT_NUMBER_MASK;
if (endpoint >= XUSB_MAX_ENDPOINTS) {
xudc_ep0_stall(udc);
return;
}
target_ep = &udc->ep[endpoint];
- outinbit = udc->setup.wIndex & USB_ENDPOINT_DIR_MASK;
+ outinbit = le16_to_cpu(udc->setup.wIndex) &
+ USB_ENDPOINT_DIR_MASK;
outinbit = outinbit >> 7;
/* Make sure direction matches.*/
@@ -1869,7 +1871,7 @@ static void xudc_ep0_in(struct xusb_udc *udc)
u16 count = 0;
u16 length;
u8 *ep0rambase;
- u8 test_mode = udc->setup.wIndex >> 8;
+ u8 test_mode = le16_to_cpu(udc->setup.wIndex) >> 8;
req = list_first_entry(&ep0->queue, struct xusb_req, queue);
bytes_to_tx = req->usb_req.length - req->usb_req.actual;
@@ -1880,12 +1882,12 @@ static void xudc_ep0_in(struct xusb_udc *udc)
case USB_REQ_SET_ADDRESS:
/* Set the address of the device.*/
udc->write_fn(udc->addr, XUSB_ADDRESS_OFFSET,
- udc->setup.wValue);
+ le16_to_cpu(udc->setup.wValue));
break;
case USB_REQ_SET_FEATURE:
if (udc->setup.bRequestType ==
USB_RECIP_DEVICE) {
- if (udc->setup.wValue ==
+ if (le16_to_cpu(udc->setup.wValue) ==
USB_DEVICE_TEST_MODE)
udc->write_fn(udc->addr,
XUSB_TESTMODE_OFFSET,
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/3] usb: gadget: udc-xilinx: fix cast from restricted __le16 warning
2023-08-22 6:31 [PATCH 0/3] usb: gadget: udc-xilinx: fix warnings Piyush Mehta
2023-08-22 6:31 ` [PATCH 1/3] usb: gadget: udc-xilinx: fix restricted __le16 degrades to integer warning Piyush Mehta
@ 2023-08-22 6:32 ` Piyush Mehta
2023-08-22 6:32 ` [PATCH 3/3] usb: gadget: udc-xilinx: fix incorrect type in assignment warning Piyush Mehta
2 siblings, 0 replies; 4+ messages in thread
From: Piyush Mehta @ 2023-08-22 6:32 UTC (permalink / raw)
To: gregkh, michal.simek, u.kleine-koenig, linus.walleij
Cc: linux-usb, linux-arm-kernel, linux-kernel, git, Piyush Mehta
usb_ctrlrequest member wValue, wLength and wIndex are of type __le16,
conversion macro cpu_to_le16() input argument is __u16, so properly
typecasted to fix the cast from restricted __le16 warning.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/all/202209020044.CX2PfZzM-lkp@intel.com/
Signed-off-by: Piyush Mehta <piyush.mehta@amd.com>
---
drivers/usb/gadget/udc/udc-xilinx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
index e6308414cd1f..476c0a8fc5e7 100644
--- a/drivers/usb/gadget/udc/udc-xilinx.c
+++ b/drivers/usb/gadget/udc/udc-xilinx.c
@@ -1757,9 +1757,9 @@ static void xudc_handle_setup(struct xusb_udc *udc)
memcpy(&setup, ep0rambase, 8);
udc->setup = setup;
- udc->setup.wValue = cpu_to_le16(setup.wValue);
- udc->setup.wIndex = cpu_to_le16(setup.wIndex);
- udc->setup.wLength = cpu_to_le16(setup.wLength);
+ udc->setup.wValue = cpu_to_le16((u16 __force)setup.wValue);
+ udc->setup.wIndex = cpu_to_le16((u16 __force)setup.wIndex);
+ udc->setup.wLength = cpu_to_le16((u16 __force)setup.wLength);
/* Clear previous requests */
xudc_nuke(ep0, -ECONNRESET);
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] usb: gadget: udc-xilinx: fix incorrect type in assignment warning
2023-08-22 6:31 [PATCH 0/3] usb: gadget: udc-xilinx: fix warnings Piyush Mehta
2023-08-22 6:31 ` [PATCH 1/3] usb: gadget: udc-xilinx: fix restricted __le16 degrades to integer warning Piyush Mehta
2023-08-22 6:32 ` [PATCH 2/3] usb: gadget: udc-xilinx: fix cast from restricted __le16 warning Piyush Mehta
@ 2023-08-22 6:32 ` Piyush Mehta
2 siblings, 0 replies; 4+ messages in thread
From: Piyush Mehta @ 2023-08-22 6:32 UTC (permalink / raw)
To: gregkh, michal.simek, u.kleine-koenig, linus.walleij
Cc: linux-usb, linux-arm-kernel, linux-kernel, git, Piyush Mehta
The bitwise attribute is used by the sparse utility to make sure the
variable is converted to the local processor type before other (unsafe)
operations are performed on the variable. Fix the below sparse warnings
type casted with __le16:
warning: incorrect type in assignment (different base types)
expected unsigned short [usertype]
got restricted __le16 [usertype]
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/all/202209020044.CX2PfZzM-lkp@intel.com/
Signed-off-by: Piyush Mehta <piyush.mehta@amd.com>
---
drivers/usb/gadget/udc/udc-xilinx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
index 476c0a8fc5e7..0b12155635d9 100644
--- a/drivers/usb/gadget/udc/udc-xilinx.c
+++ b/drivers/usb/gadget/udc/udc-xilinx.c
@@ -1638,7 +1638,7 @@ static void xudc_getstatus(struct xusb_udc *udc)
}
req->usb_req.length = 2;
- *(u16 *)req->usb_req.buf = cpu_to_le16(status);
+ *(__le16 *)req->usb_req.buf = cpu_to_le16(status);
ret = __xudc_ep0_queue(ep0, req);
if (ret == 0)
return;
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread