diff options
author | Dan Carpenter <error27@gmail.com> | 2011-03-17 15:39:49 -0400 |
---|---|---|
committer | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2011-04-13 19:19:47 -0400 |
commit | 22e0487047567252d5677ff35766cd884375efc2 (patch) | |
tree | 792d135afe30d6af87d38ff5a8eb010d39c86053 /drivers/usb/host | |
parent | 5a6c2f3ff039154872ce597952f8b8900ea0d732 (diff) |
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: Dan Carpenter <error27@gmail.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r-- | drivers/usb/host/xhci-mem.c | 8 | ||||
-rw-r--r-- | drivers/usb/host/xhci-ring.c | 4 | ||||
-rw-r--r-- | drivers/usb/host/xhci.h | 3 |
3 files changed, 9 insertions, 6 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index a003e79aacdc..ab7fc2b71a8c 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -846,7 +846,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd *xhci, | |||
846 | * Skip ports that don't have known speeds, or have duplicate | 846 | * Skip ports that don't have known speeds, or have duplicate |
847 | * Extended Capabilities port speed entries. | 847 | * Extended Capabilities port speed entries. |
848 | */ | 848 | */ |
849 | if (port_speed == 0 || port_speed == -1) | 849 | if (port_speed == 0 || port_speed == DUPLICATE_ENTRY) |
850 | continue; | 850 | continue; |
851 | 851 | ||
852 | /* | 852 | /* |
@@ -1727,12 +1727,12 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, | |||
1727 | * found a similar duplicate. | 1727 | * found a similar duplicate. |
1728 | */ | 1728 | */ |
1729 | if (xhci->port_array[i] != major_revision && | 1729 | if (xhci->port_array[i] != major_revision && |
1730 | xhci->port_array[i] != (u8) -1) { | 1730 | xhci->port_array[i] != DUPLICATE_ENTRY) { |
1731 | if (xhci->port_array[i] == 0x03) | 1731 | if (xhci->port_array[i] == 0x03) |
1732 | xhci->num_usb3_ports--; | 1732 | xhci->num_usb3_ports--; |
1733 | else | 1733 | else |
1734 | xhci->num_usb2_ports--; | 1734 | xhci->num_usb2_ports--; |
1735 | xhci->port_array[i] = (u8) -1; | 1735 | xhci->port_array[i] = DUPLICATE_ENTRY; |
1736 | } | 1736 | } |
1737 | /* FIXME: Should we disable the port? */ | 1737 | /* FIXME: Should we disable the port? */ |
1738 | continue; | 1738 | continue; |
@@ -1831,7 +1831,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) | |||
1831 | for (i = 0; i < num_ports; i++) { | 1831 | for (i = 0; i < num_ports; i++) { |
1832 | if (xhci->port_array[i] == 0x03 || | 1832 | if (xhci->port_array[i] == 0x03 || |
1833 | xhci->port_array[i] == 0 || | 1833 | xhci->port_array[i] == 0 || |
1834 | xhci->port_array[i] == -1) | 1834 | xhci->port_array[i] == DUPLICATE_ENTRY) |
1835 | continue; | 1835 | continue; |
1836 | 1836 | ||
1837 | xhci->usb2_ports[port_index] = | 1837 | xhci->usb2_ports[port_index] = |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index cfc1ad92473f..c6d1462aa1c3 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -1209,7 +1209,7 @@ static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd, | |||
1209 | * Skip ports that don't have known speeds, or have duplicate | 1209 | * Skip ports that don't have known speeds, or have duplicate |
1210 | * Extended Capabilities port speed entries. | 1210 | * Extended Capabilities port speed entries. |
1211 | */ | 1211 | */ |
1212 | if (port_speed == 0 || port_speed == -1) | 1212 | if (port_speed == 0 || port_speed == DUPLICATE_ENTRY) |
1213 | continue; | 1213 | continue; |
1214 | 1214 | ||
1215 | /* | 1215 | /* |
@@ -1260,7 +1260,7 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1260 | port_id); | 1260 | port_id); |
1261 | goto cleanup; | 1261 | goto cleanup; |
1262 | } | 1262 | } |
1263 | if (major_revision == (u8) -1) { | 1263 | if (major_revision == DUPLICATE_ENTRY) { |
1264 | xhci_warn(xhci, "Event for port %u duplicated in" | 1264 | xhci_warn(xhci, "Event for port %u duplicated in" |
1265 | "Extended Capabilities, ignoring.\n", | 1265 | "Extended Capabilities, ignoring.\n", |
1266 | port_id); | 1266 | port_id); |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 91b1a237c11e..bdb78f51735e 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -348,6 +348,9 @@ struct xhci_op_regs { | |||
348 | /* Initiate a warm port reset - complete when PORT_WRC is '1' */ | 348 | /* Initiate a warm port reset - complete when PORT_WRC is '1' */ |
349 | #define PORT_WR (1 << 31) | 349 | #define PORT_WR (1 << 31) |
350 | 350 | ||
351 | /* We mark duplicate entries with -1 */ | ||
352 | #define DUPLICATE_ENTRY ((u8)(-1)) | ||
353 | |||
351 | /* Port Power Management Status and Control - port_power_base bitmasks */ | 354 | /* Port Power Management Status and Control - port_power_base bitmasks */ |
352 | /* Inactivity timer value for transitions into U1, in microseconds. | 355 | /* Inactivity timer value for transitions into U1, in microseconds. |
353 | * Timeout can be up to 127us. 0xFF means an infinite timeout. | 356 | * Timeout can be up to 127us. 0xFF means an infinite timeout. |