Skip to content

Commit

Permalink
[ARM] Orion: fix ioremap() optimization
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nicolas Pitre committed Apr 28, 2008
1 parent c5a1e8f commit fd153ab
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions include/asm-arm/arch-orion5x/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit fd153ab

Please sign in to comment.