Skip to content

Commit c84500a

Browse files
committed
iommu/arm-smmu: Use accessor functions for iommu private data
Make use of dev_iommu_priv_set/get() functions and simplify the code where possible with this change. Signed-off-by: Joerg Roedel <[email protected]> Tested-by: Will Deacon <[email protected]> # arm-smmu Link: https://lore.kernel.org/r/[email protected]
1 parent 2465170 commit c84500a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/iommu/arm-smmu.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ static bool arm_smmu_free_sme(struct arm_smmu_device *smmu, int idx)
10591059
static int arm_smmu_master_alloc_smes(struct device *dev)
10601060
{
10611061
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
1062-
struct arm_smmu_master_cfg *cfg = fwspec->iommu_priv;
1062+
struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev);
10631063
struct arm_smmu_device *smmu = cfg->smmu;
10641064
struct arm_smmu_smr *smrs = smmu->smrs;
10651065
struct iommu_group *group;
@@ -1159,11 +1159,11 @@ static int arm_smmu_domain_add_master(struct arm_smmu_domain *smmu_domain,
11591159

11601160
static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
11611161
{
1162-
int ret;
1163-
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
11641162
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
1163+
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
11651164
struct arm_smmu_master_cfg *cfg;
11661165
struct arm_smmu_device *smmu;
1166+
int ret;
11671167

11681168
if (!fwspec || fwspec->ops != &arm_smmu_ops) {
11691169
dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n");
@@ -1177,7 +1177,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
11771177
* domains, just say no (but more politely than by dereferencing NULL).
11781178
* This should be at least a WARN_ON once that's sorted.
11791179
*/
1180-
cfg = fwspec->iommu_priv;
1180+
cfg = dev_iommu_priv_get(dev);
11811181
if (!cfg)
11821182
return -ENODEV;
11831183

@@ -1430,7 +1430,7 @@ static int arm_smmu_add_device(struct device *dev)
14301430
goto out_free;
14311431

14321432
cfg->smmu = smmu;
1433-
fwspec->iommu_priv = cfg;
1433+
dev_iommu_priv_set(dev, cfg);
14341434
while (i--)
14351435
cfg->smendx[i] = INVALID_SMENDX;
14361436

@@ -1468,7 +1468,7 @@ static void arm_smmu_remove_device(struct device *dev)
14681468
if (!fwspec || fwspec->ops != &arm_smmu_ops)
14691469
return;
14701470

1471-
cfg = fwspec->iommu_priv;
1471+
cfg = dev_iommu_priv_get(dev);
14721472
smmu = cfg->smmu;
14731473

14741474
ret = arm_smmu_rpm_get(smmu);
@@ -1480,15 +1480,16 @@ static void arm_smmu_remove_device(struct device *dev)
14801480

14811481
arm_smmu_rpm_put(smmu);
14821482

1483+
dev_iommu_priv_set(dev, NULL);
14831484
iommu_group_remove_device(dev);
1484-
kfree(fwspec->iommu_priv);
1485+
kfree(cfg);
14851486
iommu_fwspec_free(dev);
14861487
}
14871488

14881489
static struct iommu_group *arm_smmu_device_group(struct device *dev)
14891490
{
1491+
struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev);
14901492
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
1491-
struct arm_smmu_master_cfg *cfg = fwspec->iommu_priv;
14921493
struct arm_smmu_device *smmu = cfg->smmu;
14931494
struct iommu_group *group = NULL;
14941495
int i, idx;

0 commit comments

Comments
 (0)