Skip to content

Commit f790b5c

Browse files
storulfthierryreding
authored andcommitted
drm/tegra: gr3d: Convert into dev_pm_domain_attach|detach_list()
Rather than hooking up the PM domains through devm_pm_opp_attach_genpd() and manage the device-link, let's avoid the boilerplate-code by converting into dev_pm_domain_attach|detach_list. Signed-off-by: Ulf Hansson <[email protected]> Signed-off-by: Thierry Reding <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 9719c7b commit f790b5c

File tree

1 file changed

+13
-33
lines changed

1 file changed

+13
-33
lines changed

drivers/gpu/drm/tegra/gr3d.c

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct gr3d {
4646
unsigned int nclocks;
4747
struct reset_control_bulk_data resets[RST_GR3D_MAX];
4848
unsigned int nresets;
49+
struct dev_pm_domain_list *pd_list;
4950

5051
DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS);
5152
};
@@ -369,18 +370,12 @@ static int gr3d_power_up_legacy_domain(struct device *dev, const char *name,
369370
return 0;
370371
}
371372

372-
static void gr3d_del_link(void *link)
373-
{
374-
device_link_del(link);
375-
}
376-
377373
static int gr3d_init_power(struct device *dev, struct gr3d *gr3d)
378374
{
379-
static const char * const opp_genpd_names[] = { "3d0", "3d1", NULL };
380-
const u32 link_flags = DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME;
381-
struct device **opp_virt_devs, *pd_dev;
382-
struct device_link *link;
383-
unsigned int i;
375+
struct dev_pm_domain_attach_data pd_data = {
376+
.pd_names = (const char *[]) { "3d0", "3d1" },
377+
.num_pd_names = 2,
378+
};
384379
int err;
385380

386381
err = of_count_phandle_with_args(dev->of_node, "power-domains",
@@ -414,29 +409,10 @@ static int gr3d_init_power(struct device *dev, struct gr3d *gr3d)
414409
if (dev->pm_domain)
415410
return 0;
416411

417-
err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs);
418-
if (err)
412+
err = dev_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list);
413+
if (err < 0)
419414
return err;
420415

421-
for (i = 0; opp_genpd_names[i]; i++) {
422-
pd_dev = opp_virt_devs[i];
423-
if (!pd_dev) {
424-
dev_err(dev, "failed to get %s power domain\n",
425-
opp_genpd_names[i]);
426-
return -EINVAL;
427-
}
428-
429-
link = device_link_add(dev, pd_dev, link_flags);
430-
if (!link) {
431-
dev_err(dev, "failed to link to %s\n", dev_name(pd_dev));
432-
return -EINVAL;
433-
}
434-
435-
err = devm_add_action_or_reset(dev, gr3d_del_link, link);
436-
if (err)
437-
return err;
438-
}
439-
440416
return 0;
441417
}
442418

@@ -527,20 +503,23 @@ static int gr3d_probe(struct platform_device *pdev)
527503

528504
err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
529505
if (err)
530-
return err;
506+
goto err;
531507

532508
err = host1x_client_register(&gr3d->client.base);
533509
if (err < 0) {
534510
dev_err(&pdev->dev, "failed to register host1x client: %d\n",
535511
err);
536-
return err;
512+
goto err;
537513
}
538514

539515
/* initialize address register map */
540516
for (i = 0; i < ARRAY_SIZE(gr3d_addr_regs); i++)
541517
set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
542518

543519
return 0;
520+
err:
521+
dev_pm_domain_detach_list(gr3d->pd_list);
522+
return err;
544523
}
545524

546525
static void gr3d_remove(struct platform_device *pdev)
@@ -549,6 +528,7 @@ static void gr3d_remove(struct platform_device *pdev)
549528

550529
pm_runtime_disable(&pdev->dev);
551530
host1x_client_unregister(&gr3d->client.base);
531+
dev_pm_domain_detach_list(gr3d->pd_list);
552532
}
553533

554534
static int __maybe_unused gr3d_runtime_suspend(struct device *dev)

0 commit comments

Comments
 (0)