]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[ARM] Orion: fix ioremap() optimization
authorNicolas Pitre <nico@cam.org>
Fri, 25 Apr 2008 18:28:55 +0000 (14:28 -0400)
committerNicolas Pitre <nico@cam.org>
Mon, 28 Apr 2008 19:57:41 +0000 (15:57 -0400)
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 <sylver.bruneau@googlemail.com>.

Signed-off-by: Nicolas Pitre <nico@marvell.com>
include/asm-arm/arch-orion5x/io.h

index 5148ab7ad1f83404b9ae53caeba8582f4ed08941..50f8c880220667cd4523ad1f5f061eb592c6908c 100644 (file)
@@ -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);
        }