From: Nicolas Pitre Date: Fri, 25 Apr 2008 18:28:55 +0000 (-0400) Subject: [ARM] Orion: fix ioremap() optimization X-Git-Tag: v2.6.26-rc1~351^2~1^3~3 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=fd153abb01c3fbcc47cd4ac3c0bc8801cfcc0009;p=karo-tx-linux.git [ARM] Orion: fix ioremap() optimization The ioremap() optimization used for internal register didn't cope with the fact that paddr + size can wrap to zero if the area extends to the end of the physical address space. Issue isolated by Sylver Bruneau . Signed-off-by: Nicolas Pitre --- diff --git a/include/asm-arm/arch-orion5x/io.h b/include/asm-arm/arch-orion5x/io.h index 5148ab7ad1f8..50f8c8802206 100644 --- a/include/asm-arm/arch-orion5x/io.h +++ b/include/asm-arm/arch-orion5x/io.h @@ -20,11 +20,10 @@ static inline void __iomem * __arch_ioremap(unsigned long paddr, size_t size, unsigned int mtype) { void __iomem *retval; - - if (mtype == MT_DEVICE && size && paddr >= ORION5X_REGS_PHYS_BASE && - paddr + size <= ORION5X_REGS_PHYS_BASE + ORION5X_REGS_SIZE) { - retval = (void __iomem *)ORION5X_REGS_VIRT_BASE + - (paddr - ORION5X_REGS_PHYS_BASE); + unsigned long offs = paddr - ORION5X_REGS_PHYS_BASE; + if (mtype == MT_DEVICE && size && offs < ORION5X_REGS_SIZE && + size <= ORION5X_REGS_SIZE && offs + size <= ORION5X_REGS_SIZE) { + retval = (void __iomem *)ORION5X_REGS_VIRT_BASE + offs; } else { retval = __arm_ioremap(paddr, size, mtype); }