Эх сурвалжийг харах

treewide: Consolidate get_dma_ops() implementations

Introduce a new architecture-specific get_arch_dma_ops() function
that takes a struct bus_type * argument. Add get_dma_ops() in
<linux/dma-mapping.h>.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Russell King <linux@armlinux.org.uk>
Cc: x86@kernel.org
Signed-off-by: Doug Ledford <dledford@redhat.com>
Bart Van Assche 8 жил өмнө
parent
commit
815dd18788
31 өөрчлөгдсөн 48 нэмэгдсэн , 64 устгасан
  1. 1 1
      arch/alpha/include/asm/dma-mapping.h
  2. 1 1
      arch/arc/include/asm/dma-mapping.h
  3. 2 2
      arch/arm/include/asm/dma-mapping.h
  4. 2 2
      arch/arm64/include/asm/dma-mapping.h
  5. 1 1
      arch/avr32/include/asm/dma-mapping.h
  6. 1 1
      arch/blackfin/include/asm/dma-mapping.h
  7. 1 1
      arch/c6x/include/asm/dma-mapping.h
  8. 2 2
      arch/cris/include/asm/dma-mapping.h
  9. 1 1
      arch/frv/include/asm/dma-mapping.h
  10. 1 1
      arch/h8300/include/asm/dma-mapping.h
  11. 1 4
      arch/hexagon/include/asm/dma-mapping.h
  12. 4 1
      arch/ia64/include/asm/dma-mapping.h
  13. 1 3
      arch/m32r/include/asm/dma-mapping.h
  14. 1 1
      arch/m68k/include/asm/dma-mapping.h
  15. 1 1
      arch/metag/include/asm/dma-mapping.h
  16. 1 1
      arch/microblaze/include/asm/dma-mapping.h
  17. 2 5
      arch/mips/include/asm/dma-mapping.h
  18. 1 1
      arch/mn10300/include/asm/dma-mapping.h
  19. 1 1
      arch/nios2/include/asm/dma-mapping.h
  20. 1 1
      arch/openrisc/include/asm/dma-mapping.h
  21. 1 1
      arch/parisc/include/asm/dma-mapping.h
  22. 2 5
      arch/powerpc/include/asm/dma-mapping.h
  23. 1 1
      arch/powerpc/include/asm/ps3.h
  24. 1 3
      arch/s390/include/asm/dma-mapping.h
  25. 1 1
      arch/sh/include/asm/dma-mapping.h
  26. 2 2
      arch/sparc/include/asm/dma-mapping.h
  27. 2 5
      arch/tile/include/asm/dma-mapping.h
  28. 1 1
      arch/unicore32/include/asm/dma-mapping.h
  29. 1 8
      arch/x86/include/asm/dma-mapping.h
  30. 2 5
      arch/xtensa/include/asm/dma-mapping.h
  31. 7 0
      include/linux/dma-mapping.h

+ 1 - 1
arch/alpha/include/asm/dma-mapping.h

@@ -3,7 +3,7 @@
 
 
 extern const struct dma_map_ops *dma_ops;
 extern const struct dma_map_ops *dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return dma_ops;
 	return dma_ops;
 }
 }

+ 1 - 1
arch/arc/include/asm/dma-mapping.h

@@ -20,7 +20,7 @@
 
 
 extern const struct dma_map_ops arc_dma_ops;
 extern const struct dma_map_ops arc_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &arc_dma_ops;
 	return &arc_dma_ops;
 }
 }

+ 2 - 2
arch/arm/include/asm/dma-mapping.h

@@ -23,12 +23,12 @@ static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
 	return &arm_dma_ops;
 	return &arm_dma_ops;
 }
 }
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	if (xen_initial_domain())
 	if (xen_initial_domain())
 		return xen_dma_ops;
 		return xen_dma_ops;
 	else
 	else
-		return __generic_dma_ops(dev);
+		return __generic_dma_ops(NULL);
 }
 }
 
 
 #define HAVE_ARCH_DMA_SUPPORTED 1
 #define HAVE_ARCH_DMA_SUPPORTED 1

+ 2 - 2
arch/arm64/include/asm/dma-mapping.h

@@ -39,12 +39,12 @@ static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
 	return &dummy_dma_ops;
 	return &dummy_dma_ops;
 }
 }
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	if (xen_initial_domain())
 	if (xen_initial_domain())
 		return xen_dma_ops;
 		return xen_dma_ops;
 	else
 	else
