EDAC: Armada XP: Use devm_platform_ioremap_resource() in two functions
Subsystems (3)
PATCH 1/1 EDAC: Armada XP: Use devm_platform_ioremap_resource() in two functions
From: Markus Elfring <[email protected]>
Date: Sat, 21 Sep 2019 17:50:17 +0200
Simplify these function implementations by using a known function.
This issue was detected by using the Coccinelle software.
--- drivers/edac/armada_xp_edac.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
drivers/edac/armada_xp_edac.c +2 -16
@@ -286,17 +286,10 @@ static int axp_mc_probe(struct platform_device *pdev)struct edac_mc_layer layers[1 ];const struct of_device_id *id;struct mem_ctl_info *mci; -struct resource *r;void __iomem *base;uint32_t config; - r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!r) { -dev_err (&pdev->dev,"Unable to get mem resource\n" ); -return -ENODEV ; - } - - base =devm_ioremap_resource (&pdev->dev, r); + base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (base)) {dev_err (&pdev->dev,"Unable to map regs\n" );return PTR_ERR (base);
@@ -516,15 +509,8 @@ static int aurora_l2_probe(struct platform_device *pdev)const struct of_device_id *id;uint32_t l2x0_aux_ctrl;void __iomem *base; -struct resource *r; - - r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!r) { -dev_err (&pdev->dev,"Unable to get mem resource\n" ); -return -ENODEV ; - } - base =devm_ioremap_resource (&pdev->dev, r); + base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (base)) {dev_err (&pdev->dev,"Unable to map regs\n" );return PTR_ERR (base);
--
2.23.0
Hi Markus,
Quoted 6 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 21 Sep 2019 17:50:17 +0200Simplify these function implementations by using a known function.
This issue was detected by using the Coccinelle software.
Which semantic patch did you use here?
The kernel's spatch for this pattern only found and fixed the following:
$ make coccicheck COCCI=scripts/coccinelle/api/devm_platform_ioremap_resource.cocci MODE=patch M=drivers/edac | patch -p1 patching file drivers/edac/ti_edac.c patching file drivers/edac/xgene_edac.c patching file drivers/edac/synopsys_edac.c
There are probably more drivers to fix than the above and the one you fixed:
$ git grep -l platform_get_resource drivers/edac/ drivers/edac/altera_edac.c drivers/edac/armada_xp_edac.c drivers/edac/aspeed_edac.c drivers/edac/bluefield_edac.c drivers/edac/cpc925_edac.c drivers/edac/highbank_l2_edac.c drivers/edac/highbank_mc_edac.c drivers/edac/mv64x60_edac.c drivers/edac/synopsys_edac.c drivers/edac/ti_edac.c drivers/edac/xgene_edac.c
So while at it, how about fixing the .cocci patch in scripts/ and run it for drivers/edac? There should be one patch only for all edac drivers.
Thanks,
-Robert
Quoted 1 line
Which semantic patch did you use here?
I suggest to take another look at details around background information on a subject like “Coccinelle: api: add devm_platform_ioremap_resource script”.
https://lore.kernel.org/r/[email protected]/
https://systeme.lip6.fr/pipermail/cocci/2019-September/006303.html
https://lkml.org/lkml/2019/9/19/81
Quoted 1 line
There are probably more drivers to fix than the above and the one you fixed:
Yes, of course.
I concentrated my update suggestions on a specific source code transformation variant recently.
Quoted 2 lines
So while at it, how about fixing the .cocci patch in
scripts/and run it fordrivers/edac?
Some developers are trying to improve affected software components further. Did you eventually receive similar patches already by other contributors?
Quoted 1 line
There should be one patch only for all edac drivers.
Is there consensus for this kind of change expectation?
Regards,
Markus