* [patch] USB: xhci: unsigned char never equals -1
@ 2011-03-17 19:39 Dan Carpenter
2011-03-17 19:47 ` Dan Carpenter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2011-03-17 19:39 UTC (permalink / raw)
To: kernel-janitors
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>
---
I'm not super familiar with this code... Compile tested only.
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index a003e79..ab7fc2b 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,
* Skip ports that don't have known speeds, or have duplicate
* Extended Capabilities port speed entries.
*/
- if (port_speed = 0 || port_speed = -1)
+ if (port_speed = 0 || port_speed = DUPLICATE_ENTRY)
continue;
/*
@@ -1727,12 +1727,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] != DUPLICATE_ENTRY) {
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] = DUPLICATE_ENTRY;
}
/* FIXME: Should we disable the port? */
continue;
@@ -1831,7 +1831,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
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] = DUPLICATE_ENTRY)
continue;
xhci->usb2_ports[port_index] diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index cfc1ad9..c6d1462 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,
* Skip ports that don't have known speeds, or have duplicate
* Extended Capabilities port speed entries.
*/
- if (port_speed = 0 || port_speed = -1)
+ if (port_speed = 0 || port_speed = DUPLICATE_ENTRY)
continue;
/*
@@ -1260,7 +1260,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
port_id);
goto cleanup;
}
- if (major_revision = (u8) -1) {
+ if (major_revision = DUPLICATE_ENTRY) {
xhci_warn(xhci, "Event for port %u duplicated in"
"Extended Capabilities, ignoring.\n",
port_id);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 711de25..45bd5a2 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -348,6 +348,9 @@ struct xhci_op_regs {
/* Initiate a warm port reset - complete when PORT_WRC is '1' */
#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 */
/* Inactivity timer value for transitions into U1, in microseconds.
* Timeout can be up to 127us. 0xFF means an infinite timeout.
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [patch] USB: xhci: unsigned char never equals -1
2011-03-17 19:39 [patch] USB: xhci: unsigned char never equals -1 Dan Carpenter
@ 2011-03-17 19:47 ` Dan Carpenter
2011-03-17 20:52 ` Sarah Sharp
2011-03-17 21:07 ` Dan Carpenter
2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2011-03-17 19:47 UTC (permalink / raw)
To: kernel-janitors
Btw, xhci-ring.c causes some valid looking gcc warnings:
C [M] drivers/usb/host/xhci-ring.o
drivers/usb/host/xhci-ring.c: In function ‘handle_port_status’:
drivers/usb/host/xhci-ring.c:1229: warning: ‘hcd’ may be used uninitialized in this function
drivers/usb/host/xhci-ring.c: In function ‘handle_tx_event’:
drivers/usb/host/xhci-ring.c:1895: warning: ‘event_trb’ may be used uninitialized in this function
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] USB: xhci: unsigned char never equals -1
2011-03-17 19:39 [patch] USB: xhci: unsigned char never equals -1 Dan Carpenter
2011-03-17 19:47 ` Dan Carpenter
@ 2011-03-17 20:52 ` Sarah Sharp
2011-03-17 21:07 ` Dan Carpenter
2 siblings, 0 replies; 4+ messages in thread
From: Sarah Sharp @ 2011-03-17 20:52 UTC (permalink / raw)
To: kernel-janitors
On Thu, Mar 17, 2011 at 10:47:46PM +0300, Dan Carpenter wrote:
> Btw, xhci-ring.c causes some valid looking gcc warnings:
Which git commit are you working off of?
> C [M] drivers/usb/host/xhci-ring.o
> drivers/usb/host/xhci-ring.c: In function ‘handle_port_status’:
> drivers/usb/host/xhci-ring.c:1229: warning: ‘hcd’ may be used uninitialized in this function
> drivers/usb/host/xhci-ring.c: In function ‘handle_tx_event’:
> drivers/usb/host/xhci-ring.c:1895: warning: ‘event_trb’ may be used uninitialized in this function
I think the second warning is just the compiler getting confused, but
I'll look into the first warning. What gcc version are you using? I
had compile-tested the patches I recently sent to Greg, but on an older
(un-updateable, thanks Ubuntu) box with an older gcc.
Sarah Sharp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] USB: xhci: unsigned char never equals -1
2011-03-17 19:39 [patch] USB: xhci: unsigned char never equals -1 Dan Carpenter
2011-03-17 19:47 ` Dan Carpenter
2011-03-17 20:52 ` Sarah Sharp
@ 2011-03-17 21:07 ` Dan Carpenter
2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2011-03-17 21:07 UTC (permalink / raw)
To: kernel-janitors
On Thu, Mar 17, 2011 at 01:52:23PM -0700, Sarah Sharp wrote:
> On Thu, Mar 17, 2011 at 10:47:46PM +0300, Dan Carpenter wrote:
> > Btw, xhci-ring.c causes some valid looking gcc warnings:
>
> Which git commit are you working off of?
>
This is linux-next for 20110316.
commit b3694afad1864eaa7b59a1a5bcf576ed00d4089a
Merge: 37f454a 500132a
Author: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Wed Mar 16 16:53:13 2011 +1100
Merge remote-tracking branch 'usb/usb-next'
Conflicts:
arch/arm/mach-omap2/board-omap3evm.c
arch/arm/mach-omap2/board-overo.c
arch/arm/mach-omap2/clock3xxx_data.c
arch/arm/mach-omap2/usb-musb.c
arch/arm/plat-omap/include/plat/usb.h
drivers/usb/gadget/Kconfig
drivers/usb/gadget/fsl_mxc_udc.c
drivers/usb/musb/musb_core.h
commit ba0a4d9aaae789a6a632968b27c21d49b858b13a
Author: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Date: Wed Feb 23 18:13:43 2011 -0800
xhci: Clean up cycle bit math used during stalls.
> > C [M] drivers/usb/host/xhci-ring.o
> > drivers/usb/host/xhci-ring.c: In function ‘handle_port_status’:
> > drivers/usb/host/xhci-ring.c:1229: warning: ‘hcd’ may be used uninitialized in this function
> > drivers/usb/host/xhci-ring.c: In function ‘handle_tx_event’:
> > drivers/usb/host/xhci-ring.c:1895: warning: ‘event_trb’ may be used uninitialized in this function
>
> I think the second warning is just the compiler getting confused, but
> I'll look into the first warning. What gcc version are you using? I
> had compile-tested the patches I recently sent to Greg, but on an older
> (un-updateable, thanks Ubuntu) box with an older gcc.
>
I'm using gcc 4.4.3-4ubuntu5.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-17 21:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17 19:39 [patch] USB: xhci: unsigned char never equals -1 Dan Carpenter
2011-03-17 19:47 ` Dan Carpenter
2011-03-17 20:52 ` Sarah Sharp
2011-03-17 21:07 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox