aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2010-03-10 18:23:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-12 18:52:42 -0500
commit349004294c365cb99a0ee84149286d6f29b1e6b9 (patch)
tree0e131233812fd3f93827b0a5076ab532142ae0a7 /arch/sparc
parent06db881b4f1b5fb8fff563423f76b7361de8281a (diff)
dma-mapping: sparc: unify 32bit and 64bit dma_set_mask
This patchset transforms the PCI DMA API into the generic device model. It's one of the reasons why we introduced the generic DMA API long ago; driver writers are always able to use the generic DMA API with any bus instead of using bus specific DMA APIs such as pci_map_single, sbus_map_single, etc (only two bus specific APIs exist now; pci and ssb). Some of the PCI DMA API are already implented on the top of the generic DMA API (include/asm-generic/pci-dma-compat.h). But there are some exceptions. This patchset finishes the transformation. This patch: sparc has two dma_set_mask implementations for 32bit and 64bit. They are same except for the error returned value. We can safely unify them since the error returned value doesn't matter as long as it is negative (as DMA-API.txt describes). This patch also changes dma_set_mask not to call pci_set_dma_mask. Instead, dma_set_mask does the same thing that pci_set_dma_mask does. This change enables ut to change pci_set_dma_mask to call dma_set_mask; we can implement pci_set_dma_mask as pci-dma-compat.h does. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: David Miller <davem@davemloft.net> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Matt Turner <mattst88@gmail.com> Cc: James Bottomley <James.Bottomley@suse.de> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Russell King <linux@arm.linux.org.uk> Cc: Greg KH <greg@kroah.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/include/asm/dma-mapping.h14
-rw-r--r--arch/sparc/kernel/iommu.c10
-rw-r--r--arch/sparc/kernel/ioport.c11
3 files changed, 13 insertions, 22 deletions
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 5a8c308e2b5c..4b4a0c0b0ccd 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -8,7 +8,6 @@
8#define DMA_ERROR_CODE (~(dma_addr_t)0x0) 8#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
9 9
10extern int dma_supported(struct device *dev, u64 mask); 10extern int dma_supported(struct device *dev, u64 mask);
11extern int dma_set_mask(struct device *dev, u64 dma_mask);
12 11
13#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 12#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
14#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 13#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
@@ -62,4 +61,17 @@ static inline int dma_get_cache_alignment(void)
62 return (1 << INTERNODE_CACHE_SHIFT); 61 return (1 << INTERNODE_CACHE_SHIFT);
63} 62}
64 63
64static inline int dma_set_mask(struct device *dev, u64 mask)
65{
66#ifdef CONFIG_PCI
67 if (dev->bus == &pci_bus_type) {
68 if (!dev->dma_mask || !dma_supported(dev, mask))
69 return -EINVAL;
70 *dev->dma_mask = mask;
71 return 0;
72 }
73#endif
74 return -EINVAL;
75}
76
65#endif 77#endif
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 5fad94950e76..8414549c1834 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -862,13 +862,3 @@ int dma_supported(struct device *dev, u64 device_mask)
862 return 0; 862 return 0;
863} 863}
864EXPORT_SYMBOL(dma_supported); 864EXPORT_SYMBOL(dma_supported);
865
866int dma_set_mask(struct device *dev, u64 dma_mask)
867{
868#ifdef CONFIG_PCI
869 if (dev->bus == &pci_bus_type)
870 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
871#endif
872 return -EINVAL;
873}
874EXPORT_SYMBOL(dma_set_mask);
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 3c8c44f6a41c..84e5386714cd 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -676,17 +676,6 @@ int dma_supported(struct device *dev, u64 mask)
676} 676}
677EXPORT_SYMBOL(dma_supported); 677EXPORT_SYMBOL(dma_supported);
678 678
679int dma_set_mask(struct device *dev, u64 dma_mask)
680{
681#ifdef CONFIG_PCI
682 if (dev->bus == &pci_bus_type)
683 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
684#endif
685 return -EOPNOTSUPP;
686}
687EXPORT_SYMBOL(dma_set_mask);
688
689
690#ifdef CONFIG_PROC_FS 679#ifdef CONFIG_PROC_FS
691 680
692static int sparc_io_proc_show(struct seq_file *m, void *v) 681static int sparc_io_proc_show(struct seq_file *m, void *v)