Simplify the power management code by removing redundant wrapper functions
and using modern kernel PM macros. This reduces code duplication and
improves maintainability.
The changes convert the suspend/resume functions to take device pointer
directly instead of the chip structure, allowing removal of the runtime
PM wrapper functions. The manual PM ops definition is replaced with
DEFINE_RUNTIME_DEV_PM_OPS() macro and pm_ptr() is used for the platform
driver. Probe and remove functions are updated to call PM functions with
device pointer.
Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
---
.../dma/dw-axi-dmac/dw-axi-dmac-platform.c | 31 ++++++-------------
1 file changed, 9 insertions(+), 22 deletions(-)
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index b23536645ff7..8b7cf3baf5d3 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -1314,8 +1314,10 @@ static int dma_chan_resume(struct dma_chan *dchan)
return 0;
}
-static int axi_dma_suspend(struct axi_dma_chip *chip)
+static int axi_dma_suspend(struct device *dev)
{
+ struct axi_dma_chip *chip = dev_get_drvdata(dev);
+
axi_dma_irq_disable(chip);
axi_dma_disable(chip);
@@ -1325,9 +1327,10 @@ static int axi_dma_suspend(struct axi_dma_chip *chip)
return 0;
}
-static int axi_dma_resume(struct axi_dma_chip *chip)
+static int axi_dma_resume(struct device *dev)
{
int ret;
+ struct axi_dma_chip *chip = dev_get_drvdata(dev);
ret = clk_prepare_enable(chip->cfgr_clk);
if (ret < 0)
@@ -1343,20 +1346,6 @@ static int axi_dma_resume(struct axi_dma_chip *chip)
return 0;
}
-static int __maybe_unused axi_dma_runtime_suspend(struct device *dev)
-{
- struct axi_dma_chip *chip = dev_get_drvdata(dev);
-
- return axi_dma_suspend(chip);
-}
-
-static int __maybe_unused axi_dma_runtime_resume(struct device *dev)
-{
- struct axi_dma_chip *chip = dev_get_drvdata(dev);
-
- return axi_dma_resume(chip);
-}
-
static struct dma_chan *dw_axi_dma_of_xlate(struct of_phandle_args *dma_spec,
struct of_dma *ofdma)
{
@@ -1590,7 +1579,7 @@ static int dw_probe(struct platform_device *pdev)
* driver to work also without Runtime PM.
*/
pm_runtime_get_noresume(chip->dev);
- ret = axi_dma_resume(chip);
+ ret = axi_dma_resume(chip->dev);
if (ret < 0)
goto err_pm_disable;
@@ -1638,7 +1627,7 @@ static void dw_remove(struct platform_device *pdev)
axi_dma_disable(chip);
pm_runtime_disable(chip->dev);
- axi_dma_suspend(chip);
+ axi_dma_suspend(chip->dev);
for (i = 0; i < DMAC_MAX_CHANNELS; i++)
if (chip->irq[i] > 0)
@@ -1653,9 +1642,7 @@ static void dw_remove(struct platform_device *pdev)
}
}
-static const struct dev_pm_ops dw_axi_dma_pm_ops = {
- SET_RUNTIME_PM_OPS(axi_dma_runtime_suspend, axi_dma_runtime_resume, NULL)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(dw_axi_dma_pm_ops, axi_dma_suspend, axi_dma_resume, NULL);
static const struct of_device_id dw_dma_of_id_table[] = {
{
@@ -1680,7 +1667,7 @@ static struct platform_driver dw_driver = {
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = dw_dma_of_id_table,
- .pm = &dw_axi_dma_pm_ops,
+ .pm = pm_ptr(&dw_axi_dma_pm_ops),
},
};
module_platform_driver(dw_driver);
--
2.43.0