diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2009-02-06 16:29:44 -0500 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy@goop.org> | 2009-02-06 16:29:44 -0500 |
commit | 976e8f677e42757e5586ea04a9ac8bb8ddaa037e (patch) | |
tree | addb2267fe1267f506117dac15e0bc1843bf72fe /arch/x86 | |
parent | 26c8e3179933c5c9071b16db76ab6de58a787d06 (diff) |
x86: asm/io.h: unify virt_to_phys/phys_to_virt
Impact: unify identical code
asm/io_32.h and _64.h has functionally identical definitions for
virt_to_phys, phys_to_virt, page_to_phys, and the isa_* variants, so
just unify them.
The only slightly functional change is using phys_addr_t for the
physical address argument and return val.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/io.h | 59 | ||||
-rw-r--r-- | arch/x86/include/asm/io_32.h | 57 | ||||
-rw-r--r-- | arch/x86/include/asm/io_64.h | 37 |
3 files changed, 59 insertions, 94 deletions
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 1dbbdf4be9b4..919e3b19f3ca 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | #include <linux/compiler.h> | 6 | #include <linux/compiler.h> |
7 | #include <asm-generic/int-ll64.h> | 7 | #include <asm-generic/int-ll64.h> |
8 | #include <asm/page.h> | ||
8 | 9 | ||
9 | #define build_mmio_read(name, size, type, reg, barrier) \ | 10 | #define build_mmio_read(name, size, type, reg, barrier) \ |
10 | static inline type name(const volatile void __iomem *addr) \ | 11 | static inline type name(const volatile void __iomem *addr) \ |
@@ -80,6 +81,64 @@ static inline void writeq(__u64 val, volatile void __iomem *addr) | |||
80 | #define readq readq | 81 | #define readq readq |
81 | #define writeq writeq | 82 | #define writeq writeq |
82 | 83 | ||
84 | /** | ||
85 | * virt_to_phys - map virtual addresses to physical | ||
86 | * @address: address to remap | ||
87 | * | ||
88 | * The returned physical address is the physical (CPU) mapping for | ||
89 | * the memory address given. It is only valid to use this function on | ||
90 | * addresses directly mapped or allocated via kmalloc. | ||
91 | * | ||
92 | * This function does not give bus mappings for DMA transfers. In | ||
93 | * almost all conceivable cases a device driver should not be using | ||
94 | * this function | ||
95 | */ | ||
96 | |||
97 | static inline phys_addr_t virt_to_phys(volatile void *address) | ||
98 | { | ||
99 | return __pa(address); | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * phys_to_virt - map physical address to virtual | ||
104 | * @address: address to remap | ||
105 | * | ||
106 | * The returned virtual address is a current CPU mapping for | ||
107 | * the memory address given. It is only valid to use this function on | ||
108 | * addresses that have a kernel mapping | ||
109 | * | ||
110 | * This function does not handle bus mappings for DMA transfers. In | ||
111 | * almost all conceivable cases a device driver should not be using | ||
112 | * this function | ||
113 | */ | ||
114 | |||
115 | static inline void *phys_to_virt(phys_addr_t address) | ||
116 | { | ||
117 | return __va(address); | ||
118 | } | ||
119 | |||
120 | /* | ||
121 | * Change "struct page" to physical address. | ||
122 | */ | ||
123 | #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) | ||
124 | |||
125 | /* | ||
126 | * ISA I/O bus memory addresses are 1:1 with the physical address. | ||
127 | */ | ||
128 | #define isa_virt_to_bus virt_to_phys | ||
129 | #define isa_page_to_bus page_to_phys | ||
130 | #define isa_bus_to_virt phys_to_virt | ||
131 | |||
132 | /* | ||
133 | * However PCI ones are not necessarily 1:1 and therefore these interfaces | ||
134 | * are forbidden in portable PCI drivers. | ||
135 | * | ||
136 | * Allow them on x86 for legacy drivers, though. | ||
137 | */ | ||
138 | #define virt_to_bus virt_to_phys | ||
139 | #define bus_to_virt phys_to_virt | ||
140 | |||
141 | |||
83 | #ifdef CONFIG_X86_32 | 142 | #ifdef CONFIG_X86_32 |
84 | # include "io_32.h" | 143 | # include "io_32.h" |
85 | #else | 144 | #else |
diff --git a/arch/x86/include/asm/io_32.h b/arch/x86/include/asm/io_32.h index d8e242e1b396..2b687cb86093 100644 --- a/arch/x86/include/asm/io_32.h +++ b/arch/x86/include/asm/io_32.h | |||
@@ -54,47 +54,6 @@ | |||
54 | #define xlate_dev_kmem_ptr(p) p | 54 | #define xlate_dev_kmem_ptr(p) p |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * virt_to_phys - map virtual addresses to physical | ||
58 | * @address: address to remap | ||
59 | * | ||
60 | * The returned physical address is the physical (CPU) mapping for | ||
61 | * the memory address given. It is only valid to use this function on | ||
62 | * addresses directly mapped or allocated via kmalloc. | ||
63 | * | ||
64 | * This function does not give bus mappings for DMA transfers. In | ||
65 | * almost all conceivable cases a device driver should not be using | ||
66 | * this function | ||
67 | */ | ||
68 | |||
69 | static inline unsigned long virt_to_phys(volatile void *address) | ||
70 | { | ||
71 | return __pa(address); | ||
72 | } | ||
73 | |||
74 | /** | ||
75 | * phys_to_virt - map physical address to virtual | ||
76 | * @address: address to remap | ||
77 | * | ||
78 | * The returned virtual address is a current CPU mapping for | ||
79 | * the memory address given. It is only valid to use this function on | ||
80 | * addresses that have a kernel mapping | ||
81 | * | ||
82 | * This function does not handle bus mappings for DMA transfers. In | ||
83 | * almost all conceivable cases a device driver should not be using | ||
84 | * this function | ||
85 | */ | ||
86 | |||
87 | static inline void *phys_to_virt(unsigned long address) | ||
88 | { | ||
89 | return __va(address); | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | * Change "struct page" to physical address. | ||
94 | */ | ||
95 | #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) | ||
96 | |||
97 | /** | ||
98 | * ioremap - map bus memory into CPU space | 57 | * ioremap - map bus memory into CPU space |
99 | * @offset: bus address of the memory | 58 | * @offset: bus address of the memory |
100 | * @size: size of the resource to map | 59 | * @size: size of the resource to map |
@@ -123,22 +82,6 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size) | |||
123 | 82 | ||
124 | extern void iounmap(volatile void __iomem *addr); | 83 | extern void iounmap(volatile void __iomem *addr); |
125 | 84 | ||
126 | /* | ||
127 | * ISA I/O bus memory addresses are 1:1 with the physical address. | ||
128 | */ | ||
129 | #define isa_virt_to_bus virt_to_phys | ||
130 | #define isa_page_to_bus page_to_phys | ||
131 | #define isa_bus_to_virt phys_to_virt | ||
132 | |||
133 | /* | ||
134 | * However PCI ones are not necessarily 1:1 and therefore these interfaces | ||
135 | * are forbidden in portable PCI drivers. | ||
136 | * | ||
137 | * Allow them on x86 for legacy drivers, though. | ||
138 | */ | ||
139 | #define virt_to_bus virt_to_phys | ||
140 | #define bus_to_virt phys_to_virt | ||
141 | |||
142 | static inline void | 85 | static inline void |
143 | memset_io(volatile void __iomem *addr, unsigned char val, int count) | 86 | memset_io(volatile void __iomem *addr, unsigned char val, int count) |
144 | { | 87 | { |
diff --git a/arch/x86/include/asm/io_64.h b/arch/x86/include/asm/io_64.h index 563c16270ba6..e71b55508775 100644 --- a/arch/x86/include/asm/io_64.h +++ b/arch/x86/include/asm/io_64.h | |||
@@ -142,27 +142,6 @@ __OUTS(l) | |||
142 | 142 | ||
143 | #include <linux/vmalloc.h> | 143 | #include <linux/vmalloc.h> |
144 | 144 | ||
145 | #ifndef __i386__ | ||
146 | /* | ||
147 | * Change virtual addresses to physical addresses and vv. | ||
148 | * These are pretty trivial | ||
149 | */ | ||
150 | static inline unsigned long virt_to_phys(volatile void *address) | ||
151 | { | ||
152 | return __pa(address); | ||
153 | } | ||
154 | |||
155 | static inline void *phys_to_virt(unsigned long address) | ||
156 | { | ||
157 | return __va(address); | ||
158 | } | ||
159 | #endif | ||
160 | |||
161 | /* | ||
162 | * Change "struct page" to physical address. | ||
163 | */ | ||
164 | #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) | ||
165 | |||
166 | #include <asm-generic/iomap.h> | 145 | #include <asm-generic/iomap.h> |
167 | 146 | ||
168 | /* | 147 | /* |
@@ -187,22 +166,6 @@ extern void iounmap(volatile void __iomem *addr); | |||
187 | 166 | ||
188 | extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); | 167 | extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); |
189 | 168 | ||
190 | /* | ||
191 | * ISA I/O bus memory addresses are 1:1 with the physical address. | ||
192 | */ | ||
193 | #define isa_virt_to_bus virt_to_phys | ||
194 | #define isa_page_to_bus page_to_phys | ||
195 | #define isa_bus_to_virt phys_to_virt | ||
196 | |||
197 | /* | ||
198 | * However PCI ones are not necessarily 1:1 and therefore these interfaces | ||
199 | * are forbidden in portable PCI drivers. | ||
200 | * | ||
201 | * Allow them on x86 for legacy drivers, though. | ||
202 | */ | ||
203 | #define virt_to_bus virt_to_phys | ||
204 | #define bus_to_virt phys_to_virt | ||
205 | |||
206 | void __memcpy_fromio(void *, unsigned long, unsigned); | 169 | void __memcpy_fromio(void *, unsigned long, unsigned); |
207 | void __memcpy_toio(unsigned long, const void *, unsigned); | 170 | void __memcpy_toio(unsigned long, const void *, unsigned); |
208 | 171 | ||