On Fri, 18 Jul 2014, Pratyush Anand wrote:
> Following sparse warnings were reported by kbuild test bot
>
> drivers/usb/misc/lvstest.c:314:28: sparse: incorrect type in assignment
> (different base types)
> drivers/usb/misc/lvstest.c:314:28: expected unsigned short [unsigned]
> [usertype] portchange
> drivers/usb/misc/lvstest.c:314:28: got restricted __le16 [usertype]
> wPortChange
> drivers/usb/misc/lvstest.c:332:40: sparse: restricted __le16 degrades to
> integer
>
> This patch fixes above warnings.
>
> Signed-off-by: Pratyush Anand <[email protected]>
> ---
> drivers/usb/misc/lvstest.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c
> index 02df9a7..dd53958 100644
> --- a/drivers/usb/misc/lvstest.c
> +++ b/drivers/usb/misc/lvstest.c
> @@ -301,7 +301,7 @@ static void lvs_rh_work(struct work_struct *work)
> struct usb_hub_descriptor *descriptor = &lvs->descriptor;
> struct usb_port_status *port_status = &lvs->port_status;
> int i, ret = 0;
> - u16 portchange;
> + __le16 portchange;
>
> /* Examine each root port */
> for (i = 1; i <= descriptor->bNbrPorts; i++) {
> @@ -313,23 +313,23 @@ static void lvs_rh_work(struct work_struct *work)
>
> portchange = port_status->wPortChange;
>
> - if (portchange & USB_PORT_STAT_C_LINK_STATE)
> + if (le16_to_cpu(portchange) & USB_PORT_STAT_C_LINK_STATE)
Ugh, no!
Leave portchange as a u16 value, and instead simply do:
portchange = le16_to_cpu(port_status->wPortChange);
That way there's only one byte-swap operation instead of six.
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html