Commit b7a9662f authored by Joerg Roedel's avatar Joerg Roedel

iommu/arm-smmu-v3: Use accessor functions for iommu private data

Make use of dev_iommu_priv_set/get() functions in the code.
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
Tested-by: default avatarHanjun Guo <guohanjun@huawei.com>
Reviewed-by: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
Link: https://lore.kernel.org/r/20200326150841.10083-10-joro@8bytes.org
parent f9867f41
...@@ -2659,7 +2659,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) ...@@ -2659,7 +2659,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
if (!fwspec) if (!fwspec)
return -ENOENT; return -ENOENT;
master = fwspec->iommu_priv; master = dev_iommu_priv_get(dev);
smmu = master->smmu; smmu = master->smmu;
arm_smmu_detach_dev(master); arm_smmu_detach_dev(master);
...@@ -2795,7 +2795,7 @@ static int arm_smmu_add_device(struct device *dev) ...@@ -2795,7 +2795,7 @@ static int arm_smmu_add_device(struct device *dev)
if (!fwspec || fwspec->ops != &arm_smmu_ops) if (!fwspec || fwspec->ops != &arm_smmu_ops)
return -ENODEV; return -ENODEV;
if (WARN_ON_ONCE(fwspec->iommu_priv)) if (WARN_ON_ONCE(dev_iommu_priv_get(dev)))
return -EBUSY; return -EBUSY;
smmu = arm_smmu_get_by_fwnode(fwspec->iommu_fwnode); smmu = arm_smmu_get_by_fwnode(fwspec->iommu_fwnode);
...@@ -2810,7 +2810,7 @@ static int arm_smmu_add_device(struct device *dev) ...@@ -2810,7 +2810,7 @@ static int arm_smmu_add_device(struct device *dev)
master->smmu = smmu; master->smmu = smmu;
master->sids = fwspec->ids; master->sids = fwspec->ids;
master->num_sids = fwspec->num_ids; master->num_sids = fwspec->num_ids;
fwspec->iommu_priv = master; dev_iommu_priv_set(dev, master);
/* Check the SIDs are in range of the SMMU and our stream table */ /* Check the SIDs are in range of the SMMU and our stream table */
for (i = 0; i < master->num_sids; i++) { for (i = 0; i < master->num_sids; i++) {
...@@ -2852,7 +2852,7 @@ static int arm_smmu_add_device(struct device *dev) ...@@ -2852,7 +2852,7 @@ static int arm_smmu_add_device(struct device *dev)
iommu_device_unlink(&smmu->iommu, dev); iommu_device_unlink(&smmu->iommu, dev);
err_free_master: err_free_master:
kfree(master); kfree(master);
fwspec->iommu_priv = NULL; dev_iommu_priv_set(dev, NULL);
return ret; return ret;
} }
...@@ -2865,7 +2865,7 @@ static void arm_smmu_remove_device(struct device *dev) ...@@ -2865,7 +2865,7 @@ static void arm_smmu_remove_device(struct device *dev)
if (!fwspec || fwspec->ops != &arm_smmu_ops) if (!fwspec || fwspec->ops != &arm_smmu_ops)
return; return;
master = fwspec->iommu_priv; master = dev_iommu_priv_get(dev);
smmu = master->smmu; smmu = master->smmu;
arm_smmu_detach_dev(master); arm_smmu_detach_dev(master);
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