Commit 3524b559 authored by Joerg Roedel's avatar Joerg Roedel

iommu/mediatek: Use accessor functions for iommu private data

Make use of dev_iommu_priv_set/get() functions.
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
Reviewed-by: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
Link: https://lore.kernel.org/r/20200326150841.10083-14-joro@8bytes.org
parent be568d6d
...@@ -358,8 +358,8 @@ static void mtk_iommu_domain_free(struct iommu_domain *domain) ...@@ -358,8 +358,8 @@ static void mtk_iommu_domain_free(struct iommu_domain *domain)
static int mtk_iommu_attach_device(struct iommu_domain *domain, static int mtk_iommu_attach_device(struct iommu_domain *domain,
struct device *dev) struct device *dev)
{ {
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
struct mtk_iommu_domain *dom = to_mtk_domain(domain); struct mtk_iommu_domain *dom = to_mtk_domain(domain);
struct mtk_iommu_data *data = dev_iommu_fwspec_get(dev)->iommu_priv;
if (!data) if (!data)
return -ENODEV; return -ENODEV;
...@@ -378,7 +378,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, ...@@ -378,7 +378,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
static void mtk_iommu_detach_device(struct iommu_domain *domain, static void mtk_iommu_detach_device(struct iommu_domain *domain,
struct device *dev) struct device *dev)
{ {
struct mtk_iommu_data *data = dev_iommu_fwspec_get(dev)->iommu_priv; struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
if (!data) if (!data)
return; return;
...@@ -450,7 +450,7 @@ static int mtk_iommu_add_device(struct device *dev) ...@@ -450,7 +450,7 @@ static int mtk_iommu_add_device(struct device *dev)
if (!fwspec || fwspec->ops != &mtk_iommu_ops) if (!fwspec || fwspec->ops != &mtk_iommu_ops)
return -ENODEV; /* Not a iommu client device */ return -ENODEV; /* Not a iommu client device */
data = fwspec->iommu_priv; data = dev_iommu_priv_get(dev);
iommu_device_link(&data->iommu, dev); iommu_device_link(&data->iommu, dev);
group = iommu_group_get_for_dev(dev); group = iommu_group_get_for_dev(dev);
...@@ -469,7 +469,7 @@ static void mtk_iommu_remove_device(struct device *dev) ...@@ -469,7 +469,7 @@ static void mtk_iommu_remove_device(struct device *dev)
if (!fwspec || fwspec->ops != &mtk_iommu_ops) if (!fwspec || fwspec->ops != &mtk_iommu_ops)
return; return;
data = fwspec->iommu_priv; data = dev_iommu_priv_get(dev);
iommu_device_unlink(&data->iommu, dev); iommu_device_unlink(&data->iommu, dev);
iommu_group_remove_device(dev); iommu_group_remove_device(dev);
...@@ -496,7 +496,6 @@ static struct iommu_group *mtk_iommu_device_group(struct device *dev) ...@@ -496,7 +496,6 @@ static struct iommu_group *mtk_iommu_device_group(struct device *dev)
static int mtk_iommu_of_xlate(struct device *dev, struct of_phandle_args *args) static int mtk_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
{ {
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
struct platform_device *m4updev; struct platform_device *m4updev;
if (args->args_count != 1) { if (args->args_count != 1) {
...@@ -505,13 +504,13 @@ static int mtk_iommu_of_xlate(struct device *dev, struct of_phandle_args *args) ...@@ -505,13 +504,13 @@ static int mtk_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
return -EINVAL; return -EINVAL;
} }
if (!fwspec->iommu_priv) { if (!dev_iommu_priv_get(dev)) {
/* Get the m4u device */ /* Get the m4u device */
m4updev = of_find_device_by_node(args->np); m4updev = of_find_device_by_node(args->np);
if (WARN_ON(!m4updev)) if (WARN_ON(!m4updev))
return -EINVAL; return -EINVAL;
fwspec->iommu_priv = platform_get_drvdata(m4updev); dev_iommu_priv_set(dev, platform_get_drvdata(m4updev));
} }
return iommu_fwspec_add_ids(dev, args->args, 1); return iommu_fwspec_add_ids(dev, args->args, 1);
......
...@@ -263,8 +263,8 @@ static void mtk_iommu_domain_free(struct iommu_domain *domain) ...@@ -263,8 +263,8 @@ static void mtk_iommu_domain_free(struct iommu_domain *domain)
static int mtk_iommu_attach_device(struct iommu_domain *domain, static int mtk_iommu_attach_device(struct iommu_domain *domain,
struct device *dev) struct device *dev)
{ {
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
struct mtk_iommu_domain *dom = to_mtk_domain(domain); struct mtk_iommu_domain *dom = to_mtk_domain(domain);
struct mtk_iommu_data *data = dev_iommu_fwspec_get(dev)->iommu_priv;
int ret; int ret;
if (!data) if (!data)
...@@ -286,7 +286,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, ...@@ -286,7 +286,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
static void mtk_iommu_detach_device(struct iommu_domain *domain, static void mtk_iommu_detach_device(struct iommu_domain *domain,
struct device *dev) struct device *dev)
{ {
struct mtk_iommu_data *data = dev_iommu_fwspec_get(dev)->iommu_priv; struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
if (!data) if (!data)
return; return;
...@@ -387,20 +387,20 @@ static int mtk_iommu_create_mapping(struct device *dev, ...@@ -387,20 +387,20 @@ static int mtk_iommu_create_mapping(struct device *dev,
return -EINVAL; return -EINVAL;
} }
if (!fwspec->iommu_priv) { if (!dev_iommu_priv_get(dev)) {
/* Get the m4u device */ /* Get the m4u device */
m4updev = of_find_device_by_node(args->np); m4updev = of_find_device_by_node(args->np);
if (WARN_ON(!m4updev)) if (WARN_ON(!m4updev))
return -EINVAL; return -EINVAL;
fwspec->iommu_priv = platform_get_drvdata(m4updev); dev_iommu_priv_set(dev, platform_get_drvdata(m4updev));
} }
ret = iommu_fwspec_add_ids(dev, args->args, 1); ret = iommu_fwspec_add_ids(dev, args->args, 1);
if (ret) if (ret)
return ret; return ret;
data = fwspec->iommu_priv; data = dev_iommu_priv_get(dev);
m4udev = data->dev; m4udev = data->dev;
mtk_mapping = m4udev->archdata.iommu; mtk_mapping = m4udev->archdata.iommu;
if (!mtk_mapping) { if (!mtk_mapping) {
...@@ -459,7 +459,7 @@ static int mtk_iommu_add_device(struct device *dev) ...@@ -459,7 +459,7 @@ static int mtk_iommu_add_device(struct device *dev)
if (err) if (err)
return err; return err;
data = fwspec->iommu_priv; data = dev_iommu_priv_get(dev);
mtk_mapping = data->dev->archdata.iommu; mtk_mapping = data->dev->archdata.iommu;
err = arm_iommu_attach_device(dev, mtk_mapping); err = arm_iommu_attach_device(dev, mtk_mapping);
if (err) { if (err) {
...@@ -478,7 +478,7 @@ static void mtk_iommu_remove_device(struct device *dev) ...@@ -478,7 +478,7 @@ static void mtk_iommu_remove_device(struct device *dev)
if (!fwspec || fwspec->ops != &mtk_iommu_ops) if (!fwspec || fwspec->ops != &mtk_iommu_ops)
return; return;
data = fwspec->iommu_priv; data = dev_iommu_priv_get(dev);
iommu_device_unlink(&data->iommu, dev); iommu_device_unlink(&data->iommu, dev);
iommu_group_remove_device(dev); iommu_group_remove_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