Skip to contentSkip to conversation

usb: musb: - kill the compile warning

PATCH In review Bryan Wu 5 participants 7 messages Feb 6, 2009 – Feb 27, 2009

Subsystems (2)
lore
Share & tools
lore

Bryan Wu

author
#0 lore raw

PATCH 1/1 usb: musb: - kill the compile warning

drivers/usb/musb/musb_core.c:1433: warning: assignment makes pointer from integer without a cast

	hw_ep->target_regs = musb_read_target_reg_base(i, mbase);

static inline u16 musb_read_target_reg_base(u8 i, void __iomem *mbase);

this is a common bug, but a bug still ? mbase is a 32/64 bit pointer, but we return a u16 to assign to a pointer ? seems odd :)

So return right pointer in the stub.

Cc Mike Frysinger <[email protected]>
---
 drivers/usb/musb/musb_regs.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/usb/musb/musb_regs.h +3 -3
index de3b2f1..c2f6a16 100644
@@ -333,7 +333,7 @@ static inline u16 musb_read_hwvers(void __iomem *mbase)
 
 static inline void __iomem *musb_read_target_reg_base(u8 i, void __iomem *mbase)
 {
-	return (MUSB_BUSCTL_OFFSET(i, 0) + mbase);
+	return (void __iomem *)(MUSB_BUSCTL_OFFSET(i, 0) + mbase);
 }
 
 static inline void musb_write_rxfunaddr(void __iomem *ep_target_regs,
@@ -473,9 +473,9 @@ static inline u16 musb_read_hwvers(void __iomem *mbase)
 	return 0;
 }
 
-static inline u16 musb_read_target_reg_base(u8 i, void __iomem *mbase)
+static inline void __iomem *musb_read_target_reg_base(u8 i, void __iomem *mbase)
 {
-	return 0;
+	return NULL;
 }
 
 static inline void musb_write_rxfunaddr(void __iomem *ep_target_regs,
Signature · 1 line
1.5.6.3
#1 lore raw
Quoted 22 lines · Bryan Wu

drivers/usb/musb/musb_core.c:1433: warning: assignment makes pointer from integer without a cast

	hw_ep->target_regs = musb_read_target_reg_base(i, mbase);

static inline u16 musb_read_target_reg_base(u8 i, void __iomem *mbase);

this is a common bug, but a bug still ? mbase is a 32/64 bit pointer, but we return a u16 to assign to a pointer ? seems odd :)

So return right pointer in the stub.

Cc Mike Frysinger <[email protected]>
---
 drivers/usb/musb/musb_regs.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/usb/musb/musb_regs.h +0 -0
index de3b2f1..c2f6a16 100644

drivers/usb/musb/musb_regs.h static inline u16 musb_read_hwvers(void __iomem *mbase) · line 336

Quoted 5 lines
drivers/usb/musb/musb_regs.h +1 -1
@@ -333,7 +333,7 @@ static inline u16 musb_read_hwvers(void __iomem *mbase)
 
 static inline void __iomem *musb_read_target_reg_base(u8 i, void __iomem *mbase)
 {
-	return (MUSB_BUSCTL_OFFSET(i, 0) + mbase);
+	return (void __iomem *)(MUSB_BUSCTL_OFFSET(i, 0) + mbase);

please don't cast, we don't get this warning in non-blackfin builds (well, omap at least)

drivers/usb/musb/musb_regs.h static inline u16 musb_read_hwvers(void __iomem *mbase) · line 478

Quoted 9 lines
drivers/usb/musb/musb_regs.h +2 -2
@@ -473,9 +473,9 @@ static inline u16 musb_read_hwvers(void __iomem *mbase)
 	return 0;
 }
 
-static inline u16 musb_read_target_reg_base(u8 i, void __iomem *mbase)
+static inline void __iomem *musb_read_target_reg_base(u8 i, void __iomem *mbase)
 {
-	return 0;
+	return NULL;

this looks fine

Signature · 1 line
balbi
#2 lore raw
In reply to Bryan Wu
Quoted 2 lines · Bryan Wu

-       return (MUSB_BUSCTL_OFFSET(i, 0) + mbase);
+       return (void __iomem *)(MUSB_BUSCTL_OFFSET(i, 0) + mbase);

Why is MUSB_BUSCTL_OFFSET() returning something other than an integer? "mbase" is already "void __iomem *", so the only way that should trigger a warning is if that OFFSET() macro is doing something odd.

#3 lore raw
Quoted 8 lines · David Brownell

drivers/usb/musb/musb_regs.h static inline u16 musb_read_hwvers(void __iomem *mbase) · line 336

Quoted 2 lines · Bryan Wu
drivers/usb/musb/musb_regs.h +1 -1
-       return (MUSB_BUSCTL_OFFSET(i, 0) + mbase);
+       return (void __iomem *)(MUSB_BUSCTL_OFFSET(i, 0) + mbase);

Why is MUSB_BUSCTL_OFFSET() returning something other than an integer? "mbase" is already "void __iomem *", so the only way that should trigger a warning is if that OFFSET() macro is doing something odd.

The warning only comes on Blackfin's version of this, this hunk is unnecessary

Signature · 1 line
balbi
#4 lore raw
Quoted 5 lines · Felipe Balbi
Quoted 4 lines · David Brownell
Quoted 2 lines · Bryan Wu
drivers/usb/musb/musb_regs.h +1 -1
-       return (MUSB_BUSCTL_OFFSET(i, 0) + mbase);
+       return (void __iomem *)(MUSB_BUSCTL_OFFSET(i, 0) + mbase);
Quoted 7 lines
Quoted 4 lines

Why is MUSB_BUSCTL_OFFSET() returning something other than an integer? "mbase" is already "void __iomem *", so the only way that should trigger a warning is if that OFFSET() macro is doing something odd.

The warning only comes on Blackfin's version of this, this hunk is unnecessary

We want to get rid of Blackfin-specific warnings too ... but what I was hinting is that this can't be the right fix.

#5 lore raw
In reply to Bryan Wu
Quoted 6 lines · Bryan Wu

drivers/usb/musb/musb_core.c:1433: warning: assignment makes pointer from integer without a cast

	hw_ep->target_regs = musb_read_target_reg_base(i, mbase);

static inline u16 musb_read_target_reg_base(u8 i, void __iomem *mbase);

Quoted 7 lines

this is a common bug, but a bug still ? mbase is a 32/64 bit pointer, but we return a u16 to assign to a pointer ? seems odd :)

So return right pointer in the stub.

Cc Mike Frysinger <[email protected]>

any new version coming ??

Signature · 1 line
balbi
#6 lore raw
Quoted 10 lines · Felipe Balbi
Quoted 9 lines · Bryan Wu

drivers/usb/musb/musb_core.c:1433: warning: assignment makes pointer from integer without a cast
      hw_ep->target_regs = musb_read_target_reg_base(i, mbase);

static inline u16 musb_read_target_reg_base(u8 i, void __iomem *mbase);

this is a common bug, but a bug still ?  mbase is a 32/64 bit pointer, but we return a u16 to assign to a pointer ?  seems odd :)

Quoted 6 lines
Quoted 4 lines

So return right pointer in the stub.

Cc Mike Frysinger <[email protected]>

any new version coming ??

so we're all on the same page ...

we agree the first hunk is redundant as MUSB_BUSCTL_OFFSET() is an integer constant and mbase is of the type that is returned. which means the first hunk can be dropped.

the 2nd hunk is 100% correct though ...
-mike