usb: gadget: dummy: fix nonsensical comparisons 36/220136/3
authorArnd Bergmann <arnd@arndb.de>
Thu, 7 Sep 2017 14:14:31 +0000 (16:14 +0200)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 16 Dec 2019 01:32:07 +0000 (10:32 +0900)
commit082390c1b80dade01b67bae0a133ca99b7c2f55f
tree32216ab925ff9cd6b793962d314771cd4ec79818
parent8e6a1fd5c7dce3ff645c5c06e9c615126f52af79
usb: gadget: dummy: fix nonsensical comparisons

gcc-8 points out two comparisons that are clearly bogus
and almost certainly not what the author intended to write:

drivers/usb/gadget/udc/dummy_hcd.c: In function 'set_link_state_by_speed':
drivers/usb/gadget/udc/dummy_hcd.c:379:31: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
         USB_PORT_STAT_ENABLE) == 1 &&
                               ^~
drivers/usb/gadget/udc/dummy_hcd.c:381:25: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
      USB_SS_PORT_LS_U0) == 1 &&
                         ^~

I looked at the code for a bit and came up with a change that makes
it look like what the author probably meant here. This makes it
look reasonable to me and to gcc, shutting up the warning.

It does of course change behavior as the two conditions are actually
evaluated rather than being hardcoded to false, and I have made no
attempt at verifying that the changed logic makes sense in the context
of a USB HCD, so that part needs to be reviewed carefully.

Fixes: 1cd8fd2887e1 ("usb: gadget: dummy_hcd: add SuperSpeed support")
Cc: Tatyana Brokhman <tlinder@codeaurora.org>
Cc: Felipe Balbi <balbi@kernel.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
[sw0312.kim: cherry-pick mainline commit 7661ca09b2ff for gcc 9 build
 - change file path to drivers/usb/gadget/dummy_hcd.c]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I5bfba1d02743b27940d6e457fe22d254727dea29
drivers/usb/gadget/dummy_hcd.c