aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@sandisk.com>2017-01-20 16:04:01 -0500
committerDoug Ledford <dledford@redhat.com>2017-01-24 12:23:35 -0500
commit5299709d0a87342dadc1fc9850484fadeb488bf8 (patch)
treea4d866c18765747846a456810ac5f661cecb8fce
parent102c5ce082f557405a0f71ad5a8920f9df50cd9e (diff)
treewide: Constify most dma_map_ops structures
Most dma_map_ops structures are never modified. Constify these structures such that these can be write-protected. This patch has been generated as follows: git grep -l 'struct dma_map_ops' | xargs -d\\n sed -i \ -e 's/struct dma_map_ops/const struct dma_map_ops/g' \ -e 's/const struct dma_map_ops {/struct dma_map_ops {/g' \ -e 's/^const struct dma_map_ops;$/struct dma_map_ops;/' \ -e 's/const const struct dma_map_ops /const struct dma_map_ops /g'; sed -i -e 's/const \(struct dma_map_ops intel_dma_ops\)/\1/' \ $(git grep -l 'struct dma_map_ops intel_dma_ops'); sed -i -e 's/const \(struct dma_map_ops dma_iommu_ops\)/\1/' \ $(git grep -l 'struct dma_map_ops' | grep ^arch/powerpc); sed -i -e '/^struct vmd_dev {$/,/^};$/ s/const \(struct dma_map_ops[[:blank:]]dma_ops;\)/\1/' \ -e '/^static void vmd_setup_dma_ops/,/^}$/ s/const \(struct dma_map_ops \*dest\)/\1/' \ -e 's/const \(struct dma_map_ops \*dest = \&vmd->dma_ops\)/\1/' \ drivers/pci/host/*.c sed -i -e '/^void __init pci_iommu_alloc(void)$/,/^}$/ s/dma_ops->/intel_dma_ops./' arch/ia64/kernel/pci-dma.c sed -i -e 's/static const struct dma_map_ops sn_dma_ops/static struct dma_map_ops sn_dma_ops/' arch/ia64/sn/pci/pci_dma.c sed -i -e 's/(const struct dma_map_ops \*)//' drivers/misc/mic/bus/vop_bus.c Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Christoph Hellwig <hch@lst.de> 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>
-rw-r--r--arch/alpha/include/asm/dma-mapping.h4
-rw-r--r--arch/alpha/kernel/pci-noop.c4
-rw-r--r--arch/alpha/kernel/pci_iommu.c4
-rw-r--r--arch/arc/include/asm/dma-mapping.h4
-rw-r--r--arch/arc/mm/dma.c2
-rw-r--r--arch/arm/common/dmabounce.c2
-rw-r--r--arch/arm/include/asm/device.h2
-rw-r--r--arch/arm/include/asm/dma-mapping.h10
-rw-r--r--arch/arm/mm/dma-mapping.c22
-rw-r--r--arch/arm/xen/mm.c4
-rw-r--r--arch/arm64/include/asm/device.h2
-rw-r--r--arch/arm64/include/asm/dma-mapping.h6
-rw-r--r--arch/arm64/mm/dma-mapping.c6
-rw-r--r--arch/avr32/include/asm/dma-mapping.h4
-rw-r--r--arch/avr32/mm/dma-coherent.c2
-rw-r--r--arch/blackfin/include/asm/dma-mapping.h4
-rw-r--r--arch/blackfin/kernel/dma-mapping.c2
-rw-r--r--arch/c6x/include/asm/dma-mapping.h4
-rw-r--r--arch/c6x/kernel/dma.c2
-rw-r--r--arch/cris/arch-v32/drivers/pci/dma.c2
-rw-r--r--arch/cris/include/asm/dma-mapping.h6
-rw-r--r--arch/frv/include/asm/dma-mapping.h4
-rw-r--r--arch/frv/mb93090-mb00/pci-dma-nommu.c2
-rw-r--r--arch/frv/mb93090-mb00/pci-dma.c2
-rw-r--r--arch/h8300/include/asm/dma-mapping.h4
-rw-r--r--arch/h8300/kernel/dma.c2
-rw-r--r--arch/hexagon/include/asm/dma-mapping.h4
-rw-r--r--arch/hexagon/kernel/dma.c4
-rw-r--r--arch/ia64/hp/common/hwsw_iommu.c4
-rw-r--r--arch/ia64/hp/common/sba_iommu.c4
-rw-r--r--arch/ia64/include/asm/dma-mapping.h2
-rw-r--r--arch/ia64/include/asm/machvec.h4
-rw-r--r--arch/ia64/kernel/dma-mapping.c4
-rw-r--r--arch/ia64/kernel/pci-dma.c10
-rw-r--r--arch/ia64/kernel/pci-swiotlb.c2
-rw-r--r--arch/m32r/include/asm/device.h2
-rw-r--r--arch/m32r/include/asm/dma-mapping.h2
-rw-r--r--arch/m68k/include/asm/dma-mapping.h4
-rw-r--r--arch/m68k/kernel/dma.c2
-rw-r--r--arch/metag/include/asm/dma-mapping.h4
-rw-r--r--arch/metag/kernel/dma.c2
-rw-r--r--arch/microblaze/include/asm/dma-mapping.h4
-rw-r--r--arch/microblaze/kernel/dma.c2
-rw-r--r--arch/mips/cavium-octeon/dma-octeon.c4
-rw-r--r--arch/mips/include/asm/device.h2
-rw-r--r--arch/mips/include/asm/dma-mapping.h4
-rw-r--r--arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h2
-rw-r--r--arch/mips/include/asm/netlogic/common.h2
-rw-r--r--arch/mips/loongson64/common/dma-swiotlb.c2
-rw-r--r--arch/mips/mm/dma-default.c4
-rw-r--r--arch/mips/netlogic/common/nlm-dma.c2
-rw-r--r--arch/mn10300/include/asm/dma-mapping.h4
-rw-r--r--arch/mn10300/mm/dma-alloc.c2
-rw-r--r--arch/nios2/include/asm/dma-mapping.h4
-rw-r--r--arch/nios2/mm/dma-mapping.c2
-rw-r--r--arch/openrisc/include/asm/dma-mapping.h4
-rw-r--r--arch/openrisc/kernel/dma.c2
-rw-r--r--arch/parisc/include/asm/dma-mapping.h8
-rw-r--r--arch/parisc/kernel/drivers.c2
-rw-r--r--arch/parisc/kernel/pci-dma.c4
-rw-r--r--arch/powerpc/include/asm/device.h2
-rw-r--r--arch/powerpc/include/asm/dma-mapping.h6
-rw-r--r--arch/powerpc/include/asm/pci.h4
-rw-r--r--arch/powerpc/include/asm/swiotlb.h2
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c2
-rw-r--r--arch/powerpc/kernel/dma.c6
-rw-r--r--arch/powerpc/kernel/pci-common.c6
-rw-r--r--arch/powerpc/platforms/cell/iommu.c4
-rw-r--r--arch/powerpc/platforms/powernv/npu-dma.c2
-rw-r--r--arch/powerpc/platforms/ps3/system-bus.c4
-rw-r--r--arch/powerpc/platforms/pseries/ibmebus.c2
-rw-r--r--arch/powerpc/platforms/pseries/vio.c2
-rw-r--r--arch/s390/include/asm/device.h2
-rw-r--r--arch/s390/include/asm/dma-mapping.h4
-rw-r--r--arch/s390/pci/pci_dma.c2
-rw-r--r--arch/sh/include/asm/dma-mapping.h4
-rw-r--r--arch/sh/kernel/dma-nommu.c2
-rw-r--r--arch/sh/mm/consistent.c2
-rw-r--r--arch/sparc/include/asm/dma-mapping.h8
-rw-r--r--arch/sparc/kernel/iommu.c4
-rw-r--r--arch/sparc/kernel/ioport.c8
-rw-r--r--arch/sparc/kernel/pci_sun4v.c2
-rw-r--r--arch/tile/include/asm/device.h2
-rw-r--r--arch/tile/include/asm/dma-mapping.h12
-rw-r--r--arch/tile/kernel/pci-dma.c24
-rw-r--r--arch/unicore32/include/asm/dma-mapping.h4
-rw-r--r--arch/unicore32/mm/dma-swiotlb.c2
-rw-r--r--arch/x86/include/asm/device.h4
-rw-r--r--arch/x86/include/asm/dma-mapping.h4
-rw-r--r--arch/x86/include/asm/iommu.h2
-rw-r--r--arch/x86/kernel/amd_gart_64.c2
-rw-r--r--arch/x86/kernel/pci-calgary_64.c2
-rw-r--r--arch/x86/kernel/pci-dma.c4
-rw-r--r--arch/x86/kernel/pci-nommu.c2
-rw-r--r--arch/x86/kernel/pci-swiotlb.c2
-rw-r--r--arch/x86/pci/sta2x11-fixup.c2
-rw-r--r--arch/x86/xen/pci-swiotlb-xen.c2
-rw-r--r--arch/xtensa/include/asm/device.h2
-rw-r--r--arch/xtensa/include/asm/dma-mapping.h4
-rw-r--r--arch/xtensa/kernel/pci-dma.c2
-rw-r--r--drivers/iommu/amd_iommu.c4
-rw-r--r--drivers/misc/mic/bus/mic_bus.c2
-rw-r--r--drivers/misc/mic/bus/scif_bus.c2
-rw-r--r--drivers/misc/mic/bus/scif_bus.h2
-rw-r--r--drivers/misc/mic/bus/vop_bus.c2
-rw-r--r--drivers/misc/mic/host/mic_boot.c4
-rw-r--r--drivers/parisc/ccio-dma.c2
-rw-r--r--drivers/parisc/sba_iommu.c2
-rw-r--r--drivers/pci/host/vmd.c2
-rw-r--r--include/linux/dma-mapping.h42
-rw-r--r--include/linux/mic_bus.h2
-rw-r--r--include/xen/arm/hypervisor.h2
-rw-r--r--lib/dma-noop.c2
113 files changed, 227 insertions, 227 deletions
diff --git a/arch/alpha/include/asm/dma-mapping.h b/arch/alpha/include/asm/dma-mapping.h
index c63b6ac19ee5..d3480562411d 100644
--- a/arch/alpha/include/asm/dma-mapping.h
+++ b/arch/alpha/include/asm/dma-mapping.h
@@ -1,9 +1,9 @@
1#ifndef _ALPHA_DMA_MAPPING_H 1#ifndef _ALPHA_DMA_MAPPING_H
2#define _ALPHA_DMA_MAPPING_H 2#define _ALPHA_DMA_MAPPING_H
3 3
4extern struct dma_map_ops *dma_ops; 4extern const struct dma_map_ops *dma_ops;
5 5
6static inline struct dma_map_ops *get_dma_ops(struct device *dev) 6static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
7{ 7{
8 return dma_ops; 8 return dma_ops;
9} 9}
diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c
index bb152e21e5ae..ffbdb3fb672f 100644
--- a/arch/alpha/kernel/pci-noop.c
+++ b/arch/alpha/kernel/pci-noop.c
@@ -128,7 +128,7 @@ static int alpha_noop_supported(struct device *dev, u64 mask)
128 return mask < 0x00ffffffUL ? 0 : 1; 128 return mask < 0x00ffffffUL ? 0 : 1;
129} 129}
130 130
131struct dma_map_ops alpha_noop_ops = { 131const struct dma_map_ops alpha_noop_ops = {
132 .alloc = alpha_noop_alloc_coherent, 132 .alloc = alpha_noop_alloc_coherent,
133 .free = dma_noop_free_coherent, 133 .free = dma_noop_free_coherent,
134 .map_page = dma_noop_map_page, 134 .map_page = dma_noop_map_page,
@@ -137,5 +137,5 @@ struct dma_map_ops alpha_noop_ops = {
137 .dma_supported = alpha_noop_supported, 137 .dma_supported = alpha_noop_supported,
138}; 138};
139 139
140struct dma_map_ops *dma_ops = &alpha_noop_ops; 140const struct dma_map_ops *dma_ops = &alpha_noop_ops;
141EXPORT_SYMBOL(dma_ops); 141EXPORT_SYMBOL(dma_ops);
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 451fc9cdd323..7fd2329038a3 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -939,7 +939,7 @@ static int alpha_pci_mapping_error(struct device *dev, dma_addr_t dma_addr)
939 return dma_addr == 0; 939 return dma_addr == 0;
940} 940}
941 941
942struct dma_map_ops alpha_pci_ops = { 942const struct dma_map_ops alpha_pci_ops = {
943 .alloc = alpha_pci_alloc_coherent, 943 .alloc = alpha_pci_alloc_coherent,
944 .free = alpha_pci_free_coherent, 944 .free = alpha_pci_free_coherent,
945 .map_page = alpha_pci_map_page, 945 .map_page = alpha_pci_map_page,
@@ -950,5 +950,5 @@ struct dma_map_ops alpha_pci_ops = {
950 .dma_supported = alpha_pci_supported, 950 .dma_supported = alpha_pci_supported,
951}; 951};
952 952
953struct dma_map_ops *dma_ops = &alpha_pci_ops; 953const struct dma_map_ops *dma_ops = &alpha_pci_ops;
954EXPORT_SYMBOL(dma_ops); 954EXPORT_SYMBOL(dma_ops);
diff --git a/arch/arc/include/asm/dma-mapping.h b/arch/arc/include/asm/dma-mapping.h
index 266f11c9bd59..fdff3aa60052 100644
--- a/arch/arc/include/asm/dma-mapping.h
+++ b/arch/arc/include/asm/dma-mapping.h
@@ -18,9 +18,9 @@
18#include <plat/dma.h> 18#include <plat/dma.h>
19#endif 19#endif
20 20
21extern struct dma_map_ops arc_dma_ops; 21extern const struct dma_map_ops arc_dma_ops;
22 22
23static inline struct dma_map_ops *get_dma_ops(struct device *dev) 23static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
24{ 24{
25 return &arc_dma_ops; 25 return &arc_dma_ops;
26} 26}
diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
index 08450a1a5b5f..2a07e6ecafbd 100644
--- a/arch/arc/mm/dma.c
+++ b/arch/arc/mm/dma.c
@@ -218,7 +218,7 @@ static int arc_dma_supported(struct device *dev, u64 dma_mask)
218 return dma_mask == DMA_BIT_MASK(32); 218 return dma_mask == DMA_BIT_MASK(32);
219} 219}
220 220
221struct dma_map_ops arc_dma_ops = { 221const struct dma_map_ops arc_dma_ops = {
222 .alloc = arc_dma_alloc, 222 .alloc = arc_dma_alloc,
223 .free = arc_dma_free, 223 .free = arc_dma_free,
224 .mmap = arc_dma_mmap, 224 .mmap = arc_dma_mmap,
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 75055df1cda3..9b1b7be2ec0e 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -452,7 +452,7 @@ static int dmabounce_set_mask(struct device *dev, u64 dma_mask)
452 return arm_dma_ops.set_dma_mask(dev, dma_mask); 452 return arm_dma_ops.set_dma_mask(dev, dma_mask);
453} 453}
454 454
455static struct dma_map_ops dmabounce_ops = { 455static const struct dma_map_ops dmabounce_ops = {
456 .alloc = arm_dma_alloc, 456 .alloc = arm_dma_alloc,
457 .free = arm_dma_free, 457 .free = arm_dma_free,
458 .mmap = arm_dma_mmap, 458 .mmap = arm_dma_mmap,
diff --git a/arch/arm/include/asm/device.h b/arch/arm/include/asm/device.h
index 4111592f0130..d8a572f9c187 100644
--- a/arch/arm/include/asm/device.h
+++ b/arch/arm/include/asm/device.h
@@ -7,7 +7,7 @@
7#define ASMARM_DEVICE_H 7#define ASMARM_DEVICE_H
8 8
9struct dev_archdata { 9struct dev_archdata {
10 struct dma_map_ops *dma_ops; 10 const struct dma_map_ops *dma_ops;
11#ifdef CONFIG_DMABOUNCE 11#ifdef CONFIG_DMABOUNCE
12 struct dmabounce_device_info *dmabounce; 12 struct dmabounce_device_info *dmabounce;
13#endif 13#endif
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index bf02dbd9ccda..1aabd781306f 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -13,17 +13,17 @@
13#include <asm/xen/hypervisor.h> 13#include <asm/xen/hypervisor.h>
14 14
15#define DMA_ERROR_CODE (~(dma_addr_t)0x0) 15#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
16extern struct dma_map_ops arm_dma_ops; 16extern const struct dma_map_ops arm_dma_ops;
17extern struct dma_map_ops arm_coherent_dma_ops; 17extern const struct dma_map_ops arm_coherent_dma_ops;
18 18
19static inline struct dma_map_ops *__generic_dma_ops(struct device *dev) 19static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
20{ 20{
21 if (dev && dev->archdata.dma_ops) 21 if (dev && dev->archdata.dma_ops)
22 return dev->archdata.dma_ops; 22 return dev->archdata.dma_ops;
23 return &arm_dma_ops; 23 return &arm_dma_ops;
24} 24}
25 25
26static inline struct dma_map_ops *get_dma_ops(struct device *dev) 26static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
27{ 27{
28 if (xen_initial_domain()) 28 if (xen_initial_domain())
29 return xen_dma_ops; 29 return xen_dma_ops;
@@ -31,7 +31,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
31 return __generic_dma_ops(dev); 31 return __generic_dma_ops(dev);
32} 32}
33 33
34static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) 34static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops)
35{ 35{
36 BUG_ON(!dev); 36 BUG_ON(!dev);
37 dev->archdata.dma_ops = ops; 37 dev->archdata.dma_ops = ops;
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index ab7710002ba6..d26fe1a35687 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -180,7 +180,7 @@ static void arm_dma_sync_single_for_device(struct device *dev,
180 __dma_page_cpu_to_dev(page, offset, size, dir); 180 __dma_page_cpu_to_dev(page, offset, size, dir);
181} 181}
182 182
183struct dma_map_ops arm_dma_ops = { 183const struct dma_map_ops arm_dma_ops = {
184 .alloc = arm_dma_alloc, 184 .alloc = arm_dma_alloc,
185 .free = arm_dma_free, 185 .free = arm_dma_free,
186 .mmap = arm_dma_mmap, 186 .mmap = arm_dma_mmap,
@@ -204,7 +204,7 @@ static int arm_coherent_dma_mmap(struct device *dev, struct vm_area_struct *vma,
204 void *cpu_addr, dma_addr_t dma_addr, size_t size, 204 void *cpu_addr, dma_addr_t dma_addr, size_t size,
205 unsigned long attrs); 205 unsigned long attrs);
206 206
207struct dma_map_ops arm_coherent_dma_ops = { 207const struct dma_map_ops arm_coherent_dma_ops = {
208 .alloc = arm_coherent_dma_alloc, 208 .alloc = arm_coherent_dma_alloc,
209 .free = arm_coherent_dma_free, 209 .free = arm_coherent_dma_free,
210 .mmap = arm_coherent_dma_mmap, 210 .mmap = arm_coherent_dma_mmap,
@@ -1067,7 +1067,7 @@ static void __dma_page_dev_to_cpu(struct page *page, unsigned long off,
1067int arm_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 1067int arm_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
1068 enum dma_data_direction dir, unsigned long attrs) 1068 enum dma_data_direction dir, unsigned long attrs)
1069{ 1069{
1070 struct dma_map_ops *ops = get_dma_ops(dev); 1070 const struct dma_map_ops *ops = get_dma_ops(dev);
1071 struct scatterlist *s; 1071 struct scatterlist *s;
1072 int i, j; 1072 int i, j;
1073 1073
@@ -1101,7 +1101,7 @@ int arm_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
1101void arm_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, 1101void arm_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
1102 enum dma_data_direction dir, unsigned long attrs) 1102 enum dma_data_direction dir, unsigned long attrs)
1103{ 1103{
1104 struct dma_map_ops *ops = get_dma_ops(dev); 1104 const struct dma_map_ops *ops = get_dma_ops(dev);
1105 struct scatterlist *s; 1105 struct scatterlist *s;
1106 1106
1107 int i; 1107 int i;
@@ -1120,7 +1120,7 @@ void arm_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
1120void arm_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, 1120void arm_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
1121 int nents, enum dma_data_direction dir) 1121 int nents, enum dma_data_direction dir)
1122{ 1122{
1123 struct dma_map_ops *ops = get_dma_ops(dev); 1123 const struct dma_map_ops *ops = get_dma_ops(dev);
1124 struct scatterlist *s; 1124 struct scatterlist *s;
1125 int i; 1125 int i;
1126 1126
@@ -1139,7 +1139,7 @@ void arm_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
1139void arm_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, 1139void arm_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
1140 int nents, enum dma_data_direction dir) 1140 int nents, enum dma_data_direction dir)
1141{ 1141{
1142 struct dma_map_ops *ops = get_dma_ops(dev); 1142 const struct dma_map_ops *ops = get_dma_ops(dev);
1143 struct scatterlist *s; 1143 struct scatterlist *s;
1144 int i; 1144 int i;
1145 1145
@@ -2099,7 +2099,7 @@ static void arm_iommu_sync_single_for_device(struct device *dev,
2099 __dma_page_cpu_to_dev(page, offset, size, dir); 2099 __dma_page_cpu_to_dev(page, offset, size, dir);
2100} 2100}
2101 2101
2102struct dma_map_ops iommu_ops = { 2102const struct dma_map_ops iommu_ops = {
2103 .alloc = arm_iommu_alloc_attrs, 2103 .alloc = arm_iommu_alloc_attrs,
2104 .free = arm_iommu_free_attrs, 2104 .free = arm_iommu_free_attrs,
2105 .mmap = arm_iommu_mmap_attrs, 2105 .mmap = arm_iommu_mmap_attrs,
@@ -2119,7 +2119,7 @@ struct dma_map_ops iommu_ops = {
2119 .unmap_resource = arm_iommu_unmap_resource, 2119 .unmap_resource = arm_iommu_unmap_resource,
2120}; 2120};
2121 2121
2122struct dma_map_ops iommu_coherent_ops = { 2122const struct dma_map_ops iommu_coherent_ops = {
2123 .alloc = arm_coherent_iommu_alloc_attrs, 2123 .alloc = arm_coherent_iommu_alloc_attrs,
2124 .free = arm_coherent_iommu_free_attrs, 2124 .free = arm_coherent_iommu_free_attrs,
2125 .mmap = arm_coherent_iommu_mmap_attrs, 2125 .mmap = arm_coherent_iommu_mmap_attrs,
@@ -2319,7 +2319,7 @@ void arm_iommu_detach_device(struct device *dev)
2319} 2319}
2320EXPORT_SYMBOL_GPL(arm_iommu_detach_device); 2320EXPORT_SYMBOL_GPL(arm_iommu_detach_device);
2321 2321
2322static struct dma_map_ops *arm_get_iommu_dma_map_ops(bool coherent) 2322static const struct dma_map_ops *arm_get_iommu_dma_map_ops(bool coherent)
2323{ 2323{
2324 return coherent ? &iommu_coherent_ops : &iommu_ops; 2324 return coherent ? &iommu_coherent_ops : &iommu_ops;
2325} 2325}
@@ -2374,7 +2374,7 @@ static void arm_teardown_iommu_dma_ops(struct device *dev) { }
2374 2374
2375#endif /* CONFIG_ARM_DMA_USE_IOMMU */ 2375#endif /* CONFIG_ARM_DMA_USE_IOMMU */
2376 2376
2377static struct dma_map_ops *arm_get_dma_map_ops(bool coherent) 2377static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
2378{ 2378{
2379 return coherent ? &arm_coherent_dma_ops : &arm_dma_ops; 2379 return coherent ? &arm_coherent_dma_ops : &arm_dma_ops;
2380} 2380}
@@ -2382,7 +2382,7 @@ static struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
2382void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, 2382void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
2383 const struct iommu_ops *iommu, bool coherent) 2383 const struct iommu_ops *iommu, bool coherent)
2384{ 2384{
2385 struct dma_map_ops *dma_ops; 2385 const struct dma_map_ops *dma_ops;
2386 2386
2387 dev->archdata.dma_coherent = coherent; 2387 dev->archdata.dma_coherent = coherent;
2388 if (arm_setup_iommu_dma_ops(dev, dma_base, size, iommu)) 2388 if (arm_setup_iommu_dma_ops(dev, dma_base, size, iommu))
diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index bd62d94f8ac5..ce18c91b50a1 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -182,10 +182,10 @@ void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
182} 182}
183EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region); 183EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
184 184
185struct dma_map_ops *xen_dma_ops; 185const struct dma_map_ops *xen_dma_ops;
186EXPORT_SYMBOL(xen_dma_ops); 186EXPORT_SYMBOL(xen_dma_ops);
187 187
188static struct dma_map_ops xen_swiotlb_dma_ops = { 188static const struct dma_map_ops xen_swiotlb_dma_ops = {
189 .alloc = xen_swiotlb_alloc_coherent, 189 .alloc = xen_swiotlb_alloc_coherent,
190 .free = xen_swiotlb_free_coherent, 190 .free = xen_swiotlb_free_coherent,
191 .sync_single_for_cpu = xen_swiotlb_sync_single_for_cpu, 191 .sync_single_for_cpu = xen_swiotlb_sync_single_for_cpu,
diff --git a/arch/arm64/include/asm/device.h b/arch/arm64/include/asm/device.h
index 243ef256b8c9..00c678cc31e1 100644
--- a/arch/arm64/include/asm/device.h
+++ b/arch/arm64/include/asm/device.h
@@ -17,7 +17,7 @@
17#define __ASM_DEVICE_H 17#define __ASM_DEVICE_H
18 18
19struct dev_archdata { 19struct dev_archdata {
20 struct dma_map_ops *dma_ops; 20 const struct dma_map_ops *dma_ops;
21#ifdef CONFIG_IOMMU_API 21#ifdef CONFIG_IOMMU_API
22 void *iommu; /* private IOMMU data */ 22 void *iommu; /* private IOMMU data */
23#endif 23#endif
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index ccea82c2b089..1fedb43be712 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -25,9 +25,9 @@
25#include <asm/xen/hypervisor.h> 25#include <asm/xen/hypervisor.h>
26 26
27#define DMA_ERROR_CODE (~(dma_addr_t)0) 27#define DMA_ERROR_CODE (~(dma_addr_t)0)
28extern struct dma_map_ops dummy_dma_ops; 28extern const struct dma_map_ops dummy_dma_ops;
29 29
30static inline struct dma_map_ops *__generic_dma_ops(struct device *dev) 30static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
31{ 31{
32 if (dev && dev->archdata.dma_ops) 32 if (dev && dev->archdata.dma_ops)
33 return dev->archdata.dma_ops; 33 return dev->archdata.dma_ops;
@@ -39,7 +39,7 @@ static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
39 return &dummy_dma_ops; 39 return &dummy_dma_ops;
40} 40}
41 41
42static inline struct dma_map_ops *get_dma_ops(struct device *dev) 42static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
43{ 43{
44 if (xen_initial_domain()) 44 if (xen_initial_domain())
45 return xen_dma_ops; 45 return xen_dma_ops;
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index e04082700bb1..bcef6368d48f 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -352,7 +352,7 @@ static int __swiotlb_dma_supported(struct device *hwdev, u64 mask)
352 return 1; 352 return 1;
353} 353}
354 354
355static struct dma_map_ops swiotlb_dma_ops = { 355static const struct dma_map_ops swiotlb_dma_ops = {
356 .alloc = __dma_alloc, 356 .alloc = __dma_alloc,
357 .free = __dma_free, 357 .free = __dma_free,
358 .mmap = __swiotlb_mmap, 358 .mmap = __swiotlb_mmap,
@@ -505,7 +505,7 @@ static int __dummy_dma_supported(struct device *hwdev, u64 mask)
505 return 0; 505 return 0;
506} 506}
507 507
508struct dma_map_ops dummy_dma_ops = { 508const struct dma_map_ops dummy_dma_ops = {
509 .alloc = __dummy_alloc, 509 .alloc = __dummy_alloc,
510 .free = __dummy_free, 510 .free = __dummy_free,
511 .mmap = __dummy_mmap, 511 .mmap = __dummy_mmap,
@@ -784,7 +784,7 @@ static void __iommu_unmap_sg_attrs(struct device *dev,
784 iommu_dma_unmap_sg(dev, sgl, nelems, dir, attrs); 784 iommu_dma_unmap_sg(dev, sgl, nelems, dir, attrs);
785} 785}
786 786
787static struct dma_map_ops iommu_dma_ops = { 787static const struct dma_map_ops iommu_dma_ops = {
788 .alloc = __iommu_alloc_attrs, 788 .alloc = __iommu_alloc_attrs,
789 .free = __iommu_free_attrs, 789 .free = __iommu_free_attrs,
790 .mmap = __iommu_mmap_attrs, 790 .mmap = __iommu_mmap_attrs,
diff --git a/arch/avr32/include/asm/dma-mapping.h b/arch/avr32/include/asm/dma-mapping.h
index 1115f2a645d1..b2b43c0e0774 100644
--- a/arch/avr32/include/asm/dma-mapping.h
+++ b/arch/avr32/include/asm/dma-mapping.h
@@ -4,9 +4,9 @@
4extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 4extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
5 int direction); 5 int direction);
6 6
7extern struct dma_map_ops avr32_dma_ops; 7extern const struct dma_map_ops avr32_dma_ops;
8 8
9static inline struct dma_map_ops *get_dma_ops(struct device *dev) 9static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
10{ 10{
11 return &avr32_dma_ops; 11 return &avr32_dma_ops;
12} 12}
diff --git a/arch/avr32/mm/dma-coherent.c b/arch/avr32/mm/dma-coherent.c
index 54534e5d0781..555222d4f414 100644
--- a/arch/avr32/mm/dma-coherent.c
+++ b/arch/avr32/mm/dma-coherent.c
@@ -191,7 +191,7 @@ static void avr32_dma_sync_sg_for_device(struct device *dev,
191 dma_cache_sync(dev, sg_virt(sg), sg->length, direction); 191 dma_cache_sync(dev, sg_virt(sg), sg->length, direction);
192} 192}
193 193
194struct dma_map_ops avr32_dma_ops = { 194const struct dma_map_ops avr32_dma_ops = {
195 .alloc = avr32_dma_alloc, 195 .alloc = avr32_dma_alloc,
196 .free = avr32_dma_free, 196 .free = avr32_dma_free,
197 .map_page = avr32_dma_map_page, 197 .map_page = avr32_dma_map_page,
diff --git a/arch/blackfin/include/asm/dma-mapping.h b/arch/blackfin/include/asm/dma-mapping.h
index 3490570aaa82..320fb50fbd41 100644
--- a/arch/blackfin/include/asm/dma-mapping.h
+++ b/arch/blackfin/include/asm/dma-mapping.h
@@ -36,9 +36,9 @@ _dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir)
36 __dma_sync(addr, size, dir); 36 __dma_sync(addr, size, dir);
37} 37}
38 38
39extern struct dma_map_ops bfin_dma_ops; 39extern const struct dma_map_ops bfin_dma_ops;
40 40
41static inline struct dma_map_ops *get_dma_ops(struct device *dev) 41static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
42{ 42{
43 return &bfin_dma_ops; 43 return &bfin_dma_ops;
44} 44}
diff --git a/arch/blackfin/kernel/dma-mapping.c b/arch/blackfin/kernel/dma-mapping.c
index a27a74a18fb0..477bb29a7987 100644
--- a/arch/blackfin/kernel/dma-mapping.c
+++ b/arch/blackfin/kernel/dma-mapping.c
@@ -159,7 +159,7 @@ static inline void bfin_dma_sync_single_for_device(struct device *dev,
159 _dma_sync(handle, size, dir); 159 _dma_sync(handle, size, dir);
160} 160}
161 161
162struct dma_map_ops bfin_dma_ops = { 162const struct dma_map_ops bfin_dma_ops = {
163 .alloc = bfin_dma_alloc, 163 .alloc = bfin_dma_alloc,
164 .free = bfin_dma_free, 164 .free = bfin_dma_free,
165 165
diff --git a/arch/c6x/include/asm/dma-mapping.h b/arch/c6x/include/asm/dma-mapping.h
index 5717b1e52d96..88258b9ebc8e 100644
--- a/arch/c6x/include/asm/dma-mapping.h
+++ b/arch/c6x/include/asm/dma-mapping.h
@@ -17,9 +17,9 @@
17 */ 17 */
18#define DMA_ERROR_CODE ~0 18#define DMA_ERROR_CODE ~0
19 19
20extern struct dma_map_ops c6x_dma_ops; 20extern const struct dma_map_ops c6x_dma_ops;
21 21
22static inline struct dma_map_ops *get_dma_ops(struct device *dev) 22static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
23{ 23{
24 return &c6x_dma_ops; 24 return &c6x_dma_ops;
25} 25}
diff --git a/arch/c6x/kernel/dma.c b/arch/c6x/kernel/dma.c
index 6752df32ef06..9fff8be75f58 100644
--- a/arch/c6x/kernel/dma.c
+++ b/arch/c6x/kernel/dma.c
@@ -123,7 +123,7 @@ static void c6x_dma_sync_sg_for_device(struct device *dev,
123 123
124} 124}
125 125
126struct dma_map_ops c6x_dma_ops = { 126const struct dma_map_ops c6x_dma_ops = {
127 .alloc = c6x_dma_alloc, 127 .alloc = c6x_dma_alloc,
128 .free = c6x_dma_free, 128 .free = c6x_dma_free,
129 .map_page = c6x_dma_map_page, 129 .map_page = c6x_dma_map_page,
diff --git a/arch/cris/arch-v32/drivers/pci/dma.c b/arch/cris/arch-v32/drivers/pci/dma.c
index 1f0636793f0c..7072341995ff 100644
--- a/arch/cris/arch-v32/drivers/pci/dma.c
+++ b/arch/cris/arch-v32/drivers/pci/dma.c
@@ -69,7 +69,7 @@ static inline int v32_dma_supported(struct device *dev, u64 mask)
69 return 1; 69 return 1;
70} 70}
71 71
72struct dma_map_ops v32_dma_ops = { 72const struct dma_map_ops v32_dma_ops = {
73 .alloc = v32_dma_alloc, 73 .alloc = v32_dma_alloc,
74 .free = v32_dma_free, 74 .free = v32_dma_free,
75 .map_page = v32_dma_map_page, 75 .map_page = v32_dma_map_page,
diff --git a/arch/cris/include/asm/dma-mapping.h b/arch/cris/include/asm/dma-mapping.h
index 5a370178a0e9..aae4fbc0a656 100644
--- a/arch/cris/include/asm/dma-mapping.h
+++ b/arch/cris/include/asm/dma-mapping.h
@@ -2,14 +2,14 @@
2#define _ASM_CRIS_DMA_MAPPING_H 2#define _ASM_CRIS_DMA_MAPPING_H
3 3
4#ifdef CONFIG_PCI 4#ifdef CONFIG_PCI
5extern struct dma_map_ops v32_dma_ops; 5extern const struct dma_map_ops v32_dma_ops;
6 6
7static inline struct dma_map_ops *get_dma_ops(struct device *dev) 7static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
8{ 8{
9 return &v32_dma_ops; 9 return &v32_dma_ops;
10} 10}
11#else 11#else
12static inline struct dma_map_ops *get_dma_ops(struct device *dev) 12static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
13{ 13{
14 BUG(); 14 BUG();
15 return NULL; 15 return NULL;
diff --git a/arch/frv/include/asm/dma-mapping.h b/arch/frv/include/asm/dma-mapping.h
index 9a82bfa4303b..150cc00544a8 100644
--- a/arch/frv/include/asm/dma-mapping.h
+++ b/arch/frv/include/asm/dma-mapping.h
@@ -7,9 +7,9 @@
7extern unsigned long __nongprelbss dma_coherent_mem_start; 7extern unsigned long __nongprelbss dma_coherent_mem_start;
8extern unsigned long __nongprelbss dma_coherent_mem_end; 8extern unsigned long __nongprelbss dma_coherent_mem_end;
9 9
10extern struct dma_map_ops frv_dma_ops; 10extern const struct dma_map_ops frv_dma_ops;
11 11
12static inline struct dma_map_ops *get_dma_ops(struct device *dev) 12static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
13{ 13{
14 return &frv_dma_ops; 14 return &frv_dma_ops;
15} 15}
diff --git a/arch/frv/mb93090-mb00/pci-dma-nommu.c b/arch/frv/mb93090-mb00/pci-dma-nommu.c
index 187688128c65..4a96de7f0af4 100644
--- a/arch/frv/mb93090-mb00/pci-dma-nommu.c
+++ b/arch/frv/mb93090-mb00/pci-dma-nommu.c
@@ -164,7 +164,7 @@ static int frv_dma_supported(struct device *dev, u64 mask)
164 return 1; 164 return 1;
165} 165}
166 166
167struct dma_map_ops frv_dma_ops = { 167const struct dma_map_ops frv_dma_ops = {
168 .alloc = frv_dma_alloc, 168 .alloc = frv_dma_alloc,
169 .free = frv_dma_free, 169 .free = frv_dma_free,
170 .map_page = frv_dma_map_page, 170 .map_page = frv_dma_map_page,
diff --git a/arch/frv/mb93090-mb00/pci-dma.c b/arch/frv/mb93090-mb00/pci-dma.c
index dba7df918144..e7130abc0dae 100644
--- a/arch/frv/mb93090-mb00/pci-dma.c
+++ b/arch/frv/mb93090-mb00/pci-dma.c
@@ -106,7 +106,7 @@ static int frv_dma_supported(struct device *dev, u64 mask)
106 return 1; 106 return 1;
107} 107}
108 108
109struct dma_map_ops frv_dma_ops = { 109const struct dma_map_ops frv_dma_ops = {
110 .alloc = frv_dma_alloc, 110 .alloc = frv_dma_alloc,
111 .free = frv_dma_free, 111 .free = frv_dma_free,
112 .map_page = frv_dma_map_page, 112 .map_page = frv_dma_map_page,
diff --git a/arch/h8300/include/asm/dma-mapping.h b/arch/h8300/include/asm/dma-mapping.h
index 7ac7fadffed0..f804bca4c13f 100644
--- a/arch/h8300/include/asm/dma-mapping.h
+++ b/arch/h8300/include/asm/dma-mapping.h
@@ -1,9 +1,9 @@
1#ifndef _H8300_DMA_MAPPING_H 1#ifndef _H8300_DMA_MAPPING_H
2#define _H8300_DMA_MAPPING_H 2#define _H8300_DMA_MAPPING_H
3 3
4extern struct dma_map_ops h8300_dma_map_ops; 4extern const struct dma_map_ops h8300_dma_map_ops;
5 5
6static inline struct dma_map_ops *get_dma_ops(struct device *dev) 6static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
7{ 7{
8 return &h8300_dma_map_ops; 8 return &h8300_dma_map_ops;
9} 9}
diff --git a/arch/h8300/kernel/dma.c b/arch/h8300/kernel/dma.c
index 3651da045806..225dd0a188dc 100644
--- a/arch/h8300/kernel/dma.c
+++ b/arch/h8300/kernel/dma.c
@@ -60,7 +60,7 @@ static int map_sg(struct device *dev, struct scatterlist *sgl,
60 return nents; 60 return nents;
61} 61}
62 62
63struct dma_map_ops h8300_dma_map_ops = { 63const struct dma_map_ops h8300_dma_map_ops = {
64 .alloc = dma_alloc, 64 .alloc = dma_alloc,
65 .free = dma_free, 65 .free = dma_free,
66 .map_page = map_page, 66 .map_page = map_page,
diff --git a/arch/hexagon/include/asm/dma-mapping.h b/arch/hexagon/include/asm/dma-mapping.h
index 7ef58df909fc..b812e917cd95 100644
--- a/arch/hexagon/include/asm/dma-mapping.h
+++ b/arch/hexagon/include/asm/dma-mapping.h
@@ -32,9 +32,9 @@ struct device;
32extern int bad_dma_address; 32extern int bad_dma_address;
33#define DMA_ERROR_CODE bad_dma_address 33#define DMA_ERROR_CODE bad_dma_address
34 34
35extern struct dma_map_ops *dma_ops; 35extern const struct dma_map_ops *dma_ops;
36 36
37static inline struct dma_map_ops *get_dma_ops(struct device *dev) 37static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
38{ 38{
39 if (unlikely(dev == NULL)) 39 if (unlikely(dev == NULL))
40 return NULL; 40 return NULL;
diff --git a/arch/hexagon/kernel/dma.c b/arch/hexagon/kernel/dma.c
index dbc4f1003da4..e74b65009587 100644
--- a/arch/hexagon/kernel/dma.c
+++ b/arch/hexagon/kernel/dma.c
@@ -25,7 +25,7 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <asm/page.h> 26#include <asm/page.h>
27 27
28struct dma_map_ops *dma_ops; 28const struct dma_map_ops *dma_ops;
29EXPORT_SYMBOL(dma_ops); 29EXPORT_SYMBOL(dma_ops);
30 30
31int bad_dma_address; /* globals are automatically initialized to zero */ 31int bad_dma_address; /* globals are automatically initialized to zero */
@@ -203,7 +203,7 @@ static void hexagon_sync_single_for_device(struct device *dev,
203 dma_sync(dma_addr_to_virt(dma_handle), size, dir); 203 dma_sync(dma_addr_to_virt(dma_handle), size, dir);
204} 204}
205 205
206struct dma_map_ops hexagon_dma_ops = { 206const struct dma_map_ops hexagon_dma_ops = {
207 .alloc = hexagon_dma_alloc_coherent, 207 .alloc = hexagon_dma_alloc_coherent,
208 .free = hexagon_free_coherent, 208 .free = hexagon_free_coherent,
209 .map_sg = hexagon_map_sg, 209 .map_sg = hexagon_map_sg,
diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index 1e4cae5ae053..0310078a95f8 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -18,7 +18,7 @@
18#include <linux/export.h> 18#include <linux/export.h>
19#include <asm/machvec.h> 19#include <asm/machvec.h>
20 20
21extern struct dma_map_ops sba_dma_ops, swiotlb_dma_ops; 21extern const struct dma_map_ops sba_dma_ops, swiotlb_dma_ops;
22 22
23/* swiotlb declarations & definitions: */ 23/* swiotlb declarations & definitions: */
24extern int swiotlb_late_init_with_default_size (size_t size); 24extern int swiotlb_late_init_with_default_size (size_t size);
@@ -34,7 +34,7 @@ static inline int use_swiotlb(struct device *dev)
34 !sba_dma_ops.dma_supported(dev, *dev->dma_mask); 34 !sba_dma_ops.dma_supported(dev, *dev->dma_mask);
35} 35}
36 36
37struct dma_map_ops *hwsw_dma_get_ops(struct device *dev) 37const struct dma_map_ops *hwsw_dma_get_ops(struct device *dev)
38{ 38{
39 if (use_swiotlb(dev)) 39 if (use_swiotlb(dev))
40 return &swiotlb_dma_ops; 40 return &swiotlb_dma_ops;
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 630ee8073899..aec4a3354abe 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2096,7 +2096,7 @@ static int __init acpi_sba_ioc_init_acpi(void)
2096/* This has to run before acpi_scan_init(). */ 2096/* This has to run before acpi_scan_init(). */
2097arch_initcall(acpi_sba_ioc_init_acpi); 2097arch_initcall(acpi_sba_ioc_init_acpi);
2098 2098
2099extern struct dma_map_ops swiotlb_dma_ops; 2099extern const struct dma_map_ops swiotlb_dma_ops;
2100 2100
2101static int __init 2101static int __init
2102sba_init(void) 2102sba_init(void)
@@ -2216,7 +2216,7 @@ sba_page_override(char *str)
2216 2216
2217__setup("sbapagesize=",sba_page_override); 2217__setup("sbapagesize=",sba_page_override);
2218 2218
2219struct dma_map_ops sba_dma_ops = { 2219const struct dma_map_ops sba_dma_ops = {
2220 .alloc = sba_alloc_coherent, 2220 .alloc = sba_alloc_coherent,
2221 .free = sba_free_coherent, 2221 .free = sba_free_coherent,
2222 .map_page = sba_map_page, 2222 .map_page = sba_map_page,
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index d472805edfa9..05e467d56d86 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -14,7 +14,7 @@
14 14
15#define DMA_ERROR_CODE 0 15#define DMA_ERROR_CODE 0
16 16
17extern struct dma_map_ops *dma_ops; 17extern const struct dma_map_ops *dma_ops;
18extern struct ia64_machine_vector ia64_mv; 18extern struct ia64_machine_vector ia64_mv;
19extern void set_iommu_machvec(void); 19extern void set_iommu_machvec(void);
20 20
diff --git a/arch/ia64/include/asm/machvec.h b/arch/ia64/include/asm/machvec.h
index ed7f09089f12..af285c423e1e 100644
--- a/arch/ia64/include/asm/machvec.h
+++ b/arch/ia64/include/asm/machvec.h
@@ -44,7 +44,7 @@ typedef void ia64_mv_kernel_launch_event_t(void);
44/* DMA-mapping interface: */ 44/* DMA-mapping interface: */
45typedef void ia64_mv_dma_init (void); 45typedef void ia64_mv_dma_init (void);
46typedef u64 ia64_mv_dma_get_required_mask (struct device *); 46typedef u64 ia64_mv_dma_get_required_mask (struct device *);
47typedef struct dma_map_ops *ia64_mv_dma_get_ops(struct device *); 47typedef const struct dma_map_ops *ia64_mv_dma_get_ops(struct device *);
48 48
49/* 49/*
50 * WARNING: The legacy I/O space is _architected_. Platforms are 50 * WARNING: The legacy I/O space is _architected_. Platforms are
@@ -248,7 +248,7 @@ extern void machvec_init_from_cmdline(const char *cmdline);
248# endif /* CONFIG_IA64_GENERIC */ 248# endif /* CONFIG_IA64_GENERIC */
249 249
250extern void swiotlb_dma_init(void); 250extern void swiotlb_dma_init(void);
251extern struct dma_map_ops *dma_get_ops(struct device *); 251extern const struct dma_map_ops *dma_get_ops(struct device *);
252 252
253/* 253/*
254 * Define default versions so we can extend machvec for new platforms without having 254 * Define default versions so we can extend machvec for new platforms without having
diff --git a/arch/ia64/kernel/dma-mapping.c b/arch/ia64/kernel/dma-mapping.c
index 7f7916238208..e0dd97f4eb69 100644
--- a/arch/ia64/kernel/dma-mapping.c
+++ b/arch/ia64/kernel/dma-mapping.c
@@ -4,7 +4,7 @@
4/* Set this to 1 if there is a HW IOMMU in the system */ 4/* Set this to 1 if there is a HW IOMMU in the system */
5int iommu_detected __read_mostly; 5int iommu_detected __read_mostly;
6 6
7struct dma_map_ops *dma_ops; 7const struct dma_map_ops *dma_ops;
8EXPORT_SYMBOL(dma_ops); 8EXPORT_SYMBOL(dma_ops);
9 9
10#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16) 10#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
@@ -17,7 +17,7 @@ static int __init dma_init(void)
17} 17}
18fs_initcall(dma_init); 18fs_initcall(dma_init);
19 19
20struct dma_map_ops *dma_get_ops(struct device *dev) 20const struct dma_map_ops *dma_get_ops(struct device *dev)
21{ 21{
22 return dma_ops; 22 return dma_ops;
23} 23}
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index 992c1098c522..9094a73f996f 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -90,11 +90,11 @@ void __init pci_iommu_alloc(void)
90{ 90{
91 dma_ops = &intel_dma_ops; 91 dma_ops = &intel_dma_ops;
92 92
93 dma_ops->sync_single_for_cpu = machvec_dma_sync_single; 93 intel_dma_ops.sync_single_for_cpu = machvec_dma_sync_single;
94 dma_ops->sync_sg_for_cpu = machvec_dma_sync_sg; 94 intel_dma_ops.sync_sg_for_cpu = machvec_dma_sync_sg;
95 dma_ops->sync_single_for_device = machvec_dma_sync_single; 95 intel_dma_ops.sync_single_for_device = machvec_dma_sync_single;
96 dma_ops->sync_sg_for_device = machvec_dma_sync_sg; 96 intel_dma_ops.sync_sg_for_device = machvec_dma_sync_sg;
97 dma_ops->dma_supported = iommu_dma_supported; 97 intel_dma_ops.dma_supported = iommu_dma_supported;
98 98
99 /* 99 /*
100 * The order of these functions is important for 100 * The order of these functions is important for
diff --git a/arch/ia64/kernel/pci-swiotlb.c b/arch/ia64/kernel/pci-swiotlb.c
index 2933208c0285..a14989dacded 100644
--- a/arch/ia64/kernel/pci-swiotlb.c
+++ b/arch/ia64/kernel/pci-swiotlb.c
@@ -30,7 +30,7 @@ static void ia64_swiotlb_free_coherent(struct device *dev, size_t size,
30 swiotlb_free_coherent(dev, size, vaddr, dma_addr); 30 swiotlb_free_coherent(dev, size, vaddr, dma_addr);
31} 31}
32 32
33struct dma_map_ops swiotlb_dma_ops = { 33const struct dma_map_ops swiotlb_dma_ops = {
34 .alloc = ia64_swiotlb_alloc_coherent, 34 .alloc = ia64_swiotlb_alloc_coherent,
35 .free = ia64_swiotlb_free_coherent, 35 .free = ia64_swiotlb_free_coherent,
36 .map_page = swiotlb_map_page, 36 .map_page = swiotlb_map_page,
diff --git a/arch/m32r/include/asm/device.h b/arch/m32r/include/asm/device.h
index 4a9f35e0973f..7955a9799466 100644
--- a/arch/m32r/include/asm/device.h
+++ b/arch/m32r/include/asm/device.h
@@ -4,7 +4,7 @@
4 * This file is released under the GPLv2 4 * This file is released under the GPLv2
5 */ 5 */
6struct dev_archdata { 6struct dev_archdata {
7 struct dma_map_ops *dma_ops; 7 const struct dma_map_ops *dma_ops;
8}; 8};
9 9
10struct pdev_archdata { 10struct pdev_archdata {
diff --git a/arch/m32r/include/asm/dma-mapping.h b/arch/m32r/include/asm/dma-mapping.h
index 2c43a77fe942..99c43d2f05dc 100644
--- a/arch/m32r/include/asm/dma-mapping.h
+++ b/arch/m32r/include/asm/dma-mapping.h
@@ -10,7 +10,7 @@
10 10
11#define DMA_ERROR_CODE (~(dma_addr_t)0x0) 11#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
12 12
13static inline struct dma_map_ops *get_dma_ops(struct device *dev) 13static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
14{ 14{
15 if (dev && dev->archdata.dma_ops) 15 if (dev && dev->archdata.dma_ops)
16 return dev->archdata.dma_ops; 16 return dev->archdata.dma_ops;
diff --git a/arch/m68k/include/asm/dma-mapping.h b/arch/m68k/include/asm/dma-mapping.h
index 96c536194287..863509939d5a 100644
--- a/arch/m68k/include/asm/dma-mapping.h
+++ b/arch/m68k/include/asm/dma-mapping.h
@@ -1,9 +1,9 @@
1#ifndef _M68K_DMA_MAPPING_H 1#ifndef _M68K_DMA_MAPPING_H
2#define _M68K_DMA_MAPPING_H 2#define _M68K_DMA_MAPPING_H
3 3
4extern struct dma_map_ops m68k_dma_ops; 4extern const struct dma_map_ops m68k_dma_ops;
5 5
6static inline struct dma_map_ops *get_dma_ops(struct device *dev) 6static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
7{ 7{
8 return &m68k_dma_ops; 8 return &m68k_dma_ops;
9} 9}
diff --git a/arch/m68k/kernel/dma.c b/arch/m68k/kernel/dma.c
index 07070065a425..0fc5dabb4a42 100644
--- a/arch/m68k/kernel/dma.c
+++ b/arch/m68k/kernel/dma.c
@@ -158,7 +158,7 @@ static int m68k_dma_map_sg(struct device *dev, struct scatterlist *sglist,
158 return nents; 158 return nents;
159} 159}
160 160
161struct dma_map_ops m68k_dma_ops = { 161const struct dma_map_ops m68k_dma_ops = {
162 .alloc = m68k_dma_alloc, 162 .alloc = m68k_dma_alloc,
163 .free = m68k_dma_free, 163 .free = m68k_dma_free,
164 .map_page = m68k_dma_map_page, 164 .map_page = m68k_dma_map_page,
diff --git a/arch/metag/include/asm/dma-mapping.h b/arch/metag/include/asm/dma-mapping.h
index 27af5d479ce6..c156a7ac732f 100644
--- a/arch/metag/include/asm/dma-mapping.h
+++ b/arch/metag/include/asm/dma-mapping.h
@@ -1,9 +1,9 @@
1#ifndef _ASM_METAG_DMA_MAPPING_H 1#ifndef _ASM_METAG_DMA_MAPPING_H
2#define _ASM_METAG_DMA_MAPPING_H 2#define _ASM_METAG_DMA_MAPPING_H
3 3
4extern struct dma_map_ops metag_dma_ops; 4extern const struct dma_map_ops metag_dma_ops;
5 5
6static inline struct dma_map_ops *get_dma_ops(struct device *dev) 6static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
7{ 7{
8 return &metag_dma_ops; 8 return &metag_dma_ops;
9} 9}
diff --git a/arch/metag/kernel/dma.c b/arch/metag/kernel/dma.c
index 91968d92652b..f0ab3a498328 100644
--- a/arch/metag/kernel/dma.c
+++ b/arch/metag/kernel/dma.c
@@ -575,7 +575,7 @@ static void metag_dma_sync_sg_for_device(struct device *dev,
575 dma_sync_for_device(sg_virt(sg), sg->length, direction); 575 dma_sync_for_device(sg_virt(sg), sg->length, direction);
576} 576}
577 577
578struct dma_map_ops metag_dma_ops = { 578const struct dma_map_ops metag_dma_ops = {
579 .alloc = metag_dma_alloc, 579 .alloc = metag_dma_alloc,
580 .free = metag_dma_free, 580 .free = metag_dma_free,
581 .map_page = metag_dma_map_page, 581 .map_page = metag_dma_map_page,
diff --git a/arch/microblaze/include/asm/dma-mapping.h b/arch/microblaze/include/asm/dma-mapping.h
index 1768d4bdc8d3..c7faf2fb51d6 100644
--- a/arch/microblaze/include/asm/dma-mapping.h
+++ b/arch/microblaze/include/asm/dma-mapping.h
@@ -36,9 +36,9 @@
36/* 36/*
37 * Available generic sets of operations 37 * Available generic sets of operations
38 */ 38 */
39extern struct dma_map_ops dma_direct_ops; 39extern const struct dma_map_ops dma_direct_ops;
40 40
41static inline struct dma_map_ops *get_dma_ops(struct device *dev) 41static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
42{ 42{
43 return &dma_direct_ops; 43 return &dma_direct_ops;
44} 44}
diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c
index 818daf230eb4..12e093a03e60 100644
--- a/arch/microblaze/kernel/dma.c
+++ b/arch/microblaze/kernel/dma.c
@@ -187,7 +187,7 @@ int dma_direct_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
187#endif 187#endif
188} 188}
189 189
190struct dma_map_ops dma_direct_ops = { 190const struct dma_map_ops dma_direct_ops = {
191 .alloc = dma_direct_alloc_coherent, 191 .alloc = dma_direct_alloc_coherent,
192 .free = dma_direct_free_coherent, 192 .free = dma_direct_free_coherent,
193 .mmap = dma_direct_mmap_coherent, 193 .mmap = dma_direct_mmap_coherent,
diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c
index fd69528b24fb..897d32c888ee 100644
--- a/arch/mips/cavium-octeon/dma-octeon.c
+++ b/arch/mips/cavium-octeon/dma-octeon.c
@@ -205,7 +205,7 @@ static phys_addr_t octeon_unity_dma_to_phys(struct device *dev, dma_addr_t daddr
205} 205}
206 206
207struct octeon_dma_map_ops { 207struct octeon_dma_map_ops {
208 struct dma_map_ops dma_map_ops; 208 const struct dma_map_ops dma_map_ops;
209 dma_addr_t (*phys_to_dma)(struct device *dev, phys_addr_t paddr); 209 dma_addr_t (*phys_to_dma)(struct device *dev, phys_addr_t paddr);
210 phys_addr_t (*dma_to_phys)(struct device *dev, dma_addr_t daddr); 210 phys_addr_t (*dma_to_phys)(struct device *dev, dma_addr_t daddr);
211}; 211};
@@ -333,7 +333,7 @@ static struct octeon_dma_map_ops _octeon_pci_dma_map_ops = {
333 }, 333 },
334}; 334};
335 335
336struct dma_map_ops *octeon_pci_dma_map_ops; 336const struct dma_map_ops *octeon_pci_dma_map_ops;
337 337
338void __init octeon_pci_dma_init(void) 338void __init octeon_pci_dma_init(void)
339{ 339{
diff --git a/arch/mips/include/asm/device.h b/arch/mips/include/asm/device.h
index 21c2082a0dfb..ebc5c1265473 100644
--- a/arch/mips/include/asm/device.h
+++ b/arch/mips/include/asm/device.h
@@ -10,7 +10,7 @@ struct dma_map_ops;
10 10
11struct dev_archdata { 11struct dev_archdata {
12 /* DMA operations on that device */ 12 /* DMA operations on that device */
13 struct dma_map_ops *dma_ops; 13 const struct dma_map_ops *dma_ops;
14 14
15#ifdef CONFIG_DMA_PERDEV_COHERENT 15#ifdef CONFIG_DMA_PERDEV_COHERENT
16 /* Non-zero if DMA is coherent with CPU caches */ 16 /* Non-zero if DMA is coherent with CPU caches */
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index 7aa71b9b0258..b59b084a7569 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -9,9 +9,9 @@
9#include <dma-coherence.h> 9#include <dma-coherence.h>
10#endif 10#endif
11 11
12extern struct dma_map_ops *mips_dma_map_ops; 12extern const struct dma_map_ops *mips_dma_map_ops;
13 13
14static inline struct dma_map_ops *get_dma_ops(struct device *dev) 14static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
15{ 15{
16 if (dev && dev->archdata.dma_ops) 16 if (dev && dev->archdata.dma_ops)
17 return dev->archdata.dma_ops; 17 return dev->archdata.dma_ops;
diff --git a/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h b/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h
index 460042ee5d6f..9110988b92a1 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h
@@ -65,7 +65,7 @@ dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr);
65phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr); 65phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr);
66 66
67struct dma_map_ops; 67struct dma_map_ops;
68extern struct dma_map_ops *octeon_pci_dma_map_ops; 68extern const struct dma_map_ops *octeon_pci_dma_map_ops;
69extern char *octeon_swiotlb; 69extern char *octeon_swiotlb;
70 70
71#endif /* __ASM_MACH_CAVIUM_OCTEON_DMA_COHERENCE_H */ 71#endif /* __ASM_MACH_CAVIUM_OCTEON_DMA_COHERENCE_H */
diff --git a/arch/mips/include/asm/netlogic/common.h b/arch/mips/include/asm/netlogic/common.h
index be52c2125d71..e0717d10e650 100644
--- a/arch/mips/include/asm/netlogic/common.h
+++ b/arch/mips/include/asm/netlogic/common.h
@@ -88,7 +88,7 @@ extern struct plat_smp_ops nlm_smp_ops;
88extern char nlm_reset_entry[], nlm_reset_entry_end[]; 88extern char nlm_reset_entry[], nlm_reset_entry_end[];
89 89
90/* SWIOTLB */ 90/* SWIOTLB */
91extern struct dma_map_ops nlm_swiotlb_dma_ops; 91extern const struct dma_map_ops nlm_swiotlb_dma_ops;
92 92
93extern unsigned int nlm_threads_per_core; 93extern unsigned int nlm_threads_per_core;
94extern cpumask_t nlm_cpumask; 94extern cpumask_t nlm_cpumask;
diff --git a/arch/mips/loongson64/common/dma-swiotlb.c b/arch/mips/loongson64/common/dma-swiotlb.c
index aab4fd681e1f..7296df043d92 100644
--- a/arch/mips/loongson64/common/dma-swiotlb.c
+++ b/arch/mips/loongson64/common/dma-swiotlb.c
@@ -122,7 +122,7 @@ phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
122 return daddr; 122 return daddr;
123} 123}
124 124
125static struct dma_map_ops loongson_dma_map_ops = { 125static const struct dma_map_ops loongson_dma_map_ops = {
126 .alloc = loongson_dma_alloc_coherent, 126 .alloc = loongson_dma_alloc_coherent,
127 .free = loongson_dma_free_coherent, 127 .free = loongson_dma_free_coherent,
128 .map_page = loongson_dma_map_page, 128 .map_page = loongson_dma_map_page,
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index a39c36af97ad..1cb84472cb58 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -417,7 +417,7 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
417 417
418EXPORT_SYMBOL(dma_cache_sync); 418EXPORT_SYMBOL(dma_cache_sync);
419 419
420static struct dma_map_ops mips_default_dma_map_ops = { 420static const struct dma_map_ops mips_default_dma_map_ops = {
421 .alloc = mips_dma_alloc_coherent, 421 .alloc = mips_dma_alloc_coherent,
422 .free = mips_dma_free_coherent, 422 .free = mips_dma_free_coherent,
423 .mmap = mips_dma_mmap, 423 .mmap = mips_dma_mmap,
@@ -433,7 +433,7 @@ static struct dma_map_ops mips_default_dma_map_ops = {
433 .dma_supported = mips_dma_supported 433 .dma_supported = mips_dma_supported
434}; 434};
435 435
436struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops; 436const struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops;
437EXPORT_SYMBOL(mips_dma_map_ops); 437EXPORT_SYMBOL(mips_dma_map_ops);
438 438
439#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16) 439#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
diff --git a/arch/mips/netlogic/common/nlm-dma.c b/arch/mips/netlogic/common/nlm-dma.c
index 0630693bec2a..0ec9d9da6d51 100644
--- a/arch/mips/netlogic/common/nlm-dma.c
+++ b/arch/mips/netlogic/common/nlm-dma.c
@@ -67,7 +67,7 @@ static void nlm_dma_free_coherent(struct device *dev, size_t size,
67 swiotlb_free_coherent(dev, size, vaddr, dma_handle); 67 swiotlb_free_coherent(dev, size, vaddr, dma_handle);
68} 68}
69 69
70struct dma_map_ops nlm_swiotlb_dma_ops = { 70const struct dma_map_ops nlm_swiotlb_dma_ops = {
71 .alloc = nlm_dma_alloc_coherent, 71 .alloc = nlm_dma_alloc_coherent,
72 .free = nlm_dma_free_coherent, 72 .free = nlm_dma_free_coherent,
73 .map_page = swiotlb_map_page, 73 .map_page = swiotlb_map_page,
diff --git a/arch/mn10300/include/asm/dma-mapping.h b/arch/mn10300/include/asm/dma-mapping.h
index 1dcd44757f32..564e3927e005 100644
--- a/arch/mn10300/include/asm/dma-mapping.h
+++ b/arch/mn10300/include/asm/dma-mapping.h
@@ -14,9 +14,9 @@
14#include <asm/cache.h> 14#include <asm/cache.h>
15#include <asm/io.h> 15#include <asm/io.h>
16 16
17extern struct dma_map_ops mn10300_dma_ops; 17extern const struct dma_map_ops mn10300_dma_ops;
18 18
19static inline struct dma_map_ops *get_dma_ops(struct device *dev) 19static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
20{ 20{
21 return &mn10300_dma_ops; 21 return &mn10300_dma_ops;
22} 22}
diff --git a/arch/mn10300/mm/dma-alloc.c b/arch/mn10300/mm/dma-alloc.c
index 4f4b9029f0ea..86108d2496b3 100644
--- a/arch/mn10300/mm/dma-alloc.c
+++ b/arch/mn10300/mm/dma-alloc.c
@@ -121,7 +121,7 @@ static int mn10300_dma_supported(struct device *dev, u64 mask)
121 return 1; 121 return 1;
122} 122}
123 123
124struct dma_map_ops mn10300_dma_ops = { 124const struct dma_map_ops mn10300_dma_ops = {
125 .alloc = mn10300_dma_alloc, 125 .alloc = mn10300_dma_alloc,
126 .free = mn10300_dma_free, 126 .free = mn10300_dma_free,
127 .map_page = mn10300_dma_map_page, 127 .map_page = mn10300_dma_map_page,
diff --git a/arch/nios2/include/asm/dma-mapping.h b/arch/nios2/include/asm/dma-mapping.h
index bec8ac8e6ad2..aa00d839a64b 100644
--- a/arch/nios2/include/asm/dma-mapping.h
+++ b/arch/nios2/include/asm/dma-mapping.h
@@ -10,9 +10,9 @@
10#ifndef _ASM_NIOS2_DMA_MAPPING_H 10#ifndef _ASM_NIOS2_DMA_MAPPING_H
11#define _ASM_NIOS2_DMA_MAPPING_H 11#define _ASM_NIOS2_DMA_MAPPING_H
12 12
13extern struct dma_map_ops nios2_dma_ops; 13extern const struct dma_map_ops nios2_dma_ops;
14 14
15static inline struct dma_map_ops *get_dma_ops(struct device *dev) 15static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
16{ 16{
17 return &nios2_dma_ops; 17 return &nios2_dma_ops;
18} 18}
diff --git a/arch/nios2/mm/dma-mapping.c b/arch/nios2/mm/dma-mapping.c
index f6a5dcf9d682..7040c1adbb5e 100644
--- a/arch/nios2/mm/dma-mapping.c
+++ b/arch/nios2/mm/dma-mapping.c
@@ -192,7 +192,7 @@ static void nios2_dma_sync_sg_for_device(struct device *dev,
192 192
193} 193}
194 194
195struct dma_map_ops nios2_dma_ops = { 195const struct dma_map_ops nios2_dma_ops = {
196 .alloc = nios2_dma_alloc, 196 .alloc = nios2_dma_alloc,
197 .free = nios2_dma_free, 197 .free = nios2_dma_free,
198 .map_page = nios2_dma_map_page, 198 .map_page = nios2_dma_map_page,
diff --git a/arch/openrisc/include/asm/dma-mapping.h b/arch/openrisc/include/asm/dma-mapping.h
index 1f260bccb368..88acbedb4947 100644
--- a/arch/openrisc/include/asm/dma-mapping.h
+++ b/arch/openrisc/include/asm/dma-mapping.h
@@ -28,9 +28,9 @@
28 28
29#define DMA_ERROR_CODE (~(dma_addr_t)0x0) 29#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
30 30
31extern struct dma_map_ops or1k_dma_map_ops; 31extern const struct dma_map_ops or1k_dma_map_ops;
32 32
33static inline struct dma_map_ops *get_dma_ops(struct device *dev) 33static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
34{ 34{
35 return &or1k_dma_map_ops; 35 return &or1k_dma_map_ops;
36} 36}
diff --git a/arch/openrisc/kernel/dma.c b/arch/openrisc/kernel/dma.c
index 906998bac957..b10369b7e31b 100644
--- a/arch/openrisc/kernel/dma.c
+++ b/arch/openrisc/kernel/dma.c
@@ -232,7 +232,7 @@ or1k_sync_single_for_device(struct device *dev,
232 mtspr(SPR_DCBFR, cl); 232 mtspr(SPR_DCBFR, cl);
233} 233}
234 234
235struct dma_map_ops or1k_dma_map_ops = { 235const struct dma_map_ops or1k_dma_map_ops = {
236 .alloc = or1k_dma_alloc, 236 .alloc = or1k_dma_alloc,
237 .free = or1k_dma_free, 237 .free = or1k_dma_free,
238 .map_page = or1k_map_page, 238 .map_page = or1k_map_page,
diff --git a/arch/parisc/include/asm/dma-mapping.h b/arch/parisc/include/asm/dma-mapping.h
index 16e024602737..1749073e44fc 100644
--- a/arch/parisc/include/asm/dma-mapping.h
+++ b/arch/parisc/include/asm/dma-mapping.h
@@ -21,13 +21,13 @@
21*/ 21*/
22 22
23#ifdef CONFIG_PA11 23#ifdef CONFIG_PA11
24extern struct dma_map_ops pcxl_dma_ops; 24extern const struct dma_map_ops pcxl_dma_ops;
25extern struct dma_map_ops pcx_dma_ops; 25extern const struct dma_map_ops pcx_dma_ops;
26#endif 26#endif
27 27
28extern struct dma_map_ops *hppa_dma_ops; 28extern const struct dma_map_ops *hppa_dma_ops;
29 29
30static inline struct dma_map_ops *get_dma_ops(struct device *dev) 30static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
31{ 31{
32 return hppa_dma_ops; 32 return hppa_dma_ops;
33} 33}
diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
index 700e2d2da096..fa78419100c8 100644
--- a/arch/parisc/kernel/drivers.c
+++ b/arch/parisc/kernel/drivers.c
@@ -40,7 +40,7 @@
40#include <asm/parisc-device.h> 40#include <asm/parisc-device.h>
41 41
42/* See comments in include/asm-parisc/pci.h */ 42/* See comments in include/asm-parisc/pci.h */
43struct dma_map_ops *hppa_dma_ops __read_mostly; 43const struct dma_map_ops *hppa_dma_ops __read_mostly;
44EXPORT_SYMBOL(hppa_dma_ops); 44EXPORT_SYMBOL(hppa_dma_ops);
45 45
46static struct device root = { 46static struct device root = {
diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
index 697c53543a4d..5f0067a62738 100644
--- a/arch/parisc/kernel/pci-dma.c
+++ b/arch/parisc/kernel/pci-dma.c
@@ -572,7 +572,7 @@ static void pa11_dma_sync_sg_for_device(struct device *dev, struct scatterlist *
572 flush_kernel_vmap_range(sg_virt(sg), sg->length); 572 flush_kernel_vmap_range(sg_virt(sg), sg->length);
573} 573}
574 574
575struct dma_map_ops pcxl_dma_ops = { 575const struct dma_map_ops pcxl_dma_ops = {
576 .dma_supported = pa11_dma_supported, 576 .dma_supported = pa11_dma_supported,
577 .alloc = pa11_dma_alloc, 577 .alloc = pa11_dma_alloc,
578 .free = pa11_dma_free, 578 .free = pa11_dma_free,
@@ -608,7 +608,7 @@ static void pcx_dma_free(struct device *dev, size_t size, void *vaddr,
608 return; 608 return;
609} 609}
610 610
611struct dma_map_ops pcx_dma_ops = { 611const struct dma_map_ops pcx_dma_ops = {
612 .dma_supported = pa11_dma_supported, 612 .dma_supported = pa11_dma_supported,
613 .alloc = pcx_dma_alloc, 613 .alloc = pcx_dma_alloc,
614 .free = pcx_dma_free, 614 .free = pcx_dma_free,
diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index 406c2b1ff82d..49cbb0fca233 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -21,7 +21,7 @@ struct iommu_table;
21 */ 21 */
22struct dev_archdata { 22struct dev_archdata {
23 /* DMA operations on that device */ 23 /* DMA operations on that device */
24 struct dma_map_ops *dma_ops; 24 const struct dma_map_ops *dma_ops;
25 25
26 /* 26 /*
27 * These two used to be a union. However, with the hybrid ops we need 27 * These two used to be a union. However, with the hybrid ops we need
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 84e3f8dd5e4f..2ec3eadf336f 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -76,9 +76,9 @@ static inline unsigned long device_to_mask(struct device *dev)
76#ifdef CONFIG_PPC64 76#ifdef CONFIG_PPC64
77extern struct dma_map_ops dma_iommu_ops; 77extern struct dma_map_ops dma_iommu_ops;
78#endif 78#endif
79extern struct dma_map_ops dma_direct_ops; 79extern const struct dma_map_ops dma_direct_ops;
80 80
81static inline struct dma_map_ops *get_dma_ops(struct device *dev) 81static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
82{ 82{
83 /* We don't handle the NULL dev case for ISA for now. We could 83 /* We don't handle the NULL dev case for ISA for now. We could
84 * do it via an out of line call but it is not needed for now. The 84 * do it via an out of line call but it is not needed for now. The
@@ -91,7 +91,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
91 return dev->archdata.dma_ops; 91 return dev->archdata.dma_ops;
92} 92}
93 93
94static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) 94static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops)
95{ 95{
96 dev->archdata.dma_ops = ops; 96 dev->archdata.dma_ops = ops;
97} 97}
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index e9bd6cf0212f..93eded8d3843 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -53,8 +53,8 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
53} 53}
54 54
55#ifdef CONFIG_PCI 55#ifdef CONFIG_PCI
56extern void set_pci_dma_ops(struct dma_map_ops *dma_ops); 56extern void set_pci_dma_ops(const struct dma_map_ops *dma_ops);
57extern struct dma_map_ops *get_pci_dma_ops(void); 57extern const struct dma_map_ops *get_pci_dma_ops(void);
58#else /* CONFIG_PCI */ 58#else /* CONFIG_PCI */
59#define set_pci_dma_ops(d) 59#define set_pci_dma_ops(d)
60#define get_pci_dma_ops() NULL 60#define get_pci_dma_ops() NULL
diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
index de99d6e29430..01d45a5fd00b 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -13,7 +13,7 @@
13 13
14#include <linux/swiotlb.h> 14#include <linux/swiotlb.h>
15 15
16extern struct dma_map_ops swiotlb_dma_ops; 16extern const struct dma_map_ops swiotlb_dma_ops;
17 17
18static inline void dma_mark_clean(void *addr, size_t size) {} 18static inline void dma_mark_clean(void *addr, size_t size) {}
19 19
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index c6689f658b50..d0ea7860e02b 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -46,7 +46,7 @@ static u64 swiotlb_powerpc_get_required(struct device *dev)
46 * map_page, and unmap_page on highmem, use normal dma_ops 46 * map_page, and unmap_page on highmem, use normal dma_ops
47 * for everything else. 47 * for everything else.
48 */ 48 */
49struct dma_map_ops swiotlb_dma_ops = { 49const struct dma_map_ops swiotlb_dma_ops = {
50 .alloc = __dma_direct_alloc_coherent, 50 .alloc = __dma_direct_alloc_coherent,
51 .free = __dma_direct_free_coherent, 51 .free = __dma_direct_free_coherent,
52 .mmap = dma_direct_mmap_coherent, 52 .mmap = dma_direct_mmap_coherent,
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 6877e3fa95bb..03b98f1f98ec 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -274,7 +274,7 @@ static inline void dma_direct_sync_single(struct device *dev,
274} 274}
275#endif 275#endif
276 276
277struct dma_map_ops dma_direct_ops = { 277const struct dma_map_ops dma_direct_ops = {
278 .alloc = dma_direct_alloc_coherent, 278 .alloc = dma_direct_alloc_coherent,
279 .free = dma_direct_free_coherent, 279 .free = dma_direct_free_coherent,
280 .mmap = dma_direct_mmap_coherent, 280 .mmap = dma_direct_mmap_coherent,
@@ -316,7 +316,7 @@ EXPORT_SYMBOL(dma_set_coherent_mask);
316 316
317int __dma_set_mask(struct device *dev, u64 dma_mask) 317int __dma_set_mask(struct device *dev, u64 dma_mask)
318{ 318{
319 struct dma_map_ops *dma_ops = get_dma_ops(dev); 319 const struct dma_map_ops *dma_ops = get_dma_ops(dev);
320 320
321 if ((dma_ops != NULL) && (dma_ops->set_dma_mask != NULL)) 321 if ((dma_ops != NULL) && (dma_ops->set_dma_mask != NULL))
322 return dma_ops->set_dma_mask(dev, dma_mask); 322 return dma_ops->set_dma_mask(dev, dma_mask);
@@ -344,7 +344,7 @@ EXPORT_SYMBOL(dma_set_mask);
344 344
345u64 __dma_get_required_mask(struct device *dev) 345u64 __dma_get_required_mask(struct device *dev)
346{ 346{
347 struct dma_map_ops *dma_ops = get_dma_ops(dev); 347 const struct dma_map_ops *dma_ops = get_dma_ops(dev);
348 348
349 if (unlikely(dma_ops == NULL)) 349 if (unlikely(dma_ops == NULL))
350 return 0; 350 return 0;
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 74bec5498972..09db4778435c 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -59,14 +59,14 @@ resource_size_t isa_mem_base;
59EXPORT_SYMBOL(isa_mem_base); 59EXPORT_SYMBOL(isa_mem_base);
60 60
61 61
62static struct dma_map_ops *pci_dma_ops = &dma_direct_ops; 62static const struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
63 63
64void set_pci_dma_ops(struct dma_map_ops *dma_ops) 64void set_pci_dma_ops(const struct dma_map_ops *dma_ops)
65{ 65{
66 pci_dma_ops = dma_ops; 66 pci_dma_ops = dma_ops;
67} 67}
68 68
69struct dma_map_ops *get_pci_dma_ops(void) 69const struct dma_map_ops *get_pci_dma_ops(void)
70{ 70{
71 return pci_dma_ops; 71 return pci_dma_ops;
72} 72}
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 7ff51f96a00e..e1413e69e5fe 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -651,7 +651,7 @@ static int dma_fixed_dma_supported(struct device *dev, u64 mask)
651 651
652static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask); 652static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask);
653 653
654static struct dma_map_ops dma_iommu_fixed_ops = { 654static const struct dma_map_ops dma_iommu_fixed_ops = {
655 .alloc = dma_fixed_alloc_coherent, 655 .alloc = dma_fixed_alloc_coherent,
656 .free = dma_fixed_free_coherent, 656 .free = dma_fixed_free_coherent,
657 .map_sg = dma_fixed_map_sg, 657 .map_sg = dma_fixed_map_sg,
@@ -1172,7 +1172,7 @@ __setup("iommu_fixed=", setup_iommu_fixed);
1172 1172
1173static u64 cell_dma_get_required_mask(struct device *dev) 1173static u64 cell_dma_get_required_mask(struct device *dev)
1174{ 1174{
1175 struct dma_map_ops *dma_ops; 1175 const struct dma_map_ops *dma_ops;
1176 1176
1177 if (!dev->dma_mask) 1177 if (!dev->dma_mask)
1178 return 0; 1178 return 0;
diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
index 73b155fd4481..1c383f38031d 100644
--- a/arch/powerpc/platforms/powernv/npu-dma.c
+++ b/arch/powerpc/platforms/powernv/npu-dma.c
@@ -115,7 +115,7 @@ static u64 dma_npu_get_required_mask(struct device *dev)
115 return 0; 115 return 0;
116} 116}
117 117
118static struct dma_map_ops dma_npu_ops = { 118static const struct dma_map_ops dma_npu_ops = {
119 .map_page = dma_npu_map_page, 119 .map_page = dma_npu_map_page,
120 .map_sg = dma_npu_map_sg, 120 .map_sg = dma_npu_map_sg,
121 .alloc = dma_npu_alloc, 121 .alloc = dma_npu_alloc,
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index 8af1c15aef85..c81450d98794 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -701,7 +701,7 @@ static u64 ps3_dma_get_required_mask(struct device *_dev)
701 return DMA_BIT_MASK(32); 701 return DMA_BIT_MASK(32);
702} 702}
703 703
704static struct dma_map_ops ps3_sb_dma_ops = { 704static const struct dma_map_ops ps3_sb_dma_ops = {
705 .alloc = ps3_alloc_coherent, 705 .alloc = ps3_alloc_coherent,
706 .free = ps3_free_coherent, 706 .free = ps3_free_coherent,
707 .map_sg = ps3_sb_map_sg, 707 .map_sg = ps3_sb_map_sg,
@@ -712,7 +712,7 @@ static struct dma_map_ops ps3_sb_dma_ops = {
712 .unmap_page = ps3_unmap_page, 712 .unmap_page = ps3_unmap_page,
713}; 713};
714 714
715static struct dma_map_ops ps3_ioc0_dma_ops = { 715static const struct dma_map_ops ps3_ioc0_dma_ops = {
716 .alloc = ps3_alloc_coherent, 716 .alloc = ps3_alloc_coherent,
717 .free = ps3_free_coherent, 717 .free = ps3_free_coherent,
718 .map_sg = ps3_ioc0_map_sg, 718 .map_sg = ps3_ioc0_map_sg,
diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
index 614c28537141..2e36a0b8944a 100644
--- a/arch/powerpc/platforms/pseries/ibmebus.c
+++ b/arch/powerpc/platforms/pseries/ibmebus.c
@@ -136,7 +136,7 @@ static u64 ibmebus_dma_get_required_mask(struct device *dev)
136 return DMA_BIT_MASK(64); 136 return DMA_BIT_MASK(64);
137} 137}
138 138
139static struct dma_map_ops ibmebus_dma_ops = { 139static const struct dma_map_ops ibmebus_dma_ops = {
140 .alloc = ibmebus_alloc_coherent, 140 .alloc = ibmebus_alloc_coherent,
141 .free = ibmebus_free_coherent, 141 .free = ibmebus_free_coherent,
142 .map_sg = ibmebus_map_sg, 142 .map_sg = ibmebus_map_sg,
diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c
index 2c8fb3ec989e..720493932486 100644
--- a/arch/powerpc/platforms/pseries/vio.c
+++ b/arch/powerpc/platforms/pseries/vio.c
@@ -615,7 +615,7 @@ static u64 vio_dma_get_required_mask(struct device *dev)
615 return dma_iommu_ops.get_required_mask(dev); 615 return dma_iommu_ops.get_required_mask(dev);
616} 616}
617 617
618static struct dma_map_ops vio_dma_mapping_ops = { 618static const struct dma_map_ops vio_dma_mapping_ops = {
619 .alloc = vio_dma_iommu_alloc_coherent, 619 .alloc = vio_dma_iommu_alloc_coherent,
620 .free = vio_dma_iommu_free_coherent, 620 .free = vio_dma_iommu_free_coherent,
621 .mmap = dma_direct_mmap_coherent, 621 .mmap = dma_direct_mmap_coherent,
diff --git a/arch/s390/include/asm/device.h b/arch/s390/include/asm/device.h
index 4a9f35e0973f..7955a9799466 100644
--- a/arch/s390/include/asm/device.h
+++ b/arch/s390/include/asm/device.h
@@ -4,7 +4,7 @@
4 * This file is released under the GPLv2 4 * This file is released under the GPLv2
5 */ 5 */
6struct dev_archdata { 6struct dev_archdata {
7 struct dma_map_ops *dma_ops; 7 const struct dma_map_ops *dma_ops;
8}; 8};
9 9
10struct pdev_archdata { 10struct pdev_archdata {
diff --git a/arch/s390/include/asm/dma-mapping.h b/arch/s390/include/asm/dma-mapping.h
index ffaba07f50ab..2776d205b1ff 100644
--- a/arch/s390/include/asm/dma-mapping.h
+++ b/arch/s390/include/asm/dma-mapping.h
@@ -10,9 +10,9 @@
10 10
11#define DMA_ERROR_CODE (~(dma_addr_t) 0x0) 11#define DMA_ERROR_CODE (~(dma_addr_t) 0x0)
12 12
13extern struct dma_map_ops s390_pci_dma_ops; 13extern const struct dma_map_ops s390_pci_dma_ops;
14 14
15static inline struct dma_map_ops *get_dma_ops(struct device *dev) 15static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
16{ 16{
17 if (dev && dev->archdata.dma_ops) 17 if (dev && dev->archdata.dma_ops)
18 return dev->archdata.dma_ops; 18 return dev->archdata.dma_ops;
diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
index 1d7a9c71944a..9081a57fa340 100644
--- a/arch/s390/pci/pci_dma.c
+++ b/arch/s390/pci/pci_dma.c
@@ -650,7 +650,7 @@ static int __init dma_debug_do_init(void)
650} 650}
651fs_initcall(dma_debug_do_init); 651fs_initcall(dma_debug_do_init);
652 652
653struct dma_map_ops s390_pci_dma_ops = { 653const struct dma_map_ops s390_pci_dma_ops = {
654 .alloc = s390_dma_alloc, 654 .alloc = s390_dma_alloc,
655 .free = s390_dma_free, 655 .free = s390_dma_free,
656 .map_sg = s390_dma_map_sg, 656 .map_sg = s390_dma_map_sg,
diff --git a/arch/sh/include/asm/dma-mapping.h b/arch/sh/include/asm/dma-mapping.h
index 0052ad40e86d..a7382c34c241 100644
--- a/arch/sh/include/asm/dma-mapping.h
+++ b/arch/sh/include/asm/dma-mapping.h
@@ -1,10 +1,10 @@
1#ifndef __ASM_SH_DMA_MAPPING_H 1#ifndef __ASM_SH_DMA_MAPPING_H
2#define __ASM_SH_DMA_MAPPING_H 2#define __ASM_SH_DMA_MAPPING_H
3 3
4extern struct dma_map_ops *dma_ops; 4extern const struct dma_map_ops *dma_ops;
5extern void no_iommu_init(void); 5extern void no_iommu_init(void);
6 6
7static inline struct dma_map_ops *get_dma_ops(struct device *dev) 7static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
8{ 8{
9 return dma_ops; 9 return dma_ops;
10} 10}
diff --git a/arch/sh/kernel/dma-nommu.c b/arch/sh/kernel/dma-nommu.c
index 47fee3b6e29c..d24c707b2181 100644
--- a/arch/sh/kernel/dma-nommu.c
+++ b/arch/sh/kernel/dma-nommu.c
@@ -65,7 +65,7 @@ static void nommu_sync_sg(struct device *dev, struct scatterlist *sg,
65} 65}
66#endif 66#endif
67 67
68struct dma_map_ops nommu_dma_ops = { 68const struct dma_map_ops nommu_dma_ops = {
69 .alloc = dma_generic_alloc_coherent, 69 .alloc = dma_generic_alloc_coherent,
70 .free = dma_generic_free_coherent, 70 .free = dma_generic_free_coherent,
71 .map_page = nommu_map_page, 71 .map_page = nommu_map_page,
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 92b6976fde59..d1275adfa0ef 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -22,7 +22,7 @@
22 22
23#define PREALLOC_DMA_DEBUG_ENTRIES 4096 23#define PREALLOC_DMA_DEBUG_ENTRIES 4096
24 24
25struct dma_map_ops *dma_ops; 25const struct dma_map_ops *dma_ops;
26EXPORT_SYMBOL(dma_ops); 26EXPORT_SYMBOL(dma_ops);
27 27
28static int __init dma_init(void) 28static int __init dma_init(void)
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 1180ae254154..3d2babc0c4c6 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -18,13 +18,13 @@ static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
18 */ 18 */
19} 19}
20 20
21extern struct dma_map_ops *dma_ops; 21extern const struct dma_map_ops *dma_ops;
22extern struct dma_map_ops *leon_dma_ops; 22extern const struct dma_map_ops *leon_dma_ops;
23extern struct dma_map_ops pci32_dma_ops; 23extern const struct dma_map_ops pci32_dma_ops;
24 24
25extern struct bus_type pci_bus_type; 25extern struct bus_type pci_bus_type;
26 26
27static inline struct dma_map_ops *get_dma_ops(struct device *dev) 27static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
28{ 28{
29#ifdef CONFIG_SPARC_LEON 29#ifdef CONFIG_SPARC_LEON
30 if (sparc_cpu_model == sparc_leon) 30 if (sparc_cpu_model == sparc_leon)
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 9df997995f6b..c63ba99ca551 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -741,7 +741,7 @@ static void dma_4u_sync_sg_for_cpu(struct device *dev,
741 spin_unlock_irqrestore(&iommu->lock, flags); 741 spin_unlock_irqrestore(&iommu->lock, flags);
742} 742}
743 743
744static struct dma_map_ops sun4u_dma_ops = { 744static const struct dma_map_ops sun4u_dma_ops = {
745 .alloc = dma_4u_alloc_coherent, 745 .alloc = dma_4u_alloc_coherent,
746 .free = dma_4u_free_coherent, 746 .free = dma_4u_free_coherent,
747 .map_page = dma_4u_map_page, 747 .map_page = dma_4u_map_page,
@@ -752,7 +752,7 @@ static struct dma_map_ops sun4u_dma_ops = {
752 .sync_sg_for_cpu = dma_4u_sync_sg_for_cpu, 752 .sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
753}; 753};
754 754
755struct dma_map_ops *dma_ops = &sun4u_dma_ops; 755const struct dma_map_ops *dma_ops = &sun4u_dma_ops;
756EXPORT_SYMBOL(dma_ops); 756EXPORT_SYMBOL(dma_ops);
757 757
758int dma_supported(struct device *dev, u64 device_mask) 758int dma_supported(struct device *dev, u64 device_mask)
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 6ffaec44931a..cf20033a1458 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -401,7 +401,7 @@ static void sbus_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
401 BUG(); 401 BUG();
402} 402}
403 403
404static struct dma_map_ops sbus_dma_ops = { 404static const struct dma_map_ops sbus_dma_ops = {
405 .alloc = sbus_alloc_coherent, 405 .alloc = sbus_alloc_coherent,
406 .free = sbus_free_coherent, 406 .free = sbus_free_coherent,
407 .map_page = sbus_map_page, 407 .map_page = sbus_map_page,
@@ -637,7 +637,7 @@ static void pci32_sync_sg_for_device(struct device *device, struct scatterlist *
637 } 637 }
638} 638}
639 639
640struct dma_map_ops pci32_dma_ops = { 640const struct dma_map_ops pci32_dma_ops = {
641 .alloc = pci32_alloc_coherent, 641 .alloc = pci32_alloc_coherent,
642 .free = pci32_free_coherent, 642 .free = pci32_free_coherent,
643 .map_page = pci32_map_page, 643 .map_page = pci32_map_page,
@@ -652,10 +652,10 @@ struct dma_map_ops pci32_dma_ops = {
652EXPORT_SYMBOL(pci32_dma_ops); 652EXPORT_SYMBOL(pci32_dma_ops);
653 653
654/* leon re-uses pci32_dma_ops */ 654/* leon re-uses pci32_dma_ops */
655struct dma_map_ops *leon_dma_ops = &pci32_dma_ops; 655const struct dma_map_ops *leon_dma_ops = &pci32_dma_ops;
656EXPORT_SYMBOL(leon_dma_ops); 656EXPORT_SYMBOL(leon_dma_ops);
657 657
658struct dma_map_ops *dma_ops = &sbus_dma_ops; 658const struct dma_map_ops *dma_ops = &sbus_dma_ops;
659EXPORT_SYMBOL(dma_ops); 659EXPORT_SYMBOL(dma_ops);
660 660
661 661
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index f4daccd12bf5..68bec7c97cb8 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -669,7 +669,7 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
669 local_irq_restore(flags); 669 local_irq_restore(flags);
670} 670}
671 671
672static struct dma_map_ops sun4v_dma_ops = { 672static const struct dma_map_ops sun4v_dma_ops = {
673 .alloc = dma_4v_alloc_coherent, 673 .alloc = dma_4v_alloc_coherent,
674 .free = dma_4v_free_coherent, 674 .free = dma_4v_free_coherent,
675 .map_page = dma_4v_map_page, 675 .map_page = dma_4v_map_page,
diff --git a/arch/tile/include/asm/device.h b/arch/tile/include/asm/device.h
index 6ab8bf146d4c..25f23ac7d361 100644
--- a/arch/tile/include/asm/device.h
+++ b/arch/tile/include/asm/device.h
@@ -18,7 +18,7 @@
18 18
19struct dev_archdata { 19struct dev_archdata {
20 /* DMA operations on that device */ 20 /* DMA operations on that device */
21 struct dma_map_ops *dma_ops; 21 const struct dma_map_ops *dma_ops;
22 22
23 /* Offset of the DMA address from the PA. */ 23 /* Offset of the DMA address from the PA. */
24 dma_addr_t dma_offset; 24 dma_addr_t dma_offset;
diff --git a/arch/tile/include/asm/dma-mapping.h b/arch/tile/include/asm/dma-mapping.h
index 01ceb4a895b0..4a06cc75b856 100644
--- a/arch/tile/include/asm/dma-mapping.h
+++ b/arch/tile/include/asm/dma-mapping.h
@@ -24,12 +24,12 @@
24#define ARCH_HAS_DMA_GET_REQUIRED_MASK 24#define ARCH_HAS_DMA_GET_REQUIRED_MASK
25#endif 25#endif
26 26
27extern struct dma_map_ops *tile_dma_map_ops; 27extern const struct dma_map_ops *tile_dma_map_ops;
28extern struct dma_map_ops *gx_pci_dma_map_ops; 28extern const struct dma_map_ops *gx_pci_dma_map_ops;
29extern struct dma_map_ops *gx_legacy_pci_dma_map_ops; 29extern const struct dma_map_ops *gx_legacy_pci_dma_map_ops;
30extern struct dma_map_ops *gx_hybrid_pci_dma_map_ops; 30extern const struct dma_map_ops *gx_hybrid_pci_dma_map_ops;
31 31
32static inline struct dma_map_ops *get_dma_ops(struct device *dev) 32static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
33{ 33{
34 if (dev && dev->archdata.dma_ops) 34 if (dev && dev->archdata.dma_ops)
35 return dev->archdata.dma_ops; 35 return dev->archdata.dma_ops;
@@ -59,7 +59,7 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
59 59
60static inline void dma_mark_clean(void *addr, size_t size) {} 60static inline void dma_mark_clean(void *addr, size_t size) {}
61 61
62static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) 62static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops)
63{ 63{
64 dev->archdata.dma_ops = ops; 64 dev->archdata.dma_ops = ops;
65} 65}
diff --git a/arch/tile/kernel/pci-dma.c b/arch/tile/kernel/pci-dma.c
index 24e0f8c21f2f..569bb6dd154a 100644
--- a/arch/tile/kernel/pci-dma.c
+++ b/arch/tile/kernel/pci-dma.c
@@ -329,7 +329,7 @@ tile_dma_supported(struct device *dev, u64 mask)
329 return 1; 329 return 1;
330} 330}
331 331
332static struct dma_map_ops tile_default_dma_map_ops = { 332static const struct dma_map_ops tile_default_dma_map_ops = {
333 .alloc = tile_dma_alloc_coherent, 333 .alloc = tile_dma_alloc_coherent,
334 .free = tile_dma_free_coherent, 334 .free = tile_dma_free_coherent,
335 .map_page = tile_dma_map_page, 335 .map_page = tile_dma_map_page,
@@ -344,7 +344,7 @@ static struct dma_map_ops tile_default_dma_map_ops = {
344 .dma_supported = tile_dma_supported 344 .dma_supported = tile_dma_supported
345}; 345};
346 346
347struct dma_map_ops *tile_dma_map_ops = &tile_default_dma_map_ops; 347const struct dma_map_ops *tile_dma_map_ops = &tile_default_dma_map_ops;
348EXPORT_SYMBOL(tile_dma_map_ops); 348EXPORT_SYMBOL(tile_dma_map_ops);
349 349
350/* Generic PCI DMA mapping functions */ 350/* Generic PCI DMA mapping functions */
@@ -516,7 +516,7 @@ tile_pci_dma_supported(struct device *dev, u64 mask)
516 return 1; 516 return 1;
517} 517}
518 518
519static struct dma_map_ops tile_pci_default_dma_map_ops = { 519static const struct dma_map_ops tile_pci_default_dma_map_ops = {
520 .alloc = tile_pci_dma_alloc_coherent, 520 .alloc = tile_pci_dma_alloc_coherent,
521 .free = tile_pci_dma_free_coherent, 521 .free = tile_pci_dma_free_coherent,
522 .map_page = tile_pci_dma_map_page, 522 .map_page = tile_pci_dma_map_page,
@@ -531,7 +531,7 @@ static struct dma_map_ops tile_pci_default_dma_map_ops = {
531 .dma_supported = tile_pci_dma_supported 531 .dma_supported = tile_pci_dma_supported
532}; 532};
533 533
534struct dma_map_ops *gx_pci_dma_map_ops = &tile_pci_default_dma_map_ops; 534const struct dma_map_ops *gx_pci_dma_map_ops = &tile_pci_default_dma_map_ops;
535EXPORT_SYMBOL(gx_pci_dma_map_ops); 535EXPORT_SYMBOL(gx_pci_dma_map_ops);
536 536
537/* PCI DMA mapping functions for legacy PCI devices */ 537/* PCI DMA mapping functions for legacy PCI devices */
@@ -552,7 +552,7 @@ static void tile_swiotlb_free_coherent(struct device *dev, size_t size,
552 swiotlb_free_coherent(dev, size, vaddr, dma_addr); 552 swiotlb_free_coherent(dev, size, vaddr, dma_addr);
553} 553}
554 554
555static struct dma_map_ops pci_swiotlb_dma_ops = { 555static const struct dma_map_ops pci_swiotlb_dma_ops = {
556 .alloc = tile_swiotlb_alloc_coherent, 556 .alloc = tile_swiotlb_alloc_coherent,
557 .free = tile_swiotlb_free_coherent, 557 .free = tile_swiotlb_free_coherent,
558 .map_page = swiotlb_map_page, 558 .map_page = swiotlb_map_page,
@@ -567,7 +567,7 @@ static struct dma_map_ops pci_swiotlb_dma_ops = {
567 .mapping_error = swiotlb_dma_mapping_error, 567 .mapping_error = swiotlb_dma_mapping_error,
568}; 568};
569 569
570static struct dma_map_ops pci_hybrid_dma_ops = { 570static const struct dma_map_ops pci_hybrid_dma_ops = {
571 .alloc = tile_swiotlb_alloc_coherent, 571 .alloc = tile_swiotlb_alloc_coherent,
572 .free = tile_swiotlb_free_coherent, 572 .free = tile_swiotlb_free_coherent,
573 .map_page = tile_pci_dma_map_page, 573 .map_page = tile_pci_dma_map_page,
@@ -582,18 +582,18 @@ static struct dma_map_ops pci_hybrid_dma_ops = {
582 .dma_supported = tile_pci_dma_supported 582 .dma_supported = tile_pci_dma_supported
583}; 583};
584 584
585struct dma_map_ops *gx_legacy_pci_dma_map_ops = &pci_swiotlb_dma_ops; 585const struct dma_map_ops *gx_legacy_pci_dma_map_ops = &pci_swiotlb_dma_ops;
586struct dma_map_ops *gx_hybrid_pci_dma_map_ops = &pci_hybrid_dma_ops; 586const struct dma_map_ops *gx_hybrid_pci_dma_map_ops = &pci_hybrid_dma_ops;
587#else 587#else
588struct dma_map_ops *gx_legacy_pci_dma_map_ops; 588const struct dma_map_ops *gx_legacy_pci_dma_map_ops;
589struct dma_map_ops *gx_hybrid_pci_dma_map_ops; 589const struct dma_map_ops *gx_hybrid_pci_dma_map_ops;
590#endif 590#endif
591EXPORT_SYMBOL(gx_legacy_pci_dma_map_ops); 591EXPORT_SYMBOL(gx_legacy_pci_dma_map_ops);
592EXPORT_SYMBOL(gx_hybrid_pci_dma_map_ops); 592EXPORT_SYMBOL(gx_hybrid_pci_dma_map_ops);
593 593
594int dma_set_mask(struct device *dev, u64 mask) 594int dma_set_mask(struct device *dev, u64 mask)
595{ 595{
596 struct dma_map_ops *dma_ops = get_dma_ops(dev); 596 const struct dma_map_ops *dma_ops = get_dma_ops(dev);
597 597
598 /* 598 /*
599 * For PCI devices with 64-bit DMA addressing capability, promote 599 * For PCI devices with 64-bit DMA addressing capability, promote
@@ -623,7 +623,7 @@ EXPORT_SYMBOL(dma_set_mask);
623#ifdef CONFIG_ARCH_HAS_DMA_SET_COHERENT_MASK 623#ifdef CONFIG_ARCH_HAS_DMA_SET_COHERENT_MASK
624int dma_set_coherent_mask(struct device *dev, u64 mask) 624int dma_set_coherent_mask(struct device *dev, u64 mask)
625{ 625{
626 struct dma_map_ops *dma_ops = get_dma_ops(dev); 626 const struct dma_map_ops *dma_ops = get_dma_ops(dev);
627 627
628 /* 628 /*
629 * For PCI devices with 64-bit DMA addressing capability, promote 629 * For PCI devices with 64-bit DMA addressing capability, promote
diff --git a/arch/unicore32/include/asm/dma-mapping.h b/arch/unicore32/include/asm/dma-mapping.h
index 4749854afd03..14d7729c7b73 100644
--- a/arch/unicore32/include/asm/dma-mapping.h
+++ b/arch/unicore32/include/asm/dma-mapping.h
@@ -21,9 +21,9 @@
21#include <asm/memory.h> 21#include <asm/memory.h>
22#include <asm/cacheflush.h> 22#include <asm/cacheflush.h>
23 23
24extern struct dma_map_ops swiotlb_dma_map_ops; 24extern const struct dma_map_ops swiotlb_dma_map_ops;
25 25
26static inline struct dma_map_ops *get_dma_ops(struct device *dev) 26static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
27{ 27{
28 return &swiotlb_dma_map_ops; 28 return &swiotlb_dma_map_ops;
29} 29}
diff --git a/arch/unicore32/mm/dma-swiotlb.c b/arch/unicore32/mm/dma-swiotlb.c
index 3e9f6489ba38..525413d6690e 100644
--- a/arch/unicore32/mm/dma-swiotlb.c
+++ b/arch/unicore32/mm/dma-swiotlb.c
@@ -31,7 +31,7 @@ static void unicore_swiotlb_free_coherent(struct device *dev, size_t size,
31 swiotlb_free_coherent(dev, size, vaddr, dma_addr); 31 swiotlb_free_coherent(dev, size, vaddr, dma_addr);
32} 32}
33 33
34struct dma_map_ops swiotlb_dma_map_ops = { 34const struct dma_map_ops swiotlb_dma_map_ops = {
35 .alloc = unicore_swiotlb_alloc_coherent, 35 .alloc = unicore_swiotlb_alloc_coherent,
36 .free = unicore_swiotlb_free_coherent, 36 .free = unicore_swiotlb_free_coherent,
37 .map_sg = swiotlb_map_sg_attrs, 37 .map_sg = swiotlb_map_sg_attrs,
diff --git a/arch/x86/include/asm/device.h b/arch/x86/include/asm/device.h
index 684ed6c3aa67..b2d0b4ced7e3 100644
--- a/arch/x86/include/asm/device.h
+++ b/arch/x86/include/asm/device.h
@@ -3,7 +3,7 @@
3 3
4struct dev_archdata { 4struct dev_archdata {
5#ifdef CONFIG_X86_DEV_DMA_OPS 5#ifdef CONFIG_X86_DEV_DMA_OPS
6 struct dma_map_ops *dma_ops; 6 const struct dma_map_ops *dma_ops;
7#endif 7#endif
8#if defined(CONFIG_INTEL_IOMMU) || defined(CONFIG_AMD_IOMMU) 8#if defined(CONFIG_INTEL_IOMMU) || defined(CONFIG_AMD_IOMMU)
9 void *iommu; /* hook for IOMMU specific extension */ 9 void *iommu; /* hook for IOMMU specific extension */
@@ -13,7 +13,7 @@ struct dev_archdata {
13#if defined(CONFIG_X86_DEV_DMA_OPS) && defined(CONFIG_PCI_DOMAINS) 13#if defined(CONFIG_X86_DEV_DMA_OPS) && defined(CONFIG_PCI_DOMAINS)
14struct dma_domain { 14struct dma_domain {
15 struct list_head node; 15 struct list_head node;
16 struct dma_map_ops *dma_ops; 16 const struct dma_map_ops *dma_ops;
17 int domain_nr; 17 int domain_nr;
18}; 18};
19void add_dma_domain(struct dma_domain *domain); 19void add_dma_domain(struct dma_domain *domain);
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 44461626830e..5e4772886a1e 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -25,9 +25,9 @@ extern int iommu_merge;
25extern struct device x86_dma_fallback_dev; 25extern struct device x86_dma_fallback_dev;
26extern int panic_on_overflow; 26extern int panic_on_overflow;
27 27
28extern struct dma_map_ops *dma_ops; 28extern const struct dma_map_ops *dma_ops;
29 29
30static inline struct dma_map_ops *get_dma_ops(struct device *dev) 30static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
31{ 31{
32#ifndef CONFIG_X86_DEV_DMA_OPS 32#ifndef CONFIG_X86_DEV_DMA_OPS
33 return dma_ops; 33 return dma_ops;
diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index 345c99cef152..793869879464 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -1,7 +1,7 @@
1#ifndef _ASM_X86_IOMMU_H 1#ifndef _ASM_X86_IOMMU_H
2#define _ASM_X86_IOMMU_H 2#define _ASM_X86_IOMMU_H
3 3
4extern struct dma_map_ops nommu_dma_ops; 4extern const struct dma_map_ops nommu_dma_ops;
5extern int force_iommu, no_iommu; 5extern int force_iommu, no_iommu;
6extern int iommu_detected; 6extern int iommu_detected;
7extern int iommu_pass_through; 7extern int iommu_pass_through;
diff --git a/arch/x86/kernel/amd_gart_64.c b/arch/x86/kernel/amd_gart_64.c
index 63ff468a7986..82dfe32faaf4 100644
--- a/arch/x86/kernel/amd_gart_64.c
+++ b/arch/x86/kernel/amd_gart_64.c
@@ -695,7 +695,7 @@ static __init int init_amd_gatt(struct agp_kern_info *info)
695 return -1; 695 return -1;
696} 696}
697 697
698static struct dma_map_ops gart_dma_ops = { 698static const struct dma_map_ops gart_dma_ops = {
699 .map_sg = gart_map_sg, 699 .map_sg = gart_map_sg,
700 .unmap_sg = gart_unmap_sg, 700 .unmap_sg = gart_unmap_sg,
701 .map_page = gart_map_page, 701 .map_page = gart_map_page,
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 5d400ba1349d..17f180148c80 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -478,7 +478,7 @@ static void calgary_free_coherent(struct device *dev, size_t size,
478 free_pages((unsigned long)vaddr, get_order(size)); 478 free_pages((unsigned long)vaddr, get_order(size));
479} 479}
480 480
481static struct dma_map_ops calgary_dma_ops = { 481static const struct dma_map_ops calgary_dma_ops = {
482 .alloc = calgary_alloc_coherent, 482 .alloc = calgary_alloc_coherent,
483 .free = calgary_free_coherent, 483 .free = calgary_free_coherent,
484 .map_sg = calgary_map_sg, 484 .map_sg = calgary_map_sg,
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index d30c37750765..76f4c039baae 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -17,7 +17,7 @@
17 17
18static int forbid_dac __read_mostly; 18static int forbid_dac __read_mostly;
19 19
20struct dma_map_ops *dma_ops = &nommu_dma_ops; 20const struct dma_map_ops *dma_ops = &nommu_dma_ops;
21EXPORT_SYMBOL(dma_ops); 21EXPORT_SYMBOL(dma_ops);
22 22
23static int iommu_sac_force __read_mostly; 23static int iommu_sac_force __read_mostly;
@@ -214,7 +214,7 @@ early_param("iommu", iommu_setup);
214 214
215int dma_supported(struct device *dev, u64 mask) 215int dma_supported(struct device *dev, u64 mask)
216{ 216{
217 struct dma_map_ops *ops = get_dma_ops(dev); 217 const struct dma_map_ops *ops = get_dma_ops(dev);
218 218
219#ifdef CONFIG_PCI 219#ifdef CONFIG_PCI
220 if (mask > 0xffffffff && forbid_dac > 0) { 220 if (mask > 0xffffffff && forbid_dac > 0) {
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index 00e71ce396a8..a88952ef371c 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -88,7 +88,7 @@ static void nommu_sync_sg_for_device(struct device *dev,
88 flush_write_buffers(); 88 flush_write_buffers();
89} 89}
90 90
91struct dma_map_ops nommu_dma_ops = { 91const struct dma_map_ops nommu_dma_ops = {
92 .alloc = dma_generic_alloc_coherent, 92 .alloc = dma_generic_alloc_coherent,
93 .free = dma_generic_free_coherent, 93 .free = dma_generic_free_coherent,
94 .map_sg = nommu_map_sg, 94 .map_sg = nommu_map_sg,
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index 410efb2c7b80..1e23577e17cf 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -45,7 +45,7 @@ void x86_swiotlb_free_coherent(struct device *dev, size_t size,
45 dma_generic_free_coherent(dev, size, vaddr, dma_addr, attrs); 45 dma_generic_free_coherent(dev, size, vaddr, dma_addr, attrs);
46} 46}
47 47
48static struct dma_map_ops swiotlb_dma_ops = { 48static const struct dma_map_ops swiotlb_dma_ops = {
49 .mapping_error = swiotlb_dma_mapping_error, 49 .mapping_error = swiotlb_dma_mapping_error,
50 .alloc = x86_swiotlb_alloc_coherent, 50 .alloc = x86_swiotlb_alloc_coherent,
51 .free = x86_swiotlb_free_coherent, 51 .free = x86_swiotlb_free_coherent,
diff --git a/arch/x86/pci/sta2x11-fixup.c b/arch/x86/pci/sta2x11-fixup.c
index 052c1cb76305..aa3828823170 100644
--- a/arch/x86/pci/sta2x11-fixup.c
+++ b/arch/x86/pci/sta2x11-fixup.c
@@ -179,7 +179,7 @@ static void *sta2x11_swiotlb_alloc_coherent(struct device *dev,
179} 179}
180 180
181/* We have our own dma_ops: the same as swiotlb but from alloc (above) */ 181/* We have our own dma_ops: the same as swiotlb but from alloc (above) */
182static struct dma_map_ops sta2x11_dma_ops = { 182static const struct dma_map_ops sta2x11_dma_ops = {
183 .alloc = sta2x11_swiotlb_alloc_coherent, 183 .alloc = sta2x11_swiotlb_alloc_coherent,
184 .free = x86_swiotlb_free_coherent, 184 .free = x86_swiotlb_free_coherent,
185 .map_page = swiotlb_map_page, 185 .map_page = swiotlb_map_page,
diff --git a/arch/x86/xen/pci-swiotlb-xen.c b/arch/x86/xen/pci-swiotlb-xen.c
index a0b36a9d5df1..42b08f8fc2ca 100644
--- a/arch/x86/xen/pci-swiotlb-xen.c
+++ b/arch/x86/xen/pci-swiotlb-xen.c
@@ -18,7 +18,7 @@
18 18
19int xen_swiotlb __read_mostly; 19int xen_swiotlb __read_mostly;
20 20
21static struct dma_map_ops xen_swiotlb_dma_ops = { 21static const struct dma_map_ops xen_swiotlb_dma_ops = {
22 .alloc = xen_swiotlb_alloc_coherent, 22 .alloc = xen_swiotlb_alloc_coherent,
23 .free = xen_swiotlb_free_coherent, 23 .free = xen_swiotlb_free_coherent,
24 .sync_single_for_cpu = xen_swiotlb_sync_single_for_cpu, 24 .sync_single_for_cpu = xen_swiotlb_sync_single_for_cpu,
diff --git a/arch/xtensa/include/asm/device.h b/arch/xtensa/include/asm/device.h
index fe1f5c878493..a77d45d39f35 100644
--- a/arch/xtensa/include/asm/device.h
+++ b/arch/xtensa/include/asm/device.h
@@ -10,7 +10,7 @@ struct dma_map_ops;
10 10
11struct dev_archdata { 11struct dev_archdata {
12 /* DMA operations on that device */ 12 /* DMA operations on that device */
13 struct dma_map_ops *dma_ops; 13 const struct dma_map_ops *dma_ops;
14}; 14};
15 15
16struct pdev_archdata { 16struct pdev_archdata {
diff --git a/arch/xtensa/include/asm/dma-mapping.h b/arch/xtensa/include/asm/dma-mapping.h
index 3fc1170a6488..50d23106cce0 100644
--- a/arch/xtensa/include/asm/dma-mapping.h
+++ b/arch/xtensa/include/asm/dma-mapping.h
@@ -18,9 +18,9 @@
18 18
19#define DMA_ERROR_CODE (~(dma_addr_t)0x0) 19#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
20 20
21extern struct dma_map_ops xtensa_dma_map_ops; 21extern const struct dma_map_ops xtensa_dma_map_ops;
22 22
23static inline struct dma_map_ops *get_dma_ops(struct device *dev) 23static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
24{ 24{
25 if (dev && dev->archdata.dma_ops) 25 if (dev && dev->archdata.dma_ops)
26 return dev->archdata.dma_ops; 26 return dev->archdata.dma_ops;
diff --git a/arch/xtensa/kernel/pci-dma.c b/arch/xtensa/kernel/pci-dma.c
index 70e362e6038e..ecec5265a66d 100644
--- a/arch/xtensa/kernel/pci-dma.c
+++ b/arch/xtensa/kernel/pci-dma.c
@@ -249,7 +249,7 @@ int xtensa_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
249 return 0; 249 return 0;
250} 250}
251 251
252struct dma_map_ops xtensa_dma_map_ops = { 252const struct dma_map_ops xtensa_dma_map_ops = {
253 .alloc = xtensa_dma_alloc, 253 .alloc = xtensa_dma_alloc,
254 .free = xtensa_dma_free, 254 .free = xtensa_dma_free,
255 .map_page = xtensa_map_page, 255 .map_page = xtensa_map_page,
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 3ef0f42984f2..3703fb9db419 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -117,7 +117,7 @@ static const struct iommu_ops amd_iommu_ops;
117static ATOMIC_NOTIFIER_HEAD(ppr_notifier); 117static ATOMIC_NOTIFIER_HEAD(ppr_notifier);
118int amd_iommu_max_glx_val = -1; 118int amd_iommu_max_glx_val = -1;
119 119
120static struct dma_map_ops amd_iommu_dma_ops; 120static const struct dma_map_ops amd_iommu_dma_ops;
121 121
122/* 122/*
123 * This struct contains device specific data for the IOMMU 123 * This struct contains device specific data for the IOMMU
@@ -2728,7 +2728,7 @@ static int amd_iommu_dma_supported(struct device *dev, u64 mask)
2728 return check_device(dev); 2728 return check_device(dev);
2729} 2729}
2730 2730
2731static struct dma_map_ops amd_iommu_dma_ops = { 2731static const struct dma_map_ops amd_iommu_dma_ops = {
2732 .alloc = alloc_coherent, 2732 .alloc = alloc_coherent,
2733 .free = free_coherent, 2733 .free = free_coherent,
2734 .map_page = map_page, 2734 .map_page = map_page,
diff --git a/drivers/misc/mic/bus/mic_bus.c b/drivers/misc/mic/bus/mic_bus.c
index be37890abb93..c4b27a25662a 100644
--- a/drivers/misc/mic/bus/mic_bus.c
+++ b/drivers/misc/mic/bus/mic_bus.c
@@ -143,7 +143,7 @@ static void mbus_release_dev(struct device *d)
143} 143}
144 144
145struct mbus_device * 145struct mbus_device *
146mbus_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops, 146mbus_register_device(struct device *pdev, int id, const struct dma_map_ops *dma_ops,
147 struct mbus_hw_ops *hw_ops, int index, 147 struct mbus_hw_ops *hw_ops, int index,
148 void __iomem *mmio_va) 148 void __iomem *mmio_va)
149{ 149{
diff --git a/drivers/misc/mic/bus/scif_bus.c b/drivers/misc/mic/bus/scif_bus.c
index ff6e01c25810..e5d377e97c86 100644
--- a/drivers/misc/mic/bus/scif_bus.c
+++ b/drivers/misc/mic/bus/scif_bus.c
@@ -138,7 +138,7 @@ static void scif_release_dev(struct device *d)
138} 138}
139 139
140struct scif_hw_dev * 140struct scif_hw_dev *
141scif_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops, 141scif_register_device(struct device *pdev, int id, const struct dma_map_ops *dma_ops,
142 struct scif_hw_ops *hw_ops, u8 dnode, u8 snode, 142 struct scif_hw_ops *hw_ops, u8 dnode, u8 snode,
143 struct mic_mw *mmio, struct mic_mw *aper, void *dp, 143 struct mic_mw *mmio, struct mic_mw *aper, void *dp,
144 void __iomem *rdp, struct dma_chan **chan, int num_chan, 144 void __iomem *rdp, struct dma_chan **chan, int num_chan,
diff --git a/drivers/misc/mic/bus/scif_bus.h b/drivers/misc/mic/bus/scif_bus.h
index 94f29ac608b6..ff59568219ad 100644
--- a/drivers/misc/mic/bus/scif_bus.h
+++ b/drivers/misc/mic/bus/scif_bus.h
@@ -113,7 +113,7 @@ int scif_register_driver(struct scif_driver *driver);
113void scif_unregister_driver(struct scif_driver *driver); 113void scif_unregister_driver(struct scif_driver *driver);
114struct scif_hw_dev * 114struct scif_hw_dev *
115scif_register_device(struct device *pdev, int id, 115scif_register_device(struct device *pdev, int id,
116 struct dma_map_ops *dma_ops, 116 const struct dma_map_ops *dma_ops,
117 struct scif_hw_ops *hw_ops, u8 dnode, u8 snode, 117 struct scif_hw_ops *hw_ops, u8 dnode, u8 snode,
118 struct mic_mw *mmio, struct mic_mw *aper, 118 struct mic_mw *mmio, struct mic_mw *aper,
119 void *dp, void __iomem *rdp, 119 void *dp, void __iomem *rdp,
diff --git a/drivers/misc/mic/bus/vop_bus.c b/drivers/misc/mic/bus/vop_bus.c
index 303da222f5b6..e3caa6c53922 100644
--- a/drivers/misc/mic/bus/vop_bus.c
+++ b/drivers/misc/mic/bus/vop_bus.c
@@ -154,7 +154,7 @@ vop_register_device(struct device *pdev, int id,
154 vdev->dev.parent = pdev; 154 vdev->dev.parent = pdev;
155 vdev->id.device = id; 155 vdev->id.device = id;
156 vdev->id.vendor = VOP_DEV_ANY_ID; 156 vdev->id.vendor = VOP_DEV_ANY_ID;
157 vdev->dev.archdata.dma_ops = (struct dma_map_ops *)dma_ops; 157 vdev->dev.archdata.dma_ops = dma_ops;
158 vdev->dev.dma_mask = &vdev->dev.coherent_dma_mask; 158 vdev->dev.dma_mask = &vdev->dev.coherent_dma_mask;
159 dma_set_mask(&vdev->dev, DMA_BIT_MASK(64)); 159 dma_set_mask(&vdev->dev, DMA_BIT_MASK(64));
160 vdev->dev.release = vop_release_dev; 160 vdev->dev.release = vop_release_dev;
diff --git a/drivers/misc/mic/host/mic_boot.c b/drivers/misc/mic/host/mic_boot.c
index 9599d732aff3..c327985c9523 100644
--- a/drivers/misc/mic/host/mic_boot.c
+++ b/drivers/misc/mic/host/mic_boot.c
@@ -245,7 +245,7 @@ static void __mic_dma_unmap_sg(struct device *dev,
245 dma_unmap_sg(&mdev->pdev->dev, sg, nents, dir); 245 dma_unmap_sg(&mdev->pdev->dev, sg, nents, dir);
246} 246}
247 247
248static struct dma_map_ops __mic_dma_ops = { 248static const struct dma_map_ops __mic_dma_ops = {
249 .alloc = __mic_dma_alloc, 249 .alloc = __mic_dma_alloc,
250 .free = __mic_dma_free, 250 .free = __mic_dma_free,
251 .map_page = __mic_dma_map_page, 251 .map_page = __mic_dma_map_page,
@@ -344,7 +344,7 @@ mic_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
344 mic_unmap_single(mdev, dma_addr, size); 344 mic_unmap_single(mdev, dma_addr, size);
345} 345}
346 346
347static struct dma_map_ops mic_dma_ops = { 347static const struct dma_map_ops mic_dma_ops = {
348 .map_page = mic_dma_map_page, 348 .map_page = mic_dma_map_page,
349 .unmap_page = mic_dma_unmap_page, 349 .unmap_page = mic_dma_unmap_page,
350}; 350};
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 553ef8a5d588..aeb073b5fe16 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -1011,7 +1011,7 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
1011 DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents); 1011 DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);
1012} 1012}
1013 1013
1014static struct dma_map_ops ccio_ops = { 1014static const struct dma_map_ops ccio_ops = {
1015 .dma_supported = ccio_dma_supported, 1015 .dma_supported = ccio_dma_supported,
1016 .alloc = ccio_alloc, 1016 .alloc = ccio_alloc,
1017 .free = ccio_free, 1017 .free = ccio_free,
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 151b86b6d2e2..33385e574433 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -1069,7 +1069,7 @@ sba_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
1069 1069
1070} 1070}
1071 1071
1072static struct dma_map_ops sba_ops = { 1072static const struct dma_map_ops sba_ops = {
1073 .dma_supported = sba_dma_supported, 1073 .dma_supported = sba_dma_supported,
1074 .alloc = sba_alloc, 1074 .alloc = sba_alloc,
1075 .free = sba_free, 1075 .free = sba_free,
diff --git a/drivers/pci/host/vmd.c b/drivers/pci/host/vmd.c
index 18ef1a93c10a..e27ad2a3bd33 100644
--- a/drivers/pci/host/vmd.c
+++ b/drivers/pci/host/vmd.c
@@ -282,7 +282,7 @@ static struct device *to_vmd_dev(struct device *dev)
282 return &vmd->dev->dev; 282 return &vmd->dev->dev;
283} 283}
284 284
285static struct dma_map_ops *vmd_dma_ops(struct device *dev) 285static const struct dma_map_ops *vmd_dma_ops(struct device *dev)
286{ 286{
287 return get_dma_ops(to_vmd_dev(dev)); 287 return get_dma_ops(to_vmd_dev(dev));
288} 288}
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 10c5a17b1f51..f1da68b82c63 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -127,7 +127,7 @@ struct dma_map_ops {
127 int is_phys; 127 int is_phys;
128}; 128};
129 129
130extern struct dma_map_ops dma_noop_ops; 130extern const struct dma_map_ops dma_noop_ops;
131 131
132#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) 132#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
133 133
@@ -170,8 +170,8 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma,
170 * dma dependent code. Code that depends on the dma-mapping 170 * dma dependent code. Code that depends on the dma-mapping
171 * API needs to set 'depends on HAS_DMA' in its Kconfig 171 * API needs to set 'depends on HAS_DMA' in its Kconfig
172 */ 172 */
173extern struct dma_map_ops bad_dma_ops; 173extern const struct dma_map_ops bad_dma_ops;
174static inline struct dma_map_ops *get_dma_ops(struct device *dev) 174static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
175{ 175{
176 return &bad_dma_ops; 176 return &bad_dma_ops;
177} 177}
@@ -182,7 +182,7 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
182 enum dma_data_direction dir, 182 enum dma_data_direction dir,
183 unsigned long attrs) 183 unsigned long attrs)
184{ 184{
185 struct dma_map_ops *ops = get_dma_ops(dev); 185 const struct dma_map_ops *ops = get_dma_ops(dev);
186 dma_addr_t addr; 186 dma_addr_t addr;
187 187
188 kmemcheck_mark_initialized(ptr, size); 188 kmemcheck_mark_initialized(ptr, size);
@@ -201,7 +201,7 @@ static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
201 enum dma_data_direction dir, 201 enum dma_data_direction dir,
202 unsigned long attrs) 202 unsigned long attrs)
203{ 203{
204 struct dma_map_ops *ops = get_dma_ops(dev); 204 const struct dma_map_ops *ops = get_dma_ops(dev);
205 205
206 BUG_ON(!valid_dma_direction(dir)); 206 BUG_ON(!valid_dma_direction(dir));
207 if (ops->unmap_page) 207 if (ops->unmap_page)
@@ -217,7 +217,7 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
217 int nents, enum dma_data_direction dir, 217 int nents, enum dma_data_direction dir,
218 unsigned long attrs) 218 unsigned long attrs)
219{ 219{
220 struct dma_map_ops *ops = get_dma_ops(dev); 220 const struct dma_map_ops *ops = get_dma_ops(dev);
221 int i, ents; 221 int i, ents;
222 struct scatterlist *s; 222 struct scatterlist *s;
223 223
@@ -235,7 +235,7 @@ static inline void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg
235 int nents, enum dma_data_direction dir, 235 int nents, enum dma_data_direction dir,
236 unsigned long attrs) 236 unsigned long attrs)
237{ 237{
238 struct dma_map_ops *ops = get_dma_ops(dev); 238 const struct dma_map_ops *ops = get_dma_ops(dev);
239 239
240 BUG_ON(!valid_dma_direction(dir)); 240 BUG_ON(!valid_dma_direction(dir));
241 debug_dma_unmap_sg(dev, sg, nents, dir); 241 debug_dma_unmap_sg(dev, sg, nents, dir);
@@ -249,7 +249,7 @@ static inline dma_addr_t dma_map_page_attrs(struct device *dev,
249 enum dma_data_direction dir, 249 enum dma_data_direction dir,
250 unsigned long attrs) 250 unsigned long attrs)
251{ 251{
252 struct dma_map_ops *ops = get_dma_ops(dev); 252 const struct dma_map_ops *ops = get_dma_ops(dev);
253 dma_addr_t addr; 253 dma_addr_t addr;
254 254
255 kmemcheck_mark_initialized(page_address(page) + offset, size); 255 kmemcheck_mark_initialized(page_address(page) + offset, size);
@@ -265,7 +265,7 @@ static inline void dma_unmap_page_attrs(struct device *dev,
265 enum dma_data_direction dir, 265 enum dma_data_direction dir,
266 unsigned long attrs) 266 unsigned long attrs)
267{ 267{
268 struct dma_map_ops *ops = get_dma_ops(dev); 268 const struct dma_map_ops *ops = get_dma_ops(dev);
269 269
270 BUG_ON(!valid_dma_direction(dir)); 270 BUG_ON(!valid_dma_direction(dir));
271 if (ops->unmap_page) 271 if (ops->unmap_page)
@@ -279,7 +279,7 @@ static inline dma_addr_t dma_map_resource(struct device *dev,
279 enum dma_data_direction dir, 279 enum dma_data_direction dir,
280 unsigned long attrs) 280 unsigned long attrs)
281{ 281{
282 struct dma_map_ops *ops = get_dma_ops(dev); 282 const struct dma_map_ops *ops = get_dma_ops(dev);
283 dma_addr_t addr; 283 dma_addr_t addr;
284 284
285 BUG_ON(!valid_dma_direction(dir)); 285 BUG_ON(!valid_dma_direction(dir));
@@ -300,7 +300,7 @@ static inline void dma_unmap_resource(struct device *dev, dma_addr_t addr,
300 size_t size, enum dma_data_direction dir, 300 size_t size, enum dma_data_direction dir,
301 unsigned long attrs) 301 unsigned long attrs)
302{ 302{
303 struct dma_map_ops *ops = get_dma_ops(dev); 303 const struct dma_map_ops *ops = get_dma_ops(dev);
304 304
305 BUG_ON(!valid_dma_direction(dir)); 305 BUG_ON(!valid_dma_direction(dir));
306 if (ops->unmap_resource) 306 if (ops->unmap_resource)
@@ -312,7 +312,7 @@ static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
312 size_t size, 312 size_t size,
313 enum dma_data_direction dir) 313 enum dma_data_direction dir)
314{ 314{
315 struct dma_map_ops *ops = get_dma_ops(dev); 315 const struct dma_map_ops *ops = get_dma_ops(dev);
316 316
317 BUG_ON(!valid_dma_direction(dir)); 317 BUG_ON(!valid_dma_direction(dir));
318 if (ops->sync_single_for_cpu) 318 if (ops->sync_single_for_cpu)
@@ -324,7 +324,7 @@ static inline void dma_sync_single_for_device(struct device *dev,
324 dma_addr_t addr, size_t size, 324 dma_addr_t addr, size_t size,
325 enum dma_data_direction dir) 325 enum dma_data_direction dir)
326{ 326{
327 struct dma_map_ops *ops = get_dma_ops(dev); 327 const struct dma_map_ops *ops = get_dma_ops(dev);
328 328
329 BUG_ON(!valid_dma_direction(dir)); 329 BUG_ON(!valid_dma_direction(dir));
330 if (ops->sync_single_for_device) 330 if (ops->sync_single_for_device)
@@ -364,7 +364,7 @@ static inline void
364dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, 364dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
365 int nelems, enum dma_data_direction dir) 365 int nelems, enum dma_data_direction dir)
366{ 366{
367 struct dma_map_ops *ops = get_dma_ops(dev); 367 const struct dma_map_ops *ops = get_dma_ops(dev);
368 368
369 BUG_ON(!valid_dma_direction(dir)); 369 BUG_ON(!valid_dma_direction(dir));
370 if (ops->sync_sg_for_cpu) 370 if (ops->sync_sg_for_cpu)
@@ -376,7 +376,7 @@ static inline void
376dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, 376dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
377 int nelems, enum dma_data_direction dir) 377 int nelems, enum dma_data_direction dir)
378{ 378{
379 struct dma_map_ops *ops = get_dma_ops(dev); 379 const struct dma_map_ops *ops = get_dma_ops(dev);
380 380
381 BUG_ON(!valid_dma_direction(dir)); 381 BUG_ON(!valid_dma_direction(dir));
382 if (ops->sync_sg_for_device) 382 if (ops->sync_sg_for_device)
@@ -421,7 +421,7 @@ static inline int
421dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, 421dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr,
422 dma_addr_t dma_addr, size_t size, unsigned long attrs) 422 dma_addr_t dma_addr, size_t size, unsigned long attrs)
423{ 423{
424 struct dma_map_ops *ops = get_dma_ops(dev); 424 const struct dma_map_ops *ops = get_dma_ops(dev);
425 BUG_ON(!ops); 425 BUG_ON(!ops);
426 if (ops->mmap) 426 if (ops->mmap)
427 return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs); 427 return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs);
@@ -439,7 +439,7 @@ dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt, void *cpu_addr,
439 dma_addr_t dma_addr, size_t size, 439 dma_addr_t dma_addr, size_t size,
440 unsigned long attrs) 440 unsigned long attrs)
441{ 441{
442 struct dma_map_ops *ops = get_dma_ops(dev); 442 const struct dma_map_ops *ops = get_dma_ops(dev);
443 BUG_ON(!ops); 443 BUG_ON(!ops);
444 if (ops->get_sgtable) 444 if (ops->get_sgtable)
445 return ops->get_sgtable(dev, sgt, cpu_addr, dma_addr, size, 445 return ops->get_sgtable(dev, sgt, cpu_addr, dma_addr, size,
@@ -457,7 +457,7 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size,
457 dma_addr_t *dma_handle, gfp_t flag, 457 dma_addr_t *dma_handle, gfp_t flag,
458 unsigned long attrs) 458 unsigned long attrs)
459{ 459{
460 struct dma_map_ops *ops = get_dma_ops(dev); 460 const struct dma_map_ops *ops = get_dma_ops(dev);
461 void *cpu_addr; 461 void *cpu_addr;
462 462
463 BUG_ON(!ops); 463 BUG_ON(!ops);
@@ -479,7 +479,7 @@ static inline void dma_free_attrs(struct device *dev, size_t size,
479 void *cpu_addr, dma_addr_t dma_handle, 479 void *cpu_addr, dma_addr_t dma_handle,
480 unsigned long attrs) 480 unsigned long attrs)
481{ 481{
482 struct dma_map_ops *ops = get_dma_ops(dev); 482 const struct dma_map_ops *ops = get_dma_ops(dev);
483 483
484 BUG_ON(!ops); 484 BUG_ON(!ops);
485 WARN_ON(irqs_disabled()); 485 WARN_ON(irqs_disabled());
@@ -537,7 +537,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
537#ifndef HAVE_ARCH_DMA_SUPPORTED 537#ifndef HAVE_ARCH_DMA_SUPPORTED
538static inline int dma_supported(struct device *dev, u64 mask) 538static inline int dma_supported(struct device *dev, u64 mask)
539{ 539{
540 struct dma_map_ops *ops = get_dma_ops(dev); 540 const struct dma_map_ops *ops = get_dma_ops(dev);
541 541
542 if (!ops) 542 if (!ops)
543 return 0; 543 return 0;
@@ -550,7 +550,7 @@ static inline int dma_supported(struct device *dev, u64 mask)
550#ifndef HAVE_ARCH_DMA_SET_MASK 550#ifndef HAVE_ARCH_DMA_SET_MASK
551static inline int dma_set_mask(struct device *dev, u64 mask) 551static inline int dma_set_mask(struct device *dev, u64 mask)
552{ 552{
553 struct dma_map_ops *ops = get_dma_ops(dev); 553 const struct dma_map_ops *ops = get_dma_ops(dev);
554 554
555 if (ops->set_dma_mask) 555 if (ops->set_dma_mask)
556 return ops->set_dma_mask(dev, mask); 556 return ops->set_dma_mask(dev, mask);
diff --git a/include/linux/mic_bus.h b/include/linux/mic_bus.h
index 27d7c95fd0da..504d54c71bdb 100644
--- a/include/linux/mic_bus.h
+++ b/include/linux/mic_bus.h
@@ -90,7 +90,7 @@ struct mbus_hw_ops {
90}; 90};
91 91
92struct mbus_device * 92struct mbus_device *
93mbus_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops, 93mbus_register_device(struct device *pdev, int id, const struct dma_map_ops *dma_ops,
94 struct mbus_hw_ops *hw_ops, int index, 94 struct mbus_hw_ops *hw_ops, int index,
95 void __iomem *mmio_va); 95 void __iomem *mmio_va);
96void mbus_unregister_device(struct mbus_device *mbdev); 96void mbus_unregister_device(struct mbus_device *mbdev);
diff --git a/include/xen/arm/hypervisor.h b/include/xen/arm/hypervisor.h
index 95251512e2c4..44b587b49904 100644
--- a/include/xen/arm/hypervisor.h
+++ b/include/xen/arm/hypervisor.h
@@ -18,7 +18,7 @@ static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
18 return PARAVIRT_LAZY_NONE; 18 return PARAVIRT_LAZY_NONE;
19} 19}
20 20
21extern struct dma_map_ops *xen_dma_ops; 21extern const struct dma_map_ops *xen_dma_ops;
22 22
23#ifdef CONFIG_XEN 23#ifdef CONFIG_XEN
24void __init xen_early_init(void); 24void __init xen_early_init(void);
diff --git a/lib/dma-noop.c b/lib/dma-noop.c
index 3d766e78fbe2..65e49dd35b7b 100644
--- a/lib/dma-noop.c
+++ b/lib/dma-noop.c
@@ -64,7 +64,7 @@ static int dma_noop_supported(struct device *dev, u64 mask)
64 return 1; 64 return 1;
65} 65}
66 66
67struct dma_map_ops dma_noop_ops = { 67const struct dma_map_ops dma_noop_ops = {
68 .alloc = dma_noop_alloc, 68 .alloc = dma_noop_alloc,
69 .free = dma_noop_free, 69 .free = dma_noop_free,
70 .map_page = dma_noop_map_page, 70 .map_page = dma_noop_map_page,