Skip to contentSkip to conversation

sparc: leon: grpci1: Use devm_platform_get_and_ioremap_resource() in grpci1_of_probe()

PATCH Superseded Markus Elfring 2 participants 3 messages Feb 4, 2024 – Feb 16, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc: leon: grpci1: Use devm_platform_get_and_ioremap_resource() in grpci1_of_probe()

From: Markus Elfring <[email protected]>
Date: Sun, 4 Feb 2024 21:21:31 +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.

---
 arch/sparc/kernel/leon_pci_grpci1.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/sparc/kernel/leon_pci_grpci1.c +1 -2
index 8700a0e3b0df..ed2fd7b10dfe 100644
@@ -537,8 +537,7 @@ static int grpci1_of_probe(struct platform_device *ofdev)
 	priv->dev = &ofdev->dev;
 
 	/* find device register base address */
-	res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
-	regs = devm_ioremap_resource(&ofdev->dev, res);
+	regs = devm_platform_get_and_ioremap_resource(ofdev, 0, &res);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
 

--
2.43.0

#1 lore raw

PATCH v2 1/1 sparc: leon: grpci1: Use devm_platform_ioremap_resource() in grpci1_of_probe()

From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2024 16:30:15 +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.

---

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

Examples:
* Doug Anderson
* Geert Uytterhoeven
* Robin Murphy

 arch/sparc/kernel/leon_pci_grpci1.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/sparc/kernel/leon_pci_grpci1.c +1 -3
index 8700a0e3b0df..a01ecee18e1e 100644
@@ -516,7 +516,6 @@ static int grpci1_of_probe(struct platform_device *ofdev)
 	int err, len;
 	const int *tmp;
 	u32 cfg, size, err_mask;
-	struct resource *res;
 
 	if (grpci1priv) {
 		dev_err(&ofdev->dev, "only one GRPCI1 supported\n");
@@ -537,8 +536,7 @@ static int grpci1_of_probe(struct platform_device *ofdev)
 	priv->dev = &ofdev->dev;
 
 	/* find device register base address */
-	res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
-	regs = devm_ioremap_resource(&ofdev->dev, res);
+	regs = devm_platform_ioremap_resource(ofdev, 0);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
 

--
2.43.0

maintainer
#2 lore raw

Re: [PATCH v2] sparc: leon: grpci1: Use devm_platform_ioremap_resource() in grpci1_of_probe()

Quoted 4 lines · Markus Elfring

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

A wrapper function is available since the commit 7945f929f1a77a1c8887a97ca07f87626858ff42

This line is needlessly long. Could you wrap it or shorten the SHA-1 ID? You don't need more than the first 12 characters of the SHA-1 ID.

Quoted 3 lines

("drivers: provide devm_platform_ioremap_resource()").

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

The same goes for this one. Please keep the width of the commit description within 75 characters.

Quoted 6 lines

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

This issue was transformed by using the Coccinelle software.

Apart from that the patch looks good.

Thanks,
Andreas