-		return __generic_dma_ops(dev);
+		return __generic_dma_ops(NULL);
 }
 }
 
 
 void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
 void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,

+ 1 - 1
arch/avr32/include/asm/dma-mapping.h

@@ -6,7 +6,7 @@ extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 
 
 extern const struct dma_map_ops avr32_dma_ops;
 extern const struct dma_map_ops avr32_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &avr32_dma_ops;
 	return &avr32_dma_ops;
 }
 }

+ 1 - 1
arch/blackfin/include/asm/dma-mapping.h

@@ -38,7 +38,7 @@ _dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir)
 
 
 extern const struct dma_map_ops bfin_dma_ops;
 extern const struct dma_map_ops bfin_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &bfin_dma_ops;
 	return &bfin_dma_ops;
 }
 }

+ 1 - 1
arch/c6x/include/asm/dma-mapping.h

@@ -19,7 +19,7 @@
 
 
 extern const struct dma_map_ops c6x_dma_ops;
 extern const struct dma_map_ops c6x_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &c6x_dma_ops;
 	return &c6x_dma_ops;
 }
 }

+ 2 - 2
arch/cris/include/asm/dma-mapping.h

@@ -4,12 +4,12 @@
 #ifdef CONFIG_PCI
 #ifdef CONFIG_PCI
 extern const struct dma_map_ops v32_dma_ops;
 extern const struct dma_map_ops v32_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &v32_dma_ops;
 	return &v32_dma_ops;
 }
 }
 #else
 #else
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	BUG();
 	BUG();
 	return NULL;
 	return NULL;

+ 1 - 1
arch/frv/include/asm/dma-mapping.h

@@ -9,7 +9,7 @@ extern unsigned long __nongprelbss dma_coherent_mem_end;
 
 
 extern const struct dma_map_ops frv_dma_ops;
 extern const struct dma_map_ops frv_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &frv_dma_ops;
 	return &frv_dma_ops;
 }
 }

+ 1 - 1
arch/h8300/include/asm/dma-mapping.h

@@ -3,7 +3,7 @@
 
 
 extern const struct dma_map_ops h8300_dma_map_ops;
 extern const struct dma_map_ops h8300_dma_map_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &h8300_dma_map_ops;
 	return &h8300_dma_map_ops;
 }
 }

+ 1 - 4
arch/hexagon/include/asm/dma-mapping.h

@@ -34,11 +34,8 @@ extern int bad_dma_address;
 
 
 extern const struct dma_map_ops *dma_ops;
 extern const struct dma_map_ops *dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
-	if (unlikely(dev == NULL))
-		return NULL;
-
 	return dma_ops;
 	return dma_ops;
 }
 }
 
 

+ 4 - 1
arch/ia64/include/asm/dma-mapping.h

@@ -23,7 +23,10 @@ extern void machvec_dma_sync_single(struct device *, dma_addr_t, size_t,
 extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int,
 extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int,
 				enum dma_data_direction);
 				enum dma_data_direction);
 
 
-#define get_dma_ops(dev) platform_dma_get_ops(dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
+{
+	return platform_dma_get_ops(NULL);
+}
 
 
 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
 {
 {

+ 1 - 3
arch/m32r/include/asm/dma-mapping.h

@@ -10,10 +10,8 @@
 
 
 #define DMA_ERROR_CODE (~(dma_addr_t)0x0)
 #define DMA_ERROR_CODE (~(dma_addr_t)0x0)
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
-	if (dev && dev->dma_ops)
-		return dev->dma_ops;
 	return &dma_noop_ops;
 	return &dma_noop_ops;
 }
 }
 
 

+ 1 - 1
arch/m68k/include/asm/dma-mapping.h

@@ -3,7 +3,7 @@
 
 
 extern const struct dma_map_ops m68k_dma_ops;
 extern const struct dma_map_ops m68k_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
         return &m68k_dma_ops;
         return &m68k_dma_ops;
 }
 }

+ 1 - 1
arch/metag/include/asm/dma-mapping.h

@@ -3,7 +3,7 @@
 
 
 extern const struct dma_map_ops metag_dma_ops;
 extern const struct dma_map_ops metag_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &metag_dma_ops;
 	return &metag_dma_ops;
 }
 }

