Skip to content

Commit 7661ca0

Browse files
arndbFelipe Balbi
authored andcommitted
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: 1cd8fd2 ("usb: gadget: dummy_hcd: add SuperSpeed support") Cc: Tatyana Brokhman <[email protected]> Cc: Felipe Balbi <[email protected]> Acked-by: Alan Stern <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 641663a commit 7661ca0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/usb/gadget/udc/dummy_hcd.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,10 @@ static void set_link_state_by_speed(struct dummy_hcd *dum_hcd)
375375
USB_PORT_STAT_CONNECTION) == 0)
376376
dum_hcd->port_status |=
377377
(USB_PORT_STAT_C_CONNECTION << 16);
378-
if ((dum_hcd->port_status &
379-
USB_PORT_STAT_ENABLE) == 1 &&
380-
(dum_hcd->port_status &
381-
USB_SS_PORT_LS_U0) == 1 &&
382-
dum_hcd->rh_state != DUMMY_RH_SUSPENDED)
378+
if ((dum_hcd->port_status & USB_PORT_STAT_ENABLE) &&
379+
(dum_hcd->port_status &
380+
USB_PORT_STAT_LINK_STATE) == USB_SS_PORT_LS_U0 &&
381+
dum_hcd->rh_state != DUMMY_RH_SUSPENDED)
383382
dum_hcd->active = 1;
384383
}
385384
} else {

0 commit comments

Comments
 (0)