Commit 22e04870 authored by Dan Carpenter's avatar Dan Carpenter Committed by Sarah Sharp

USB: xhci: unsigned char never equals -1

There were some places that compared port_speed == -1 where port_speed
is a u8.  This doesn't work unless we cast the -1 to u8.  Some places
did it correctly.

Instead of using -1 directly, I've created a DUPLICATE_ENTRY define
which does the cast and is more descriptive as well.
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
parent 5a6c2f3f
...@@ -846,7 +846,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd *xhci, ...@@ -846,7 +846,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd *xhci,
* Skip ports that don't have known speeds, or have duplicate * Skip ports that don't have known speeds, or have duplicate
* Extended Capabilities port speed entries. * Extended Capabilities port speed entries.
*/ */
if (port_speed == 0 || port_speed == -1) if (port_speed == 0 || port_speed == DUPLICATE_ENTRY)
continue; continue;
/* /*
...@@ -1727,12 +1727,12 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, ...@@ -1727,12 +1727,12 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
* found a similar duplicate. * found a similar duplicate.
*/ */
if (xhci->port_array[i] != major_revision && if (xhci->port_array[i] != major_revision &&
xhci->port_array[i] != (u8) -1) { xhci->port_array[i] != DUPLICATE_ENTRY) {
if (xhci->port_array[i] == 0x03) if (xhci->port_array[i] == 0x03)
xhci->num_usb3_ports--; xhci->num_usb3_ports--;
else else
xhci->num_usb2_ports--; xhci->num_usb2_ports--;
xhci->port_array[i] = (u8) -1; xhci->port_array[i] = DUPLICATE_ENTRY;
} }
/* FIXME: Should we disable the port? */ /* FIXME: Should we disable the port? */
continue; continue;
...@@ -1831,7 +1831,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) ...@@ -1831,7 +1831,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
for (i = 0; i < num_ports; i++) { for (i = 0; i < num_ports; i++) {
if (xhci->port_array[i] == 0x03 || if (xhci->port_array[i] == 0x03 ||
xhci->port_array[i] == 0 || xhci->port_array[i] == 0 ||
xhci->port_array[i] == -1) xhci->port_array[i] == DUPLICATE_ENTRY)
continue; continue;
xhci->usb2_ports[port_index] = xhci->usb2_ports[port_index] =
......
...@@ -1209,7 +1209,7 @@ static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd, ...@@ -1209,7 +1209,7 @@ static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd,
* Skip ports that don't have known speeds, or have duplicate * Skip ports that don't have known speeds, or have duplicate
* Extended Capabilities port speed entries. * Extended Capabilities port speed entries.
*/ */
if (port_speed == 0 || port_speed == -1) if (port_speed == 0 || port_speed == DUPLICATE_ENTRY)
continue; continue;
/* /*
...@@ -1260,7 +1260,7 @@ static void handle_port_status(struct xhci_hcd *xhci, ...@@ -1260,7 +1260,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
port_id); port_id);
goto cleanup; goto cleanup;
} }
if (major_revision == (u8) -1) { if (major_revision == DUPLICATE_ENTRY) {
xhci_warn(xhci, "Event for port %u duplicated in" xhci_warn(xhci, "Event for port %u duplicated in"
"Extended Capabilities, ignoring.\n", "Extended Capabilities, ignoring.\n",
port_id); port_id);
......
...@@ -348,6 +348,9 @@ struct xhci_op_regs { ...@@ -348,6 +348,9 @@ struct xhci_op_regs {
/* Initiate a warm port reset - complete when PORT_WRC is '1' */ /* Initiate a warm port reset - complete when PORT_WRC is '1' */
#define PORT_WR (1 << 31) #define PORT_WR (1 << 31)
/* We mark duplicate entries with -1 */
#define DUPLICATE_ENTRY ((u8)(-1))
/* Port Power Management Status and Control - port_power_base bitmasks */ /* Port Power Management Status and Control - port_power_base bitmasks */
/* Inactivity timer value for transitions into U1, in microseconds. /* Inactivity timer value for transitions into U1, in microseconds.
* Timeout can be up to 127us. 0xFF means an infinite timeout. * Timeout can be up to 127us. 0xFF means an infinite timeout.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment