OSDN Git Service

staging: usbip: fix sparse warnings regarding endianness
authorTeodora Baluta <teobaluta@gmail.com>
Mon, 4 Nov 2013 11:12:12 +0000 (13:12 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Nov 2013 19:51:53 +0000 (11:51 -0800)
The wHubCharacteristics field in usb_hub_descriptor structure is __le16
so there is no need for cast. The cpu_to_le16 returns a __le16 type for
a u16 type. Used cpu_to_le16 to silence last sparse error.

drivers/staging/usbip/vhci_hcd.c:223:35: warning: incorrect type in assignment (different base types)
drivers/staging/usbip/vhci_hcd.c:223:35:    expected restricted __le16 [usertype] wHubCharacteristics
drivers/staging/usbip/vhci_hcd.c:223:35:    got unsigned short [unsigned] [usertype] <noident>
drivers/staging/usbip/vhci_hcd.c:351:34: warning: incorrect type in assignment (different base types)
drivers/staging/usbip/vhci_hcd.c:351:34:    expected unsigned short [unsigned] [short] [usertype] <noident>
drivers/staging/usbip/vhci_hcd.c:351:34:    got restricted __le16 [usertype] <noident>
drivers/staging/usbip/vhci_hcd.c:352:34: warning: incorrect type in assignment (different base types)
drivers/staging/usbip/vhci_hcd.c:352:34:    expected unsigned short [unsigned] [short] [usertype] <noident>
drivers/staging/usbip/vhci_hcd.c:352:34:    got restricted __le16 [usertype] <noident>
drivers/staging/usbip/vhci_hcd.c:540:36: warning: restricted __le16 degrades to integer

Signed-off-by: Teodora Baluta <teobaluta@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/usbip/vhci_hcd.c

index e810ad5..e37c6c1 100644 (file)
@@ -220,8 +220,7 @@ static inline void hub_descriptor(struct usb_hub_descriptor *desc)
        memset(desc, 0, sizeof(*desc));
        desc->bDescriptorType = 0x29;
        desc->bDescLength = 9;
-       desc->wHubCharacteristics = (__force __u16)
-               (__constant_cpu_to_le16(0x0001));
+       desc->wHubCharacteristics = (__constant_cpu_to_le16(0x0001));
        desc->bNbrPorts = VHCI_NPORTS;
        desc->u.hs.DeviceRemovable[0] = 0xff;
        desc->u.hs.DeviceRemovable[1] = 0xff;
@@ -348,8 +347,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                                        USB_PORT_STAT_ENABLE;
                        }
                }
-               ((u16 *) buf)[0] = cpu_to_le16(dum->port_status[rhport]);
-               ((u16 *) buf)[1] = cpu_to_le16(dum->port_status[rhport] >> 16);
+               ((__le16 *) buf)[0] = cpu_to_le16(dum->port_status[rhport]);
+               ((__le16 *) buf)[1] = cpu_to_le16(dum->port_status[rhport] >> 16);
 
                usbip_dbg_vhci_rh(" GetPortStatus bye %x %x\n", ((u16 *)buf)[0],
                                  ((u16 *)buf)[1]);
@@ -537,7 +536,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
                        goto no_need_xmit;
 
                case USB_REQ_GET_DESCRIPTOR:
-                       if (ctrlreq->wValue == (USB_DT_DEVICE << 8))
+                       if (ctrlreq->wValue == cpu_to_le16(USB_DT_DEVICE << 8))
                                usbip_dbg_vhci_hc("Not yet?: "
                                                  "Get_Descriptor to device 0 "
                                                  "(get max pipe size)\n");