Skip to content

Commit 5299709

Browse files
Bart Van Asschedledford
authored andcommitted
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>
1 parent 102c5ce commit 5299709

113 files changed

Lines changed: 227 additions & 227 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/alpha/include/asm/dma-mapping.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef _ALPHA_DMA_MAPPING_H
22
#define _ALPHA_DMA_MAPPING_H
33

4-
extern struct dma_map_ops *dma_ops;
4+
extern const struct dma_map_ops *dma_ops;
55

6-
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
6+
static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
77
{
88
return dma_ops;
99
}

‎arch/alpha/kernel/pci-noop.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int alpha_noop_supported(struct device *dev, u64 mask)
128128
return mask < 0x00ffffffUL ? 0 : 1;
129129
}
130130

131-
struct dma_map_ops alpha_noop_ops = {
131+
const struct dma_map_ops alpha_noop_ops = {
132132
.alloc = alpha_noop_alloc_coherent,
133133
.free = dma_noop_free_coherent,
134134
.map_page = dma_noop_map_page,
@@ -137,5 +137,5 @@ struct dma_map_ops alpha_noop_ops = {
137137
.dma_supported = alpha_noop_supported,
138138
};
139139

140-
struct dma_map_ops *dma_ops = &alpha_noop_ops;
140+
const struct dma_map_ops *dma_ops = &alpha_noop_ops;
141141
EXPORT_SYMBOL(dma_ops);

‎arch/alpha/kernel/pci_iommu.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ static int alpha_pci_mapping_error(struct device *dev, dma_addr_t dma_addr)
939939
return dma_addr == 0;
940940
}
941941

942-
struct dma_map_ops alpha_pci_ops = {
942+
const struct dma_map_ops alpha_pci_ops = {
943943
.alloc = alpha_pci_alloc_coherent,
944944
.free = alpha_pci_free_coherent,
945945
.map_page = alpha_pci_map_page,
@@ -950,5 +950,5 @@ struct dma_map_ops alpha_pci_ops = {
950950
.dma_supported = alpha_pci_supported,
951951
};
952952

953-
struct dma_map_ops *dma_ops = &alpha_pci_ops;
953+
const struct dma_map_ops *dma_ops = &alpha_pci_ops;
954954
EXPORT_SYMBOL(dma_ops);

‎arch/arc/include/asm/dma-mapping.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#include <plat/dma.h>
1919
#endif
2020

21-
extern struct dma_map_ops arc_dma_ops;
21+
extern const struct dma_map_ops arc_dma_ops;
2222

23-
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
23+
static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
2424
{
2525
return &arc_dma_ops;
2626
}

‎arch/arc/mm/dma.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static int arc_dma_supported(struct device *dev, u64 dma_mask)
218218
return dma_mask == DMA_BIT_MASK(32);
219219
}
220220

221-
struct dma_map_ops arc_dma_ops = {
221+
const struct dma_map_ops arc_dma_ops = {
222222
.alloc = arc_dma_alloc,
223223
.free = arc_dma_free,
224224
.mmap = arc_dma_mmap,

‎arch/arm/common/dmabounce.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static int dmabounce_set_mask(struct device *dev, u64 dma_mask)
452452
return arm_dma_ops.set_dma_mask(dev, dma_mask);
453453
}
454454

455-
static struct dma_map_ops dmabounce_ops = {
455+
static const struct dma_map_ops dmabounce_ops = {
456456
.alloc = arm_dma_alloc,
457457
.free = arm_dma_free,
458458
.mmap = arm_dma_mmap,

‎arch/arm/include/asm/device.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define ASMARM_DEVICE_H
88

99
struct dev_archdata {
10-
struct dma_map_ops *dma_ops;
10+
const struct dma_map_ops *dma_ops;
1111
#ifdef CONFIG_DMABOUNCE
1212
struct dmabounce_device_info *dmabounce;
1313
#endif

‎arch/arm/include/asm/dma-mapping.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@
1313
#include <asm/xen/hypervisor.h>
1414

1515
#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
16-
extern struct dma_map_ops arm_dma_ops;
17-
extern struct dma_map_ops arm_coherent_dma_ops;
16+
extern const struct dma_map_ops arm_dma_ops;
17+
extern const struct dma_map_ops arm_coherent_dma_ops;
1818

19-
static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
19+
static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
2020
{
2121
if (dev && dev->archdata.dma_ops)
2222
return dev->archdata.dma_ops;
2323
return &arm_dma_ops;
2424
}
2525

26-
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
26+
static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
2727
{
2828
if (xen_initial_domain())
2929
return xen_dma_ops;
3030
else
3131
return __generic_dma_ops(dev);
3232
}
3333

34-
static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
34+
static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops)
3535
{
3636
BUG_ON(!dev);
3737
dev->archdata.dma_ops = ops;

‎arch/arm/mm/dma-mapping.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static void arm_dma_sync_single_for_device(struct device *dev,
180180
__dma_page_cpu_to_dev(page, offset, size, dir);
181181
}
182182

183-
struct dma_map_ops arm_dma_ops = {
183+
const struct dma_map_ops arm_dma_ops = {
184184
.alloc = arm_dma_alloc,
185185
.free = arm_dma_free,
186186
.mmap = arm_dma_mmap,
@@ -204,7 +204,7 @@ static int arm_coherent_dma_mmap(struct device *dev, struct vm_area_struct *vma,
204204
void *cpu_addr, dma_addr_t dma_addr, size_t size,
205205
unsigned long attrs);
206206

207-
struct dma_map_ops arm_coherent_dma_ops = {
207+
const struct dma_map_ops arm_coherent_dma_ops = {
208208
.alloc = arm_coherent_dma_alloc,
209209
.free = arm_coherent_dma_free,
210210
.mmap = arm_coherent_dma_mmap,
@@ -1067,7 +1067,7 @@ static void __dma_page_dev_to_cpu(struct page *page, unsigned long off,
10671067
int arm_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
10681068
enum dma_data_direction dir, unsigned long attrs)
10691069
{
1070-
struct dma_map_ops *ops = get_dma_ops(dev);
1070+
const struct dma_map_ops *ops = get_dma_ops(dev);
10711071
struct scatterlist *s;
10721072
int i, j;
10731073

@@ -1101,7 +1101,7 @@ int arm_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
11011101
void arm_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
11021102
enum dma_data_direction dir, unsigned long attrs)
11031103
{
1104-
struct dma_map_ops *ops = get_dma_ops(dev);
1104+
const struct dma_map_ops *ops = get_dma_ops(dev);
11051105
struct scatterlist *s;
11061106

11071107
int i;
@@ -1120,7 +1120,7 @@ void arm_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
11201120
void arm_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
11211121
int nents, enum dma_data_direction dir)
11221122
{
1123-
struct dma_map_ops *ops = get_dma_ops(dev);
1123+
const struct dma_map_ops *ops = get_dma_ops(dev);
11241124
struct scatterlist *s;
11251125
int i;
11261126

@@ -1139,7 +1139,7 @@ void arm_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
11391139
void arm_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
11401140
int nents, enum dma_data_direction dir)
11411141
{
1142-
struct dma_map_ops *ops = get_dma_ops(dev);
1142+
const struct dma_map_ops *ops = get_dma_ops(dev);
11431143
struct scatterlist *s;
11441144
int i;
11451145

@@ -2099,7 +2099,7 @@ static void arm_iommu_sync_single_for_device(struct device *dev,
20992099
__dma_page_cpu_to_dev(page, offset, size, dir);
21002100
}
21012101

2102-
struct dma_map_ops iommu_ops = {
2102+
const struct dma_map_ops iommu_ops = {
21032103
.alloc = arm_iommu_alloc_attrs,
21042104
.free = arm_iommu_free_attrs,
21052105
.mmap = arm_iommu_mmap_attrs,
@@ -2119,7 +2119,7 @@ struct dma_map_ops iommu_ops = {
21192119
.unmap_resource = arm_iommu_unmap_resource,
21202120
};
21212121

2122-
struct dma_map_ops iommu_coherent_ops = {
2122+
const struct dma_map_ops iommu_coherent_ops = {
21232123
.alloc = arm_coherent_iommu_alloc_attrs,
21242124
.free = arm_coherent_iommu_free_attrs,
21252125
.mmap = arm_coherent_iommu_mmap_attrs,
@@ -2319,7 +2319,7 @@ void arm_iommu_detach_device(struct device *dev)
23192319
}
23202320
EXPORT_SYMBOL_GPL(arm_iommu_detach_device);
23212321

2322-
static struct dma_map_ops *arm_get_iommu_dma_map_ops(bool coherent)
2322+
static const struct dma_map_ops *arm_get_iommu_dma_map_ops(bool coherent)
23232323
{
23242324
return coherent ? &iommu_coherent_ops : &iommu_ops;
23252325
}
@@ -2374,15 +2374,15 @@ static void arm_teardown_iommu_dma_ops(struct device *dev) { }
23742374

23752375
#endif /* CONFIG_ARM_DMA_USE_IOMMU */
23762376

2377-
static struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
2377+
static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
23782378
{
23792379
return coherent ? &arm_coherent_dma_ops : &arm_dma_ops;
23802380
}
23812381

23822382
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
23832383
const struct iommu_ops *iommu, bool coherent)
23842384
{
2385-
struct dma_map_ops *dma_ops;
2385+
const struct dma_map_ops *dma_ops;
23862386

23872387
dev->archdata.dma_coherent = coherent;
23882388
if (arm_setup_iommu_dma_ops(dev, dma_base, size, iommu))

‎arch/arm/xen/mm.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
182182
}
183183
EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
184184

185-
struct dma_map_ops *xen_dma_ops;
185+
const struct dma_map_ops *xen_dma_ops;
186186
EXPORT_SYMBOL(xen_dma_ops);
187187

188-
static struct dma_map_ops xen_swiotlb_dma_ops = {
188+
static const struct dma_map_ops xen_swiotlb_dma_ops = {
189189
.alloc = xen_swiotlb_alloc_coherent,
190190
.free = xen_swiotlb_free_coherent,
191191
.sync_single_for_cpu = xen_swiotlb_sync_single_for_cpu,

0 commit comments

Comments
 (0)