]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
iommu: of: enforce const-ness of struct iommu_ops
authorRobin Murphy <Robin.Murphy@arm.com>
Thu, 7 Apr 2016 17:42:05 +0000 (18:42 +0100)
committerJoerg Roedel <jroedel@suse.de>
Mon, 9 May 2016 13:33:29 +0000 (15:33 +0200)
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>
arch/arm/include/asm/dma-mapping.h
arch/arm/mm/dma-mapping.c
arch/arm64/include/asm/dma-mapping.h
arch/arm64/mm/dma-mapping.c
drivers/iommu/of_iommu.c
drivers/of/device.c
include/linux/dma-mapping.h
include/linux/of_iommu.h

index 6ad1ceda62a52cebe1063828ef8c131ebc9489c6..02283eb2f5b22b0e66db8aad31660d5100e707cb 100644 (file)
@@ -118,7 +118,7 @@ static inline unsigned long dma_max_pfn(struct device *dev)
 
 #define arch_setup_dma_ops arch_setup_dma_ops
 extern void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
-                              struct iommu_ops *iommu, bool coherent);
+                              const struct iommu_ops *iommu, bool coherent);
 
 #define arch_teardown_dma_ops arch_teardown_dma_ops
 extern void arch_teardown_dma_ops(struct device *dev);
index c941e93048ad4d2ba09dabc2bb9451eaabcf8760..5c2ca062c3fa5b43497e422131aac2fec4d4146e 100644 (file)
@@ -2215,7 +2215,7 @@ static struct dma_map_ops *arm_get_iommu_dma_map_ops(bool coherent)
 }
 
 static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
-                                   struct iommu_ops *iommu)
+                                   const struct iommu_ops *iommu)
 {
        struct dma_iommu_mapping *mapping;
 
@@ -2253,7 +2253,7 @@ static void arm_teardown_iommu_dma_ops(struct device *dev)
 #else
 
 static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
-                                   struct iommu_ops *iommu)
+                                   const struct iommu_ops *iommu)
 {
        return false;
 }
@@ -2270,7 +2270,7 @@ static struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
 }
 
 void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
-                       struct iommu_ops *iommu, bool coherent)
+                       const struct iommu_ops *iommu, bool coherent)
 {
        struct dma_map_ops *dma_ops;
 
index ba437f090a74702dd1e697db3238f6619023f83c..7dbea6c070ec400e5cd4e7bcd051f0fb8c4c84b0 100644 (file)
@@ -48,7 +48,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
 }
 
 void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
-                       struct iommu_ops *iommu, bool coherent);
+                       const struct iommu_ops *iommu, bool coherent);
 #define arch_setup_dma_ops     arch_setup_dma_ops
 
 #ifdef CONFIG_IOMMU_DMA
index a6e757cbab7785ed411e919b95c6d13caaf21726..5d36907f9b12ea21370c1a3d81e8ab6dbedaed03 100644 (file)
@@ -979,13 +979,13 @@ void arch_teardown_dma_ops(struct device *dev)
 #else
 
 static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
-                                 struct iommu_ops *iommu)
+                                 const struct iommu_ops *iommu)
 { }
 
 #endif  /* CONFIG_IOMMU_DMA */
 
 void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
-                       struct iommu_ops *iommu, bool coherent)
+                       const struct iommu_ops *iommu, bool coherent)
 {
        if (!dev->archdata.dma_ops)
                dev->archdata.dma_ops = &swiotlb_dma_ops;
index 5fea665af99d1168cd8541746f45fa6e17e5a14c..af499aea0a1a24ed154e35016c868a40df8497c4 100644 (file)
@@ -98,12 +98,12 @@ EXPORT_SYMBOL_GPL(of_get_dma_window);
 struct of_iommu_node {
        struct list_head list;
        struct device_node *np;
-       struct iommu_ops *ops;
+       const struct iommu_ops *ops;
 };
 static LIST_HEAD(of_iommu_list);
 static DEFINE_SPINLOCK(of_iommu_lock);
 
-void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops)
+void of_iommu_set_ops(struct device_node *np, const struct iommu_ops *ops)
 {
        struct of_iommu_node *iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
 
@@ -119,10 +119,10 @@ void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops)
        spin_unlock(&of_iommu_lock);
 }
 
-struct iommu_ops *of_iommu_get_ops(struct device_node *np)
+const struct iommu_ops *of_iommu_get_ops(struct device_node *np)
 {
        struct of_iommu_node *node;
-       struct iommu_ops *ops = NULL;
+       const struct iommu_ops *ops = NULL;
 
        spin_lock(&of_iommu_lock);
        list_for_each_entry(node, &of_iommu_list, list)
@@ -134,12 +134,12 @@ struct iommu_ops *of_iommu_get_ops(struct device_node *np)
        return ops;
 }
 
-struct iommu_ops *of_iommu_configure(struct device *dev,
-                                    struct device_node *master_np)
+const struct iommu_ops *of_iommu_configure(struct device *dev,
+                                          struct device_node *master_np)
 {
        struct of_phandle_args iommu_spec;
        struct device_node *np;
-       struct iommu_ops *ops = NULL;
+       const struct iommu_ops *ops = NULL;
        int idx = 0;
 
        /*
index e5f47cec75f34e046b15efbc5bcdc50073eff5c0..fd5cfad7c4030e58bb817c4b2a56c49b674a1eba 100644 (file)
@@ -88,7 +88,7 @@ void of_dma_configure(struct device *dev, struct device_node *np)
        int ret;
        bool coherent;
        unsigned long offset;
-       struct iommu_ops *iommu;
+       const struct iommu_ops *iommu;
 
        /*
         * Set default coherent_dma_mask to 32 bit.  Drivers are expected to
index 9ea9aba280498fa7f86e293044610fa321857e99..71c1b215ef6606a3f512d592f3106c4d793265de 100644 (file)
@@ -514,7 +514,7 @@ extern u64 dma_get_required_mask(struct device *dev);
 
 #ifndef arch_setup_dma_ops
 static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
-                                     u64 size, struct iommu_ops *iommu,
+                                     u64 size, const struct iommu_ops *iommu,
                                      bool coherent) { }
 #endif
 
index ffbe4707d4aa82f4ac898c6d0ca214d6a8227805..bd02b44902d041cf2d0841be779a0cd56c44b2c1 100644 (file)
@@ -12,7 +12,7 @@ extern int of_get_dma_window(struct device_node *dn, const char *prefix,
                             size_t *size);
 
 extern void of_iommu_init(void);
-extern struct iommu_ops *of_iommu_configure(struct device *dev,
+extern const struct iommu_ops *of_iommu_configure(struct device *dev,
                                        struct device_node *master_np);
 
 #else
@@ -25,7 +25,7 @@ static inline int of_get_dma_window(struct device_node *dn, const char *prefix,
 }
 
 static inline void of_iommu_init(void) { }
-static inline struct iommu_ops *of_iommu_configure(struct device *dev,
+static inline const struct iommu_ops *of_iommu_configure(struct device *dev,
                                         struct device_node *master_np)
 {
        return NULL;
@@ -33,8 +33,8 @@ static inline struct iommu_ops *of_iommu_configure(struct device *dev,
 
 #endif /* CONFIG_OF_IOMMU */
 
-void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops);
-struct iommu_ops *of_iommu_get_ops(struct device_node *np);
+void of_iommu_set_ops(struct device_node *np, const struct iommu_ops *ops);
+const struct iommu_ops *of_iommu_get_ops(struct device_node *np);
 
 extern struct of_device_id __iommu_of_table;