Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Robin Murphy and committed by
Joerg Roedel
53c92d79 3c3e8943

+20 -20
+1 -1
arch/arm/include/asm/dma-mapping.h
··· 118 118 119 119 #define arch_setup_dma_ops arch_setup_dma_ops 120 120 extern 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 123 #define arch_teardown_dma_ops arch_teardown_dma_ops 124 124 extern void arch_teardown_dma_ops(struct device *dev);
+3 -3
arch/arm/mm/dma-mapping.c
··· 2215 2215 } 2216 2216 2217 2217 static 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 2220 struct dma_iommu_mapping *mapping; 2221 2221 ··· 2253 2253 #else 2254 2254 2255 2255 static 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 2258 return false; 2259 2259 } ··· 2270 2270 } 2271 2271 2272 2272 void 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 2275 struct dma_map_ops *dma_ops; 2276 2276
+1 -1
arch/arm64/include/asm/dma-mapping.h
··· 48 48 } 49 49 50 50 void 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 52 #define arch_setup_dma_ops arch_setup_dma_ops 53 53 54 54 #ifdef CONFIG_IOMMU_DMA
+2 -2
arch/arm64/mm/dma-mapping.c
··· 979 979 #else 980 980 981 981 static 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 985 #endif /* CONFIG_IOMMU_DMA */ 986 986 987 987 void 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 990 if (!dev->archdata.dma_ops) 991 991 dev->archdata.dma_ops = &swiotlb_dma_ops;
+7 -7
drivers/iommu/of_iommu.c
··· 98 98 struct of_iommu_node { 99 99 struct list_head list; 100 100 struct device_node *np; 101 - struct iommu_ops *ops; 101 + const struct iommu_ops *ops; 102 102 }; 103 103 static LIST_HEAD(of_iommu_list); 104 104 static DEFINE_SPINLOCK(of_iommu_lock); 105 105 106 - void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops) 106 + void of_iommu_set_ops(struct device_node *np, const struct iommu_ops *ops) 107 107 { 108 108 struct of_iommu_node *iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); 109 109 ··· 119 119 spin_unlock(&of_iommu_lock); 120 120 } 121 121 122 - struct iommu_ops *of_iommu_get_ops(struct device_node *np) 122 + const struct iommu_ops *of_iommu_get_ops(struct device_node *np) 123 123 { 124 124 struct of_iommu_node *node; 125 - struct iommu_ops *ops = NULL; 125 + const struct iommu_ops *ops = NULL; 126 126 127 127 spin_lock(&of_iommu_lock); 128 128 list_for_each_entry(node, &of_iommu_list, list) ··· 134 134 return ops; 135 135 } 136 136 137 - struct iommu_ops *of_iommu_configure(struct device *dev, 138 - struct device_node *master_np) 137 + const struct iommu_ops *of_iommu_configure(struct device *dev, 138 + struct device_node *master_np) 139 139 { 140 140 struct of_phandle_args iommu_spec; 141 141 struct device_node *np; 142 - struct iommu_ops *ops = NULL; 142 + const struct iommu_ops *ops = NULL; 143 143 int idx = 0; 144 144 145 145 /*
+1 -1
drivers/of/device.c
··· 88 88 int ret; 89 89 bool coherent; 90 90 unsigned long offset; 91 - struct iommu_ops *iommu; 91 + const struct iommu_ops *iommu; 92 92 93 93 /* 94 94 * Set default coherent_dma_mask to 32 bit. Drivers are expected to
+1 -1
include/linux/dma-mapping.h
··· 514 514 515 515 #ifndef arch_setup_dma_ops 516 516 static 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 518 bool coherent) { } 519 519 #endif 520 520
+4 -4
include/linux/of_iommu.h
··· 12 12 size_t *size); 13 13 14 14 extern void of_iommu_init(void); 15 - extern struct iommu_ops *of_iommu_configure(struct device *dev, 15 + extern const struct iommu_ops *of_iommu_configure(struct device *dev, 16 16 struct device_node *master_np); 17 17 18 18 #else ··· 25 25 } 26 26 27 27 static inline void of_iommu_init(void) { } 28 - static inline struct iommu_ops *of_iommu_configure(struct device *dev, 28 + static inline const struct iommu_ops *of_iommu_configure(struct device *dev, 29 29 struct device_node *master_np) 30 30 { 31 31 return NULL; ··· 33 33 34 34 #endif /* CONFIG_OF_IOMMU */ 35 35 36 - void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops); 37 - struct iommu_ops *of_iommu_get_ops(struct device_node *np); 36 + void of_iommu_set_ops(struct device_node *np, const struct iommu_ops *ops); 37 + const struct iommu_ops *of_iommu_get_ops(struct device_node *np); 38 38 39 39 extern struct of_device_id __iommu_of_table; 40 40