+ 1 - 1
arch/microblaze/include/asm/dma-mapping.h

@@ -38,7 +38,7 @@
  */
  */
 extern const struct dma_map_ops dma_direct_ops;
 extern const struct dma_map_ops dma_direct_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &dma_direct_ops;
 	return &dma_direct_ops;
 }
 }

+ 2 - 5
arch/mips/include/asm/dma-mapping.h

@@ -11,12 +11,9 @@
 
 
 extern const struct dma_map_ops *mips_dma_map_ops;
 extern const struct dma_map_ops *mips_dma_map_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
-	if (dev && dev->dma_ops)
-		return dev->dma_ops;
-	else
-		return mips_dma_map_ops;
+	return mips_dma_map_ops;
 }
 }
 
 
 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)

+ 1 - 1
arch/mn10300/include/asm/dma-mapping.h

@@ -16,7 +16,7 @@
 
 
 extern const struct dma_map_ops mn10300_dma_ops;
 extern const struct dma_map_ops mn10300_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &mn10300_dma_ops;
 	return &mn10300_dma_ops;
 }
 }

+ 1 - 1
arch/nios2/include/asm/dma-mapping.h

@@ -12,7 +12,7 @@
 
 
 extern const struct dma_map_ops nios2_dma_ops;
 extern const struct dma_map_ops nios2_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &nios2_dma_ops;
 	return &nios2_dma_ops;
 }
 }

+ 1 - 1
arch/openrisc/include/asm/dma-mapping.h

@@ -30,7 +30,7 @@
 
 
 extern const struct dma_map_ops or1k_dma_map_ops;
 extern const struct dma_map_ops or1k_dma_map_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &or1k_dma_map_ops;
 	return &or1k_dma_map_ops;
 }
 }

+ 1 - 1
arch/parisc/include/asm/dma-mapping.h

@@ -27,7 +27,7 @@ extern const struct dma_map_ops pcx_dma_ops;
 
 
 extern const struct dma_map_ops *hppa_dma_ops;
 extern const struct dma_map_ops *hppa_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return hppa_dma_ops;
 	return hppa_dma_ops;
 }
 }

+ 2 - 5
arch/powerpc/include/asm/dma-mapping.h

@@ -78,17 +78,14 @@ extern struct dma_map_ops dma_iommu_ops;
 #endif
 #endif
 extern const struct dma_map_ops dma_direct_ops;
 extern const struct dma_map_ops dma_direct_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	/* We don't handle the NULL dev case for ISA for now. We could
 	/* We don't handle the NULL dev case for ISA for now. We could
 	 * do it via an out of line call but it is not needed for now. The
 	 * do it via an out of line call but it is not needed for now. The
 	 * only ISA DMA device we support is the floppy and we have a hack
 	 * only ISA DMA device we support is the floppy and we have a hack
 	 * in the floppy driver directly to get a device for us.
 	 * in the floppy driver directly to get a device for us.
 	 */
 	 */
-	if (unlikely(dev == NULL))
-		return NULL;
-
-	return dev->dma_ops;
+	return NULL;
 }
 }
 
 
 /*
 /*

+ 1 - 1
arch/powerpc/include/asm/ps3.h

@@ -435,7 +435,7 @@ static inline void *ps3_system_bus_get_drvdata(
 	return dev_get_drvdata(&dev->core);
 	return dev_get_drvdata(&dev->core);
 }
 }
 
 
-/* These two need global scope for get_dma_ops(). */
+/* These two need global scope for get_arch_dma_ops(). */
 
 
 extern struct bus_type ps3_system_bus_type;
 extern struct bus_type ps3_system_bus_type;
 
 

+ 1 - 3
arch/s390/include/asm/dma-mapping.h

@@ -12,10 +12,8 @@
 
 
 extern const struct dma_map_ops s390_pci_dma_ops;
 extern const struct dma_map_ops s390_pci_dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
-	if (dev && dev->dma_ops)
-		return dev->dma_ops;
 	return &dma_noop_ops;
 	return &dma_noop_ops;
 }
 }
 
 

+ 1 - 1
arch/sh/include/asm/dma-mapping.h

@@ -4,7 +4,7 @@
 extern const struct dma_map_ops *dma_ops;
 extern const struct dma_map_ops *dma_ops;
 extern void no_iommu_init(void);
 extern void no_iommu_init(void);
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return dma_ops;
 	return dma_ops;
 }
 }

