2024-02-05 07:20:52

by Markus Elfring

[permalink] [raw]
Subject: [PATCH] EDAC/xgene: Use devm_platform_get_and_ioremap_resource() in xgene_edac_probe()

From: Markus Elfring <[email protected]>
Date: Mon, 5 Feb 2024 08:12:24 +0100

A wrapper function is available since the commit 890cc39a879906b63912482dfc41944579df2dc6
("drivers: provide devm_platform_get_and_ioremap_resource()").
Thus reuse existing functionality instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/edac/xgene_edac.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/edac/xgene_edac.c b/drivers/edac/xgene_edac.c
index 1b50f8160013..8776765b6d2e 100644
--- a/drivers/edac/xgene_edac.c
+++ b/drivers/edac/xgene_edac.c
@@ -1903,8 +1903,7 @@ static int xgene_edac_probe(struct platform_device *pdev)
edac->rb_map = NULL;
}

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- edac->pcp_csr = devm_ioremap_resource(&pdev->dev, res);
+ edac->pcp_csr = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(edac->pcp_csr)) {
dev_err(&pdev->dev, "no PCP resource address\n");
rc = PTR_ERR(edac->pcp_csr);
--
2.43.0



2024-02-06 16:36:53

by Markus Elfring

[permalink] [raw]
Subject: [PATCH v2] EDAC/xgene: Use devm_platform_ioremap_resource() in xgene_edac_probe()

From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2024 17:30:11 +0100

A wrapper function is available since the commit 7945f929f1a77a1c8887a97ca07f87626858ff42
("drivers: provide devm_platform_ioremap_resource()").

* Thus reuse existing functionality instead of keeping duplicate source code.

* Delete a local variable which became unnecessary with this refactoring.


This issue was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---

v2:
The transformation pattern was adjusted based on advices by known contributors.

Examples:
* Doug Anderson
* Geert Uytterhoeven
* Robin Murphy


drivers/edac/xgene_edac.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/edac/xgene_edac.c b/drivers/edac/xgene_edac.c
index 1b50f8160013..59eb0e97adef 100644
--- a/drivers/edac/xgene_edac.c
+++ b/drivers/edac/xgene_edac.c
@@ -1845,7 +1845,6 @@ static int xgene_edac_probe(struct platform_device *pdev)
{
struct xgene_edac *edac;
struct device_node *child;
- struct resource *res;
int rc;

edac = devm_kzalloc(&pdev->dev, sizeof(*edac), GFP_KERNEL);
@@ -1903,8 +1902,7 @@ static int xgene_edac_probe(struct platform_device *pdev)
edac->rb_map = NULL;
}

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- edac->pcp_csr = devm_ioremap_resource(&pdev->dev, res);
+ edac->pcp_csr = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(edac->pcp_csr)) {
dev_err(&pdev->dev, "no PCP resource address\n");
rc = PTR_ERR(edac->pcp_csr);
--
2.43.0