Skip to content

Commit 3524b55

Browse files
committed
iommu/mediatek: Use accessor functions for iommu private data
Make use of dev_iommu_priv_set/get() functions. Signed-off-by: Joerg Roedel <[email protected]> Reviewed-by: Jean-Philippe Brucker <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent be568d6 commit 3524b55

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

drivers/iommu/mtk_iommu.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ static void mtk_iommu_domain_free(struct iommu_domain *domain)
358358
static int mtk_iommu_attach_device(struct iommu_domain *domain,
359359
struct device *dev)
360360
{
361+
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
361362
struct mtk_iommu_domain *dom = to_mtk_domain(domain);
362-
struct mtk_iommu_data *data = dev_iommu_fwspec_get(dev)->iommu_priv;
363363

364364
if (!data)
365365
return -ENODEV;
@@ -378,7 +378,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
378378
static void mtk_iommu_detach_device(struct iommu_domain *domain,
379379
struct device *dev)
380380
{
381-
struct mtk_iommu_data *data = dev_iommu_fwspec_get(dev)->iommu_priv;
381+
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
382382

383383
if (!data)
384384
return;
@@ -450,7 +450,7 @@ static int mtk_iommu_add_device(struct device *dev)
450450
if (!fwspec || fwspec->ops != &mtk_iommu_ops)
451451
return -ENODEV; /* Not a iommu client device */
452452

453-
data = fwspec->iommu_priv;
453+
data = dev_iommu_priv_get(dev);
454454
iommu_device_link(&data->iommu, dev);
455455

456456
group = iommu_group_get_for_dev(dev);
@@ -469,7 +469,7 @@ static void mtk_iommu_remove_device(struct device *dev)
469469
if (!fwspec || fwspec->ops != &mtk_iommu_ops)
470470
return;
471471

472-
data = fwspec->iommu_priv;
472+
data = dev_iommu_priv_get(dev);
473473
iommu_device_unlink(&data->iommu, dev);
474474

475475
iommu_group_remove_device(dev);
@@ -496,7 +496,6 @@ static struct iommu_group *mtk_iommu_device_group(struct device *dev)
496496

497497
static int mtk_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
498498
{
499-
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
500499
struct platform_device *m4updev;
501500

502501
if (args->args_count != 1) {
@@ -505,13 +504,13 @@ static int mtk_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
505504
return -EINVAL;
506505
}
507506

508-
if (!fwspec->iommu_priv) {
507+
if (!dev_iommu_priv_get(dev)) {
509508
/* Get the m4u device */
510509
m4updev = of_find_device_by_node(args->np);
511510
if (WARN_ON(!m4updev))
512511
return -EINVAL;
513512

514-
fwspec->iommu_priv = platform_get_drvdata(m4updev);
513+
dev_iommu_priv_set(dev, platform_get_drvdata(m4updev));
515514
}
516515

517516
return iommu_fwspec_add_ids(dev, args->args, 1);

drivers/iommu/mtk_iommu_v1.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ static void mtk_iommu_domain_free(struct iommu_domain *domain)
263263
static int mtk_iommu_attach_device(struct iommu_domain *domain,
264264
struct device *dev)
265265
{
266+
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
266267
struct mtk_iommu_domain *dom = to_mtk_domain(domain);
267-
struct mtk_iommu_data *data = dev_iommu_fwspec_get(dev)->iommu_priv;
268268
int ret;
269269

270270
if (!data)
@@ -286,7 +286,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
286286
static void mtk_iommu_detach_device(struct iommu_domain *domain,
287287
struct device *dev)
288288
{
289-
struct mtk_iommu_data *data = dev_iommu_fwspec_get(dev)->iommu_priv;
289+
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
290290

291291
if (!data)
292292
return;
@@ -387,20 +387,20 @@ static int mtk_iommu_create_mapping(struct device *dev,
387387
return -EINVAL;
388388
}
389389

390-
if (!fwspec->iommu_priv) {
390+
if (!dev_iommu_priv_get(dev)) {
391391
/* Get the m4u device */
392392
m4updev = of_find_device_by_node(args->np);
393393
if (WARN_ON(!m4updev))
394394
return -EINVAL;
395395

396-
fwspec->iommu_priv = platform_get_drvdata(m4updev);
396+
dev_iommu_priv_set(dev, platform_get_drvdata(m4updev));
397397
}
398398

399399
ret = iommu_fwspec_add_ids(dev, args->args, 1);
400400
if (ret)
401401
return ret;
402402

403-
data = fwspec->iommu_priv;
403+
data = dev_iommu_priv_get(dev);
404404
m4udev = data->dev;
405405
mtk_mapping = m4udev->archdata.iommu;
406406
if (!mtk_mapping) {
@@ -459,7 +459,7 @@ static int mtk_iommu_add_device(struct device *dev)
459459
if (err)
460460
return err;
461461

462-
data = fwspec->iommu_priv;
462+
data = dev_iommu_priv_get(dev);
463463
mtk_mapping = data->dev->archdata.iommu;
464464
err = arm_iommu_attach_device(dev, mtk_mapping);
465465
if (err) {
@@ -478,7 +478,7 @@ static void mtk_iommu_remove_device(struct device *dev)
478478
if (!fwspec || fwspec->ops != &mtk_iommu_ops)
479479
return;
480480

481-
data = fwspec->iommu_priv;
481+
data = dev_iommu_priv_get(dev);
482482
iommu_device_unlink(&data->iommu, dev);
483483

484484
iommu_group_remove_device(dev);

0 commit comments

Comments
 (0)