Skip to content

Commit 6b05266

Browse files
pcercueilynxeye-dev
authored andcommitted
drm/etnaviv: Remove #ifdef guards for PM related functions
Use the RUNTIME_PM_OPS() and pm_ptr() macros to handle the .runtime_suspend/.runtime_resume callbacks. These macros allow the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM is disabled, without having to use #ifdef guards. This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch. Some #ifdef CONFIG_PM guards were protecting simple statements, and were also converted to "if (IS_ENABLED(CONFIG_PM))". Signed-off-by: Paul Cercueil <[email protected]> Signed-off-by: Lucas Stach <[email protected]>
1 parent 764be12 commit 6b05266

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

drivers/gpu/drm/etnaviv/etnaviv_gpu.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,6 @@ static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu)
16491649
return etnaviv_gpu_clk_disable(gpu);
16501650
}
16511651

1652-
#ifdef CONFIG_PM
16531652
static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu)
16541653
{
16551654
int ret;
@@ -1665,7 +1664,6 @@ static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu)
16651664

16661665
return 0;
16671666
}
1668-
#endif
16691667

16701668
static int
16711669
etnaviv_gpu_cooling_get_max_state(struct thermal_cooling_device *cdev,
@@ -1733,11 +1731,10 @@ static int etnaviv_gpu_bind(struct device *dev, struct device *master,
17331731
if (ret)
17341732
goto out_workqueue;
17351733

1736-
#ifdef CONFIG_PM
1737-
ret = pm_runtime_get_sync(gpu->dev);
1738-
#else
1739-
ret = etnaviv_gpu_clk_enable(gpu);
1740-
#endif
1734+
if (IS_ENABLED(CONFIG_PM))
1735+
ret = pm_runtime_get_sync(gpu->dev);
1736+
else
1737+
ret = etnaviv_gpu_clk_enable(gpu);
17411738
if (ret < 0)
17421739
goto out_sched;
17431740

@@ -1781,12 +1778,12 @@ static void etnaviv_gpu_unbind(struct device *dev, struct device *master,
17811778

17821779
etnaviv_sched_fini(gpu);
17831780

1784-
#ifdef CONFIG_PM
1785-
pm_runtime_get_sync(gpu->dev);
1786-
pm_runtime_put_sync_suspend(gpu->dev);
1787-
#else
1788-
etnaviv_gpu_hw_suspend(gpu);
1789-
#endif
1781+
if (IS_ENABLED(CONFIG_PM)) {
1782+
pm_runtime_get_sync(gpu->dev);
1783+
pm_runtime_put_sync_suspend(gpu->dev);
1784+
} else {
1785+
etnaviv_gpu_hw_suspend(gpu);
1786+
}
17901787

17911788
if (gpu->mmu_context)
17921789
etnaviv_iommu_context_put(gpu->mmu_context);
@@ -1900,7 +1897,6 @@ static int etnaviv_gpu_platform_remove(struct platform_device *pdev)
19001897
return 0;
19011898
}
19021899

1903-
#ifdef CONFIG_PM
19041900
static int etnaviv_gpu_rpm_suspend(struct device *dev)
19051901
{
19061902
struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
@@ -1943,18 +1939,16 @@ static int etnaviv_gpu_rpm_resume(struct device *dev)
19431939

19441940
return 0;
19451941
}
1946-
#endif
19471942

19481943
static const struct dev_pm_ops etnaviv_gpu_pm_ops = {
1949-
SET_RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume,
1950-
NULL)
1944+
RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume, NULL)
19511945
};
19521946

19531947
struct platform_driver etnaviv_gpu_driver = {
19541948
.driver = {
19551949
.name = "etnaviv-gpu",
19561950
.owner = THIS_MODULE,
1957-
.pm = &etnaviv_gpu_pm_ops,
1951+
.pm = pm_ptr(&etnaviv_gpu_pm_ops),
19581952
.of_match_table = etnaviv_gpu_match,
19591953
},
19601954
.probe = etnaviv_gpu_platform_probe,

0 commit comments

Comments
 (0)