isight_firmware: Avoid crash on loading invalid firmware
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-arm / arch-orion5x / io.h
blob50f8c880220667cd4523ad1f5f061eb592c6908c
1 /*
2 * include/asm-arm/arch-orion5x/io.h
4 * Tzachi Perelstein <tzachi@marvell.com>
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
11 #ifndef __ASM_ARCH_IO_H
12 #define __ASM_ARCH_IO_H
14 #include "orion5x.h"
16 #define IO_SPACE_LIMIT 0xffffffff
17 #define IO_SPACE_REMAP ORION5X_PCI_SYS_IO_BASE
19 static inline void __iomem *
20 __arch_ioremap(unsigned long paddr, size_t size, unsigned int mtype)
22 void __iomem *retval;
23 unsigned long offs = paddr - ORION5X_REGS_PHYS_BASE;
24 if (mtype == MT_DEVICE && size && offs < ORION5X_REGS_SIZE &&
25 size <= ORION5X_REGS_SIZE && offs + size <= ORION5X_REGS_SIZE) {
26 retval = (void __iomem *)ORION5X_REGS_VIRT_BASE + offs;
27 } else {
28 retval = __arm_ioremap(paddr, size, mtype);
31 return retval;
34 static inline void
35 __arch_iounmap(void __iomem *addr)
37 if (addr < (void __iomem *)ORION5X_REGS_VIRT_BASE ||
38 addr >= (void __iomem *)(ORION5X_REGS_VIRT_BASE + ORION5X_REGS_SIZE))
39 __iounmap(addr);
42 static inline void __iomem *__io(unsigned long addr)
44 return (void __iomem *)addr;
47 #define __arch_ioremap(p, s, m) __arch_ioremap(p, s, m)
48 #define __arch_iounmap(a) __arch_iounmap(a)
49 #define __io(a) __io(a)
50 #define __mem_pci(a) (a)
53 /*****************************************************************************
54 * Helpers to access Orion registers
55 ****************************************************************************/
56 #define orion5x_read(r) __raw_readl(r)
57 #define orion5x_write(r, val) __raw_writel(val, r)
60 * These are not preempt-safe. Locks, if needed, must be taken
61 * care of by the caller.
63 #define orion5x_setbits(r, mask) orion5x_write((r), orion5x_read(r) | (mask))
64 #define orion5x_clrbits(r, mask) orion5x_write((r), orion5x_read(r) & ~(mask))
67 #endif