Commit b42a905b authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Joerg Roedel

iommu: constify of_phandle_args in xlate

The xlate callbacks are supposed to translate of_phandle_args to proper
provider without modifying the of_phandle_args.  Make the argument
pointer to const for code safety and readability.
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240216144027.185959-2-krzysztof.kozlowski@linaro.orgSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent e70e9ecd
...@@ -779,7 +779,8 @@ static void apple_dart_domain_free(struct iommu_domain *domain) ...@@ -779,7 +779,8 @@ static void apple_dart_domain_free(struct iommu_domain *domain)
kfree(dart_domain); kfree(dart_domain);
} }
static int apple_dart_of_xlate(struct device *dev, struct of_phandle_args *args) static int apple_dart_of_xlate(struct device *dev,
const struct of_phandle_args *args)
{ {
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
struct platform_device *iommu_pdev = of_find_device_by_node(args->np); struct platform_device *iommu_pdev = of_find_device_by_node(args->np);
......
...@@ -2704,7 +2704,8 @@ static int arm_smmu_enable_nesting(struct iommu_domain *domain) ...@@ -2704,7 +2704,8 @@ static int arm_smmu_enable_nesting(struct iommu_domain *domain)
return ret; return ret;
} }
static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args) static int arm_smmu_of_xlate(struct device *dev,
const struct of_phandle_args *args)
{ {
return iommu_fwspec_add_ids(dev, args->args, 1); return iommu_fwspec_add_ids(dev, args->args, 1);
} }
......
...@@ -1551,7 +1551,8 @@ static int arm_smmu_set_pgtable_quirks(struct iommu_domain *domain, ...@@ -1551,7 +1551,8 @@ static int arm_smmu_set_pgtable_quirks(struct iommu_domain *domain,
return ret; return ret;
} }
static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args) static int arm_smmu_of_xlate(struct device *dev,
const struct of_phandle_args *args)
{ {
u32 mask, fwid = 0; u32 mask, fwid = 0;
......
...@@ -546,7 +546,8 @@ static struct iommu_device *qcom_iommu_probe_device(struct device *dev) ...@@ -546,7 +546,8 @@ static struct iommu_device *qcom_iommu_probe_device(struct device *dev)
return &qcom_iommu->iommu; return &qcom_iommu->iommu;
} }
static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args) static int qcom_iommu_of_xlate(struct device *dev,
const struct of_phandle_args *args)
{ {
struct qcom_iommu_dev *qcom_iommu; struct qcom_iommu_dev *qcom_iommu;
struct platform_device *iommu_pdev; struct platform_device *iommu_pdev;
......
...@@ -1431,7 +1431,7 @@ static void exynos_iommu_release_device(struct device *dev) ...@@ -1431,7 +1431,7 @@ static void exynos_iommu_release_device(struct device *dev)
} }
static int exynos_iommu_of_xlate(struct device *dev, static int exynos_iommu_of_xlate(struct device *dev,
struct of_phandle_args *spec) const struct of_phandle_args *spec)
{ {
struct platform_device *sysmmu = of_find_device_by_node(spec->np); struct platform_device *sysmmu = of_find_device_by_node(spec->np);
struct exynos_iommu_owner *owner = dev_iommu_priv_get(dev); struct exynos_iommu_owner *owner = dev_iommu_priv_get(dev);
......
...@@ -2825,7 +2825,7 @@ void iommu_fwspec_free(struct device *dev) ...@@ -2825,7 +2825,7 @@ void iommu_fwspec_free(struct device *dev)
} }
EXPORT_SYMBOL_GPL(iommu_fwspec_free); EXPORT_SYMBOL_GPL(iommu_fwspec_free);
int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids) int iommu_fwspec_add_ids(struct device *dev, const u32 *ids, int num_ids)
{ {
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
int i, new_num; int i, new_num;
......
...@@ -709,7 +709,7 @@ static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain, ...@@ -709,7 +709,7 @@ static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
} }
static int ipmmu_init_platform_device(struct device *dev, static int ipmmu_init_platform_device(struct device *dev,
struct of_phandle_args *args) const struct of_phandle_args *args)
{ {
struct platform_device *ipmmu_pdev; struct platform_device *ipmmu_pdev;
...@@ -773,7 +773,7 @@ static bool ipmmu_device_is_allowed(struct device *dev) ...@@ -773,7 +773,7 @@ static bool ipmmu_device_is_allowed(struct device *dev)
} }
static int ipmmu_of_xlate(struct device *dev, static int ipmmu_of_xlate(struct device *dev,
struct of_phandle_args *spec) const struct of_phandle_args *spec)
{ {
if (!ipmmu_device_is_allowed(dev)) if (!ipmmu_device_is_allowed(dev))
return -ENODEV; return -ENODEV;
......
...@@ -598,7 +598,7 @@ static void print_ctx_regs(void __iomem *base, int ctx) ...@@ -598,7 +598,7 @@ static void print_ctx_regs(void __iomem *base, int ctx)
static int insert_iommu_master(struct device *dev, static int insert_iommu_master(struct device *dev,
struct msm_iommu_dev **iommu, struct msm_iommu_dev **iommu,
struct of_phandle_args *spec) const struct of_phandle_args *spec)
{ {
struct msm_iommu_ctx_dev *master = dev_iommu_priv_get(dev); struct msm_iommu_ctx_dev *master = dev_iommu_priv_get(dev);
int sid; int sid;
...@@ -626,7 +626,7 @@ static int insert_iommu_master(struct device *dev, ...@@ -626,7 +626,7 @@ static int insert_iommu_master(struct device *dev,
} }
static int qcom_iommu_of_xlate(struct device *dev, static int qcom_iommu_of_xlate(struct device *dev,
struct of_phandle_args *spec) const struct of_phandle_args *spec)
{ {
struct msm_iommu_dev *iommu = NULL, *iter; struct msm_iommu_dev *iommu = NULL, *iter;
unsigned long flags; unsigned long flags;
......
...@@ -957,7 +957,8 @@ static struct iommu_group *mtk_iommu_device_group(struct device *dev) ...@@ -957,7 +957,8 @@ static struct iommu_group *mtk_iommu_device_group(struct device *dev)
return group; return group;
} }
static int mtk_iommu_of_xlate(struct device *dev, struct of_phandle_args *args) static int mtk_iommu_of_xlate(struct device *dev,
const struct of_phandle_args *args)
{ {
struct platform_device *m4updev; struct platform_device *m4updev;
......
...@@ -398,7 +398,8 @@ static const struct iommu_ops mtk_iommu_v1_ops; ...@@ -398,7 +398,8 @@ static const struct iommu_ops mtk_iommu_v1_ops;
* MTK generation one iommu HW only support one iommu domain, and all the client * MTK generation one iommu HW only support one iommu domain, and all the client
* sharing the same iova address space. * sharing the same iova address space.
*/ */
static int mtk_iommu_v1_create_mapping(struct device *dev, struct of_phandle_args *args) static int mtk_iommu_v1_create_mapping(struct device *dev,
const struct of_phandle_args *args)
{ {
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
struct mtk_iommu_v1_data *data; struct mtk_iommu_v1_data *data;
......
...@@ -1140,7 +1140,7 @@ static void rk_iommu_release_device(struct device *dev) ...@@ -1140,7 +1140,7 @@ static void rk_iommu_release_device(struct device *dev)
} }
static int rk_iommu_of_xlate(struct device *dev, static int rk_iommu_of_xlate(struct device *dev,
struct of_phandle_args *args) const struct of_phandle_args *args)
{ {
struct platform_device *iommu_dev; struct platform_device *iommu_dev;
struct rk_iommudata *data; struct rk_iommudata *data;
......
...@@ -390,7 +390,8 @@ static struct iommu_device *sprd_iommu_probe_device(struct device *dev) ...@@ -390,7 +390,8 @@ static struct iommu_device *sprd_iommu_probe_device(struct device *dev)
return &sdev->iommu; return &sdev->iommu;
} }
static int sprd_iommu_of_xlate(struct device *dev, struct of_phandle_args *args) static int sprd_iommu_of_xlate(struct device *dev,
const struct of_phandle_args *args)
{ {
struct platform_device *pdev; struct platform_device *pdev;
......
...@@ -819,7 +819,7 @@ static struct iommu_device *sun50i_iommu_probe_device(struct device *dev) ...@@ -819,7 +819,7 @@ static struct iommu_device *sun50i_iommu_probe_device(struct device *dev)
} }
static int sun50i_iommu_of_xlate(struct device *dev, static int sun50i_iommu_of_xlate(struct device *dev,
struct of_phandle_args *args) const struct of_phandle_args *args)
{ {
struct platform_device *iommu_pdev = of_find_device_by_node(args->np); struct platform_device *iommu_pdev = of_find_device_by_node(args->np);
unsigned id = args->args[0]; unsigned id = args->args[0];
......
...@@ -830,7 +830,7 @@ static struct tegra_smmu *tegra_smmu_find(struct device_node *np) ...@@ -830,7 +830,7 @@ static struct tegra_smmu *tegra_smmu_find(struct device_node *np)
} }
static int tegra_smmu_configure(struct tegra_smmu *smmu, struct device *dev, static int tegra_smmu_configure(struct tegra_smmu *smmu, struct device *dev,
struct of_phandle_args *args) const struct of_phandle_args *args)
{ {
const struct iommu_ops *ops = smmu->iommu.ops; const struct iommu_ops *ops = smmu->iommu.ops;
int err; int err;
...@@ -959,7 +959,7 @@ static struct iommu_group *tegra_smmu_device_group(struct device *dev) ...@@ -959,7 +959,7 @@ static struct iommu_group *tegra_smmu_device_group(struct device *dev)
} }
static int tegra_smmu_of_xlate(struct device *dev, static int tegra_smmu_of_xlate(struct device *dev,
struct of_phandle_args *args) const struct of_phandle_args *args)
{ {
struct platform_device *iommu_pdev = of_find_device_by_node(args->np); struct platform_device *iommu_pdev = of_find_device_by_node(args->np);
struct tegra_mc *mc = platform_get_drvdata(iommu_pdev); struct tegra_mc *mc = platform_get_drvdata(iommu_pdev);
......
...@@ -1051,7 +1051,8 @@ static struct iommu_group *viommu_device_group(struct device *dev) ...@@ -1051,7 +1051,8 @@ static struct iommu_group *viommu_device_group(struct device *dev)
return generic_device_group(dev); return generic_device_group(dev);
} }
static int viommu_of_xlate(struct device *dev, struct of_phandle_args *args) static int viommu_of_xlate(struct device *dev,
const struct of_phandle_args *args)
{ {
return iommu_fwspec_add_ids(dev, args->args, 1); return iommu_fwspec_add_ids(dev, args->args, 1);
} }
......
...@@ -567,7 +567,7 @@ struct iommu_ops { ...@@ -567,7 +567,7 @@ struct iommu_ops {
/* Request/Free a list of reserved regions for a device */ /* Request/Free a list of reserved regions for a device */
void (*get_resv_regions)(struct device *dev, struct list_head *list); void (*get_resv_regions)(struct device *dev, struct list_head *list);
int (*of_xlate)(struct device *dev, struct of_phandle_args *args); int (*of_xlate)(struct device *dev, const struct of_phandle_args *args);
bool (*is_attach_deferred)(struct device *dev); bool (*is_attach_deferred)(struct device *dev);
/* Per device IOMMU features */ /* Per device IOMMU features */
...@@ -985,7 +985,7 @@ struct iommu_mm_data { ...@@ -985,7 +985,7 @@ struct iommu_mm_data {
int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode, int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode,
const struct iommu_ops *ops); const struct iommu_ops *ops);
void iommu_fwspec_free(struct device *dev); void iommu_fwspec_free(struct device *dev);
int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids); int iommu_fwspec_add_ids(struct device *dev, const u32 *ids, int num_ids);
const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode); const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode);
static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev) static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment