aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2011-05-07 14:58:02 -0400
committerGeert Uytterhoeven <geert@linux-m68k.org>2011-07-30 15:21:39 -0400
commita0e997c20a2fbe25b0f97fb7521cdbda341c7f0a (patch)
tree9e9f1d329145328a47a7f30215c072e4e2939123 /arch/sparc/kernel
parent217bbd81885587b462311fab1b04172926c59f1e (diff)
sparc: iounmap() and *_free_coherent() - Use lookup_resource()
Replace a custom implementation (which doesn't lock the resource tree) by a call to lookup_resource() Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel')
-rw-r--r--arch/sparc/kernel/ioport.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index b5e83beb5b6b..92700c1650c7 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -65,9 +65,6 @@ static inline void dma_make_coherent(unsigned long pa, unsigned long len)
65} 65}
66#endif 66#endif
67 67
68static struct resource *_sparc_find_resource(struct resource *r,
69 unsigned long);
70
71static void __iomem *_sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz); 68static void __iomem *_sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz);
72static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys, 69static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys,
73 unsigned long size, char *name); 70 unsigned long size, char *name);
@@ -143,7 +140,11 @@ void iounmap(volatile void __iomem *virtual)
143 unsigned long vaddr = (unsigned long) virtual & PAGE_MASK; 140 unsigned long vaddr = (unsigned long) virtual & PAGE_MASK;
144 struct resource *res; 141 struct resource *res;
145 142
146 if ((res = _sparc_find_resource(&sparc_iomap, vaddr)) == NULL) { 143 /*
144 * XXX Too slow. Can have 8192 DVMA pages on sun4m in the worst case.
145 * This probably warrants some sort of hashing.
146 */
147 if ((res = lookup_resource(&sparc_iomap, vaddr)) == NULL) {
147 printk("free_io/iounmap: cannot free %lx\n", vaddr); 148 printk("free_io/iounmap: cannot free %lx\n", vaddr);
148 return; 149 return;
149 } 150 }
@@ -319,7 +320,7 @@ static void sbus_free_coherent(struct device *dev, size_t n, void *p,
319 struct resource *res; 320 struct resource *res;
320 struct page *pgv; 321 struct page *pgv;
321 322
322 if ((res = _sparc_find_resource(&_sparc_dvma, 323 if ((res = lookup_resource(&_sparc_dvma,
323 (unsigned long)p)) == NULL) { 324 (unsigned long)p)) == NULL) {
324 printk("sbus_free_consistent: cannot free %p\n", p); 325 printk("sbus_free_consistent: cannot free %p\n", p);
325 return; 326 return;
@@ -492,7 +493,7 @@ static void pci32_free_coherent(struct device *dev, size_t n, void *p,
492{ 493{
493 struct resource *res; 494 struct resource *res;
494 495
495 if ((res = _sparc_find_resource(&_sparc_dvma, 496 if ((res = lookup_resource(&_sparc_dvma,
496 (unsigned long)p)) == NULL) { 497 (unsigned long)p)) == NULL) {
497 printk("pci_free_consistent: cannot free %p\n", p); 498 printk("pci_free_consistent: cannot free %p\n", p);
498 return; 499 return;
@@ -715,25 +716,6 @@ static const struct file_operations sparc_io_proc_fops = {
715}; 716};
716#endif /* CONFIG_PROC_FS */ 717#endif /* CONFIG_PROC_FS */
717 718
718/*
719 * This is a version of find_resource and it belongs to kernel/resource.c.
720 * Until we have agreement with Linus and Martin, it lingers here.
721 *
722 * XXX Too slow. Can have 8192 DVMA pages on sun4m in the worst case.
723 * This probably warrants some sort of hashing.
724 */
725static struct resource *_sparc_find_resource(struct resource *root,
726 unsigned long start)
727{
728 struct resource *tmp;
729
730 for (tmp = root->child; tmp != 0; tmp = tmp->sibling) {
731 if (tmp->start == start)
732 return tmp;
733 }
734 return NULL;
735}
736
737static void register_proc_sparc_ioport(void) 719static void register_proc_sparc_ioport(void)
738{ 720{
739#ifdef CONFIG_PROC_FS 721#ifdef CONFIG_PROC_FS