Skip to content

Commit 056f605

Browse files
committed
drm/tegra: gr3d: Convert into devm_pm_domain_attach_list()
JIRA: https://issues.redhat.com/browse/RHEL-75956 commit 1ce91bf Author: Ulf Hansson <ulf.hansson@linaro.org> Date: Wed Oct 2 14:22:29 2024 +0200 drm/tegra: gr3d: Convert into devm_pm_domain_attach_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 devm_pm_domain_attach_list(). Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://lore.kernel.org/r/20241002122232.194245-9-ulf.hansson@linaro.org Signed-off-by: José Expósito <jexposit@redhat.com>
1 parent 4dd8d8f commit 056f605

File tree

1 file changed

+8
-31
lines changed

1 file changed

+8
-31
lines changed

drivers/gpu/drm/tegra/gr3d.c

Lines changed: 8 additions & 31 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,13 @@ 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+
.pd_flags = PD_FLAG_REQUIRED_OPP,
379+
};
384380
int err;
385381

386382
err = of_count_phandle_with_args(dev->of_node, "power-domains",
@@ -414,29 +410,10 @@ static int gr3d_init_power(struct device *dev, struct gr3d *gr3d)
414410
if (dev->pm_domain)
415411
return 0;
416412

417-
err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs);
418-
if (err)
413+
err = devm_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list);
414+
if (err < 0)
419415
return err;
420416

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-
440417
return 0;
441418
}
442419

0 commit comments

Comments
 (0)