[PATCH] briq_panel: read() and write() get __user pointers, damnit
[linux-2.6/verdex.git] / arch / powerpc / kernel / iomap.c
bloba13a93dfc65539e7a70ef75baab047bcb250e277
1 /*
2 * ppc64 "iomap" interface implementation.
4 * (C) Copyright 2004 Linus Torvalds
5 */
6 #include <linux/init.h>
7 #include <linux/pci.h>
8 #include <linux/mm.h>
9 #include <asm/io.h>
12 * Here comes the ppc64 implementation of the IOMAP
13 * interfaces.
15 unsigned int fastcall ioread8(void __iomem *addr)
17 return readb(addr);
19 unsigned int fastcall ioread16(void __iomem *addr)
21 return readw(addr);
23 unsigned int fastcall ioread16be(void __iomem *addr)
25 return in_be16(addr);
27 unsigned int fastcall ioread32(void __iomem *addr)
29 return readl(addr);
31 unsigned int fastcall ioread32be(void __iomem *addr)
33 return in_be32(addr);
35 EXPORT_SYMBOL(ioread8);
36 EXPORT_SYMBOL(ioread16);
37 EXPORT_SYMBOL(ioread16be);
38 EXPORT_SYMBOL(ioread32);
39 EXPORT_SYMBOL(ioread32be);
41 void fastcall iowrite8(u8 val, void __iomem *addr)
43 writeb(val, addr);
45 void fastcall iowrite16(u16 val, void __iomem *addr)
47 writew(val, addr);
49 void fastcall iowrite16be(u16 val, void __iomem *addr)
51 out_be16(addr, val);
53 void fastcall iowrite32(u32 val, void __iomem *addr)
55 writel(val, addr);
57 void fastcall iowrite32be(u32 val, void __iomem *addr)
59 out_be32(addr, val);
61 EXPORT_SYMBOL(iowrite8);
62 EXPORT_SYMBOL(iowrite16);
63 EXPORT_SYMBOL(iowrite16be);
64 EXPORT_SYMBOL(iowrite32);
65 EXPORT_SYMBOL(iowrite32be);
68 * These are the "repeat read/write" functions. Note the
69 * non-CPU byte order. We do things in "IO byteorder"
70 * here.
72 * FIXME! We could make these do EEH handling if we really
73 * wanted. Not clear if we do.
75 void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
77 _insb((u8 __iomem *) addr, dst, count);
79 void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
81 _insw_ns((u16 __iomem *) addr, dst, count);
83 void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
85 _insl_ns((u32 __iomem *) addr, dst, count);
87 EXPORT_SYMBOL(ioread8_rep);
88 EXPORT_SYMBOL(ioread16_rep);
89 EXPORT_SYMBOL(ioread32_rep);
91 void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
93 _outsb((u8 __iomem *) addr, src, count);
95 void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
97 _outsw_ns((u16 __iomem *) addr, src, count);
99 void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
101 _outsl_ns((u32 __iomem *) addr, src, count);
103 EXPORT_SYMBOL(iowrite8_rep);
104 EXPORT_SYMBOL(iowrite16_rep);
105 EXPORT_SYMBOL(iowrite32_rep);
107 void __iomem *ioport_map(unsigned long port, unsigned int len)
109 return (void __iomem *) (port+pci_io_base);
112 void ioport_unmap(void __iomem *addr)
114 /* Nothing to do */
116 EXPORT_SYMBOL(ioport_map);
117 EXPORT_SYMBOL(ioport_unmap);
119 void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
121 unsigned long start = pci_resource_start(dev, bar);
122 unsigned long len = pci_resource_len(dev, bar);
123 unsigned long flags = pci_resource_flags(dev, bar);
125 if (!len)
126 return NULL;
127 if (max && len > max)
128 len = max;
129 if (flags & IORESOURCE_IO)
130 return ioport_map(start, len);
131 if (flags & IORESOURCE_MEM)
132 return ioremap(start, len);
133 /* What? */
134 return NULL;
137 void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
139 /* Nothing to do */
141 EXPORT_SYMBOL(pci_iomap);
142 EXPORT_SYMBOL(pci_iounmap);