[PATCH 3/3] staging: emxx_udc: Added missing le16_to_cpu conversions

From: Carmeli Tamir
Date: Wed Oct 17 2018 - 17:02:30 EST


Fixed sparse tool warnings due to missing convesion from
le16 to cpu endienness.

Signed-off-by: Carmeli Tamir <carmeli.tamir@xxxxxxxxx>
---
drivers/staging/emxx_udc/emxx_udc.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index 344fe80..03df1bc 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -135,6 +135,7 @@ static void _nbu2ss_ep0_complete(struct usb_ep *_ep, struct usb_request *_req)
{
u8 recipient;
u16 selector;
+ u16 wIndex;
u32 test_mode;
struct usb_ctrlrequest *p_ctrl;
struct nbu2ss_udc *udc;
@@ -149,10 +150,12 @@ static void _nbu2ss_ep0_complete(struct usb_ep *_ep, struct usb_request *_req)
/*-------------------------------------------------*/
/* SET_FEATURE */
recipient = (u8)(p_ctrl->bRequestType & USB_RECIP_MASK);
- selector = p_ctrl->wValue;
+ selector = le16_to_cpu(p_ctrl->wValue);
if ((recipient == USB_RECIP_DEVICE) &&
(selector == USB_DEVICE_TEST_MODE)) {
test_mode = (u32)(p_ctrl->wIndex >> 8);
+ wIndex = le16_to_cpu(p_ctrl->wIndex);
+ test_mode = (u32)(wIndex >> 8);
_nbu2ss_set_test_mode(udc, test_mode);
}
}
@@ -1380,7 +1383,7 @@ static struct usb_device_descriptor device_desc = {
.bMaxPacketSize0 = 64,
.idVendor = cpu_to_le16(0x0409),
.idProduct = cpu_to_le16(0xfff0),
- .bcdDevice = 0xffff,
+ .bcdDevice = cpu_to_le16(0xffff),
.iManufacturer = 0x00,
.iProduct = 0x00,
.iSerialNumber = 0x00,
@@ -1468,8 +1471,8 @@ static inline int _nbu2ss_req_feature(struct nbu2ss_udc *udc, bool bset)
{
u8 recipient = (u8)(udc->ctrl.bRequestType & USB_RECIP_MASK);
u8 direction = (u8)(udc->ctrl.bRequestType & USB_DIR_IN);
- u16 selector = udc->ctrl.wValue;
- u16 wIndex = udc->ctrl.wIndex;
+ u16 selector = le16_to_cpu(udc->ctrl.wValue);
+ u16 wIndex = le16_to_cpu(udc->ctrl.wIndex);
u8 ep_adrs;
int result = -EOPNOTSUPP;

@@ -1568,7 +1571,8 @@ static int std_req_get_status(struct nbu2ss_udc *udc)
if ((udc->ctrl.wValue != 0x0000) || (direction != USB_DIR_IN))
return result;

- length = min_t(u16, udc->ctrl.wLength, sizeof(status_data));
+ length =
+ min_t(u16, le16_to_cpu(udc->ctrl.wLength), sizeof(status_data));

switch (recipient) {
case USB_RECIP_DEVICE:
@@ -1584,8 +1588,8 @@ static int std_req_get_status(struct nbu2ss_udc *udc)
break;

case USB_RECIP_ENDPOINT:
- if (0x0000 == (udc->ctrl.wIndex & 0xFF70)) {
- ep_adrs = (u8)(udc->ctrl.wIndex & 0xFF);
+ if (0x0000 == (le16_to_cpu(udc->ctrl.wIndex) & 0xFF70)) {
+ ep_adrs = (u8)(le16_to_cpu(udc->ctrl.wIndex) & 0xFF);
result = _nbu2ss_get_ep_stall(udc, ep_adrs);

if (result > 0)
@@ -1625,7 +1629,7 @@ static int std_req_set_feature(struct nbu2ss_udc *udc)
static int std_req_set_address(struct nbu2ss_udc *udc)
{
int result = 0;
- u32 wValue = udc->ctrl.wValue;
+ u32 wValue = le16_to_cpu(udc->ctrl.wValue);

if ((udc->ctrl.bRequestType != 0x00) ||
(udc->ctrl.wIndex != 0x0000) ||
@@ -1647,7 +1651,7 @@ static int std_req_set_address(struct nbu2ss_udc *udc)
/*-------------------------------------------------------------------------*/
static int std_req_set_configuration(struct nbu2ss_udc *udc)
{
- u32 config_value = (u32)(udc->ctrl.wValue & 0x00ff);
+ u32 config_value = (u32)(le16_to_cpu(udc->ctrl.wValue) & 0x00ff);

if ((udc->ctrl.wIndex != 0x0000) ||
(udc->ctrl.wLength != 0x0000) ||
--
2.7.4