>From 76f7253356a10f698fbd9a3dba3ee633902526ae Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov <dtor@xxxxxxxxxx> Date: Wed, 23 Feb 2011 00:23:21 -0800 Subject: [PATCH] USB: xhci - fix comparison when checking for duplicate ports Compiling with more strict compiler flags than default ones yeilds the following warning: cc1: warnings being treated as errors xhci-mem.c: In function 'xhci_setup_port_arrays': xhci-mem.c:1769: warning: comparison is always false due to limited range of data types which happens because port_array[] is u8 so after integer promotion the value is between 0 - 255 (no sign extension happens) but we compare it with -1. Signed-off-by: Dmitry Torokhov <dtor@xxxxxxxxxx> --- As far as I can see this is a real issue, still compiled only at this time. Thanks, Dmitry drivers/usb/host/xhci-mem.c | 9 +++++---- drivers/usb/host/xhci.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index a953439..ef1edec 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1672,12 +1672,12 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, * found a similar duplicate. */ if (xhci->port_array[i] != major_revision && - xhci->port_array[i] != (u8) -1) { + xhci->port_array[i] != XHCI_PORT_IGNORE) { if (xhci->port_array[i] == 0x03) xhci->num_usb3_ports--; else xhci->num_usb2_ports--; - xhci->port_array[i] = (u8) -1; + xhci->port_array[i] = XHCI_PORT_IGNORE; } /* FIXME: Should we disable the port? */ continue; @@ -1761,9 +1761,10 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) port_index = 0; for (i = 0; i < num_ports; i++) { if (xhci->port_array[i] == 0x03 || - xhci->port_array[i] == 0 || - xhci->port_array[i] == -1) + xhci->port_array[i] == 0 || + xhci->port_array[i] == XHCI_PORT_IGNORE) { continue; + } xhci->usb2_ports[port_index] = &xhci->op_regs->port_status_base + diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 7f127df..b560cbc 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1255,6 +1255,7 @@ struct xhci_hcd { suspended */ unsigned long resume_done[MAX_HC_PORTS]; /* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */ +#define XHCI_PORT_IGNORE 0xff u8 *port_array; /* Array of pointers to USB 3.0 PORTSC registers */ u32 __iomem **usb3_ports; -- 1.7.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html