+ 2 - 2
arch/sparc/include/asm/dma-mapping.h

@@ -24,14 +24,14 @@ extern const struct dma_map_ops pci32_dma_ops;
 
 
 extern struct bus_type pci_bus_type;
 extern struct bus_type pci_bus_type;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 #ifdef CONFIG_SPARC_LEON
 #ifdef CONFIG_SPARC_LEON
 	if (sparc_cpu_model == sparc_leon)
 	if (sparc_cpu_model == sparc_leon)
 		return leon_dma_ops;
 		return leon_dma_ops;
 #endif
 #endif
 #if defined(CONFIG_SPARC32) && defined(CONFIG_PCI)
 #if defined(CONFIG_SPARC32) && defined(CONFIG_PCI)
-	if (dev->bus == &pci_bus_type)
+	if (bus == &pci_bus_type)
 		return &pci32_dma_ops;
 		return &pci32_dma_ops;
 #endif
 #endif
 	return dma_ops;
 	return dma_ops;

+ 2 - 5
arch/tile/include/asm/dma-mapping.h

@@ -29,12 +29,9 @@ extern const struct dma_map_ops *gx_pci_dma_map_ops;
 extern const struct dma_map_ops *gx_legacy_pci_dma_map_ops;
 extern const struct dma_map_ops *gx_legacy_pci_dma_map_ops;
 extern const struct dma_map_ops *gx_hybrid_pci_dma_map_ops;
 extern const struct dma_map_ops *gx_hybrid_pci_dma_map_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
-	if (dev && dev->dma_ops)
-		return dev->dma_ops;
-	else
-		return tile_dma_map_ops;
+	return tile_dma_map_ops;
 }
 }
 
 
 static inline dma_addr_t get_dma_offset(struct device *dev)
 static inline dma_addr_t get_dma_offset(struct device *dev)

+ 1 - 1
arch/unicore32/include/asm/dma-mapping.h

@@ -23,7 +23,7 @@
 
 
 extern const struct dma_map_ops swiotlb_dma_map_ops;
 extern const struct dma_map_ops swiotlb_dma_map_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
 	return &swiotlb_dma_map_ops;
 	return &swiotlb_dma_map_ops;
 }
 }

+ 1 - 8
arch/x86/include/asm/dma-mapping.h

@@ -27,16 +27,9 @@ extern int panic_on_overflow;
 
 
 extern const struct dma_map_ops *dma_ops;
 extern const struct dma_map_ops *dma_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
-#ifndef CONFIG_X86_DEV_DMA_OPS
 	return dma_ops;
 	return dma_ops;
-#else
-	if (unlikely(!dev) || !dev->dma_ops)
-		return dma_ops;
-	else
-		return dev->dma_ops;
-#endif
 }
 }
 
 
 bool arch_dma_alloc_attrs(struct device **dev, gfp_t *gfp);
 bool arch_dma_alloc_attrs(struct device **dev, gfp_t *gfp);

+ 2 - 5
arch/xtensa/include/asm/dma-mapping.h

@@ -20,12 +20,9 @@
 
 
 extern const struct dma_map_ops xtensa_dma_map_ops;
 extern const struct dma_map_ops xtensa_dma_map_ops;
 
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 {
-	if (dev && dev->dma_ops)
-		return dev->dma_ops;
-	else
-		return &xtensa_dma_map_ops;
+	return &xtensa_dma_map_ops;
 }
 }
 
 
 void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 void dma_cache_sync(struct device *dev, void *vaddr, size_t size,

+ 7 - 0
include/linux/dma-mapping.h

@@ -164,6 +164,13 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma,
 
 
 #ifdef CONFIG_HAS_DMA
 #ifdef CONFIG_HAS_DMA
 #include <asm/dma-mapping.h>
 #include <asm/dma-mapping.h>
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+{
+	if (dev && dev->dma_ops)
+		return dev->dma_ops;
+	return get_arch_dma_ops(dev ? dev->bus : NULL);
+}
+
 static inline void set_dma_ops(struct device *dev,
 static inline void set_dma_ops(struct device *dev,
 			       const struct dma_map_ops *dma_ops)
 			       const struct dma_map_ops *dma_ops)
 {
 {