Re: [PATCH] USB: xhci - fix comparison when checking for duplicate ports

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dmitry,

I guess that casting -1 to a u8 didn't have the effect that I thought it
would.

This looks correct, and we probably haven't run into this issue because
all the xHCI host controllers we've run into have well-formed port speed
arrays.  I'll queue this.

On Wed, Feb 23, 2011 at 12:54:37AM -0800, Dmitry Torokhov wrote:
> 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

Can you please not send the above bit in future mails?  It causes some
pain for maintainers (particularly since git-am accepts it fine, but git
rebase has some serious issues if you leave this bit in the commit
message).

Sarah Sharp

> 
> 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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux