Skip to content

Commit da07c58

Browse files
Uwe Kleine-Königstorulf
authored andcommitted
pmdomain: imx-gpc: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). In the error path emit an error message replacing the (less useful) message by the core. Apart from the improved error message there is no change in behaviour. Signed-off-by: Uwe Kleine-König <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent b3dff2e commit da07c58

File tree

1 file changed

+13
-9
lines changed
  • drivers/pmdomain/imx

1 file changed

+13
-9
lines changed

drivers/pmdomain/imx/gpc.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ static int imx_gpc_probe(struct platform_device *pdev)
509509
return 0;
510510
}
511511

512-
static int imx_gpc_remove(struct platform_device *pdev)
512+
static void imx_gpc_remove(struct platform_device *pdev)
513513
{
514514
struct device_node *pgc_node;
515515
int ret;
@@ -519,7 +519,7 @@ static int imx_gpc_remove(struct platform_device *pdev)
519519
/* bail out if DT too old and doesn't provide the necessary info */
520520
if (!of_property_read_bool(pdev->dev.of_node, "#power-domain-cells") &&
521521
!pgc_node)
522-
return 0;
522+
return;
523523

524524
/*
525525
* If the old DT binding is used the toplevel driver needs to
@@ -529,16 +529,20 @@ static int imx_gpc_remove(struct platform_device *pdev)
529529
of_genpd_del_provider(pdev->dev.of_node);
530530

531531
ret = pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_PU].base);
532-
if (ret)
533-
return ret;
532+
if (ret) {
533+
dev_err(&pdev->dev, "Failed to remove PU power domain (%pe)\n",
534+
ERR_PTR(ret));
535+
return;
536+
}
534537
imx_pgc_put_clocks(&imx_gpc_domains[GPC_PGC_DOMAIN_PU]);
535538

536539
ret = pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_ARM].base);
537-
if (ret)
538-
return ret;
540+
if (ret) {
541+
dev_err(&pdev->dev, "Failed to remove ARM power domain (%pe)\n",
542+
ERR_PTR(ret));
543+
return;
544+
}
539545
}
540-
541-
return 0;
542546
}
543547

544548
static struct platform_driver imx_gpc_driver = {
@@ -547,6 +551,6 @@ static struct platform_driver imx_gpc_driver = {
547551
.of_match_table = imx_gpc_dt_ids,
548552
},
549553
.probe = imx_gpc_probe,
550-
.remove = imx_gpc_remove,
554+
.remove_new = imx_gpc_remove,
551555
};
552556
builtin_platform_driver(imx_gpc_driver)

0 commit comments

Comments
 (0)