aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Murphy <Robin.Murphy@arm.com>2016-04-07 13:42:05 -0400
committerJoerg Roedel <jroedel@suse.de>2016-05-09 09:33:29 -0400
commit53c92d793395fdab9edbd2f79b084bb6b2e6ae79 (patch)
tree57a3dd2ec3c8c3b280adab8dbe400c8c19345b40
parent3c3e8943ac6f36ca5d18ca61b30634fb560b4ebb (diff)
iommu: of: enforce const-ness of struct iommu_ops
As a set of driver-provided callbacks and static data, there is no compelling reason for struct iommu_ops to be mutable in core code, so enforce const-ness throughout. Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r--arch/arm/include/asm/dma-mapping.h2
-rw-r--r--arch/arm/mm/dma-mapping.c6
-rw-r--r--arch/arm64/include/asm/dma-mapping.h2
-rw-r--r--arch/arm64/mm/dma-mapping.c4
-rw-r--r--drivers/iommu/of_iommu.c14
-rw-r--r--drivers/of/device.c2
-rw-r--r--include/linux/dma-mapping.h2
-rw-r--r--include/linux/of_iommu.h8
8 files changed, 20 insertions, 20 deletions
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index 6ad1ceda62a5..02283eb2f5b2 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -118,7 +118,7 @@ static inline unsigned long dma_max_pfn(struct device *dev)
118 118
119#define arch_setup_dma_ops arch_setup_dma_ops 119#define arch_setup_dma_ops arch_setup_dma_ops
120extern void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, 120extern void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
121 struct iommu_ops *iommu, bool coherent); 121 const struct iommu_ops *iommu, bool coherent);
122 122
123#define arch_teardown_dma_ops arch_teardown_dma_ops 123#define arch_teardown_dma_ops arch_teardown_dma_ops
124extern void arch_teardown_dma_ops(struct device *dev); 124extern void arch_teardown_dma_ops(struct device *dev);
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index c941e93048ad..5c2ca062c3fa 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -2215,7 +2215,7 @@ static struct dma_map_ops *arm_get_iommu_dma_map_ops(bool coherent)
2215} 2215}
2216 2216
2217static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size, 2217static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
2218 struct iommu_ops *iommu) 2218 const struct iommu_ops *iommu)
2219{ 2219{
2220 struct dma_iommu_mapping *mapping; 2220 struct dma_iommu_mapping *mapping;
2221 2221
@@ -2253,7 +2253,7 @@ static void arm_teardown_iommu_dma_ops(struct device *dev)
2253#else 2253#else
2254 2254
2255static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size, 2255static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
2256 struct iommu_ops *iommu) 2256 const struct iommu_ops *iommu)
2257{ 2257{
2258 return false; 2258 return false;
2259} 2259}
@@ -2270,7 +2270,7 @@ static struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
2270} 2270}
2271 2271
2272void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, 2272void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
2273 struct iommu_ops *iommu, bool coherent) 2273 const struct iommu_ops *iommu, bool coherent)
2274{ 2274{
2275 struct dma_map_ops *dma_ops; 2275 struct dma_map_ops *dma_ops;
2276 2276
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index ba437f090a74..7dbea6c070ec 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -48,7 +48,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
48} 48}
49 49
50void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, 50void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
51 struct iommu_ops *iommu, bool coherent); 51 const struct iommu_ops *iommu, bool coherent);
52#define arch_setup_dma_ops arch_setup_dma_ops 52#define arch_setup_dma_ops arch_setup_dma_ops
53 53
54#ifdef CONFIG_IOMMU_DMA 54#ifdef CONFIG_IOMMU_DMA
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index a6e757cbab77..5d36907f9b12 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -979,13 +979,13 @@ void arch_teardown_dma_ops(struct device *dev)
979#else 979#else
980 980
981static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, 981static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
982 struct iommu_ops *iommu) 982 const struct iommu_ops *iommu)
983{ } 983{ }
984 984
985#endif /* CONFIG_IOMMU_DMA */ 985#endif /* CONFIG_IOMMU_DMA */
986 986
987void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, 987void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
988 struct iommu_ops *iommu, bool coherent) 988 const struct iommu_ops *iommu, bool coherent)
989{ 989{
990 if (!dev->archdata.dma_ops) 990 if (!dev->archdata.dma_ops)
991 dev->archdata.dma_ops = &swiotlb_dma_ops; 991 dev->archdata.dma_ops = &swiotlb_dma_ops;
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
index 5fea665af99d..af499aea0a1a 100644
--- a/drivers/iommu/of_iommu.c
+++ b/drivers/iommu/of_iommu.c
@@ -98,12 +98,12 @@ EXPORT_SYMBOL_GPL(of_get_dma_window);
98struct of_iommu_node { 98struct of_iommu_node {
99 struct list_head list; 99 struct list_head list;
100 struct device_node *np; 100 struct device_node *np;
101 struct iommu_ops *ops; 101 const struct iommu_ops *ops;
102}; 102};
103static LIST_HEAD(of_iommu_list); 103static LIST_HEAD(of_iommu_list);
104static DEFINE_SPINLOCK(of_iommu_lock); 104static DEFINE_SPINLOCK(of_iommu_lock);
105 105
106void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops) 106void of_iommu_set_ops(struct device_node *np, const struct iommu_ops *ops)
107{ 107{
108 struct of_iommu_node *iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); 108 struct of_iommu_node *iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
109 109
@@ -119,10 +119,10 @@ void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops)
119 spin_unlock(&of_iommu_lock); 119 spin_unlock(&of_iommu_lock);
120} 120}
121 121
122struct iommu_ops *of_iommu_get_ops(struct device_node *np) 122const struct iommu_ops *of_iommu_get_ops(struct device_node *np)
123{ 123{
124 struct of_iommu_node *node; 124 struct of_iommu_node *node;
125 struct iommu_ops *ops = NULL; 125 const struct iommu_ops *ops = NULL;
126 126
127 spin_lock(&of_iommu_lock); 127 spin_lock(&of_iommu_lock);
128 list_for_each_entry(node, &of_iommu_list, list) 128 list_for_each_entry(node, &of_iommu_list, list)
@@ -134,12 +134,12 @@ struct iommu_ops *of_iommu_get_ops(struct device_node *np)
134 return ops; 134 return ops;
135} 135}
136 136
137struct iommu_ops *of_iommu_configure(struct device *dev, 137const struct iommu_ops *of_iommu_configure(struct device *dev,
138 struct device_node *master_np) 138 struct device_node *master_np)
139{ 139{
140 struct of_phandle_args iommu_spec; 140 struct of_phandle_args iommu_spec;
141 struct device_node *np; 141 struct device_node *np;
142 struct iommu_ops *ops = NULL; 142 const struct iommu_ops *ops = NULL;
143 int idx = 0; 143 int idx = 0;
144 144
145 /* 145 /*
diff --git a/drivers/of/device.c b/drivers/of/device.c
index e5f47cec75f3..fd5cfad7c403 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -88,7 +88,7 @@ void of_dma_configure(struct device *dev, struct device_node *np)
88 int ret; 88 int ret;
89 bool coherent; 89 bool coherent;
90 unsigned long offset; 90 unsigned long offset;
91 struct iommu_ops *iommu; 91 const struct iommu_ops *iommu;
92 92
93 /* 93 /*
94 * Set default coherent_dma_mask to 32 bit. Drivers are expected to 94 * Set default coherent_dma_mask to 32 bit. Drivers are expected to
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 9ea9aba28049..71c1b215ef66 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -514,7 +514,7 @@ extern u64 dma_get_required_mask(struct device *dev);
514 514
515#ifndef arch_setup_dma_ops 515#ifndef arch_setup_dma_ops
516static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, 516static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
517 u64 size, struct iommu_ops *iommu, 517 u64 size, const struct iommu_ops *iommu,
518 bool coherent) { } 518 bool coherent) { }
519#endif 519#endif
520 520
diff --git a/include/linux/of_iommu.h b/include/linux/of_iommu.h
index ffbe4707d4aa..bd02b44902d0 100644
--- a/include/linux/of_iommu.h
+++ b/include/linux/of_iommu.h
@@ -12,7 +12,7 @@ extern int of_get_dma_window(struct device_node *dn, const char *prefix,
12 size_t *size); 12 size_t *size);
13 13
14extern void of_iommu_init(void); 14extern void of_iommu_init(void);
15extern struct iommu_ops *of_iommu_configure(struct device *dev, 15extern const struct iommu_ops *of_iommu_configure(struct device *dev,
16 struct device_node *master_np); 16 struct device_node *master_np);
17 17
18#else 18#else
@@ -25,7 +25,7 @@ static inline int of_get_dma_window(struct device_node *dn, const char *prefix,
25} 25}
26 26
27static inline void of_iommu_init(void) { } 27static inline void of_iommu_init(void) { }
28static inline struct iommu_ops *of_iommu_configure(struct device *dev, 28static inline const struct iommu_ops *of_iommu_configure(struct device *dev,
29 struct device_node *master_np) 29 struct device_node *master_np)
30{ 30{
31 return NULL; 31 return NULL;
@@ -33,8 +33,8 @@ static inline struct iommu_ops *of_iommu_configure(struct device *dev,
33 33
34#endif /* CONFIG_OF_IOMMU */ 34#endif /* CONFIG_OF_IOMMU */
35 35
36void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops); 36void of_iommu_set_ops(struct device_node *np, const struct iommu_ops *ops);
37struct iommu_ops *of_iommu_get_ops(struct device_node *np); 37const struct iommu_ops *of_iommu_get_ops(struct device_node *np);
38 38
39extern struct of_device_id __iommu_of_table; 39extern struct of_device_id __iommu_of_table;
40 40