Skip to contentSkip to conversation

mfd: omap-usb-tll: fix register offsets

PATCH Applied Arnd Bergmann 2 participants 2 messages Aug 23, 2017 – Aug 24, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: omap-usb-tll: fix register offsets

gcc-8 notices that the register number calculation is wrong when the offset is an 'u8' but the number is larger than 256:

drivers/mfd/omap-usb-tll.c: In function 'omap_tll_init':
drivers/mfd/omap-usb-tll.c:90:46: error: overflow in conversion from 'int' to 'u8 {aka unsigned char}' chages value from 'i * 256 + 2070' to '22' [-Werror=overflow]

This addresses it by always using a 32-bit offset number for the register. This is apparently an old problem that previous compilers did not find.

Fixes 16fa3dc75c22 ("mfd: omap-usb-tll: HOST TLL platform driver")
---
 drivers/mfd/omap-usb-tll.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/omap-usb-tll.c +2 -2
index 6f5300b0eb31..44a5d66314c6 100644
@@ -131,12 +131,12 @@ static inline u32 usbtll_read(void __iomem *base, u32 reg)
 	return readl_relaxed(base + reg);
 }
 
-static inline void usbtll_writeb(void __iomem *base, u8 reg, u8 val)
+static inline void usbtll_writeb(void __iomem *base, u32 reg, u8 val)
 {
 	writeb_relaxed(val, base + reg);
 }
 
-static inline u8 usbtll_readb(void __iomem *base, u8 reg)
+static inline u8 usbtll_readb(void __iomem *base, u32 reg)
 {
 	return readb_relaxed(base + reg);
 }
Signature · 1 line
2.9.0
Applied
#1 lore raw
Quoted 10 lines · Arnd Bergmann

gcc-8 notices that the register number calculation is wrong when the offset is an 'u8' but the number is larger than 256:

drivers/mfd/omap-usb-tll.c: In function 'omap_tll_init':
drivers/mfd/omap-usb-tll.c:90:46: error: overflow in conversion from 'int' to 'u8 {aka unsigned char}' chages value from 'i * 256 + 2070' to '22' [-Werror=overflow]

This addresses it by always using a 32-bit offset number for the register. This is apparently an old problem that previous compilers did not find.

Quoted 5 lines
Fixes 16fa3dc75c22 ("mfd: omap-usb-tll: HOST TLL platform driver")
---
 drivers/mfd/omap-usb-tll.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog