iommu/ipmmu-vmsa: Use devm_platform_get_and_ioremap_resource() in ipmmu_probe()
Subsystems (2)
PATCH 1/1 iommu/ipmmu-vmsa: Use devm_platform_get_and_ioremap_resource() in ipmmu_probe()
From: Markus Elfring <[email protected]>
Date: Mon, 5 Feb 2024 11:36:51 +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.
--- drivers/iommu/ipmmu-vmsa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iommu/ipmmu-vmsa.c +1 -2
@@ -1025,8 +1025,7 @@ static int ipmmu_probe(struct platform_device *pdev)return ret;/* Map I/O memory and request IRQ. */ - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mmu->base =devm_ioremap_resource (&pdev->dev, res); + mmu->base =devm_platform_get_and_ioremap_resource (pdev,0 , &res);if (IS_ERR (mmu->base))return PTR_ERR (mmu->base);
--
2.43.0
Robin Murphy
reviewerQuoted 6 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 5 Feb 2024 11:36:51 +0100A wrapper function is available since the commit
890cc39a879906b63912482dfc41944579df2dc6("drivers: providedevm_platform_get_and_ioremap_resource()").
Thus reuse existing functionality instead of keeping duplicate source code.
Much as I detest the get_and_ioremap_resource obfuscator, it's not even appropriate here since nothing else is using "res".
Quoted 1 line
This issue was detected by using the Coccinelle software.
Please improve your script, or at least manually review your patches to ensure they actually make sense in context. If you want to do cleanup, do thorough, meaningful cleanup - leaving weird dangling local variables does not make the code clearer, if anything it makes it subtly worse since now the reader's wondering why we've gone out of our way to make this unused assignment, so maybe something's missing and there's a bug?
Thanks,
Robin.
Quoted 22 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/iommu/ipmmu-vmsa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/iommu/ipmmu-vmsa.c +1
-3@@ -1025,8 +1025,7 @@ static int ipmmu_probe(struct platform_device *pdev)return ret;/* Map I/O memory and request IRQ. */ - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mmu->base =devm_ioremap_resource (&pdev->dev, res); + mmu->base =devm_platform_get_and_ioremap_resource (pdev,0 , &res);if (IS_ERR (mmu->base))return PTR_ERR (mmu->base); --2.43.0
Quoted 3 lines
Quoted 1 line
Thus reuse existing functionality instead of keeping duplicate source code.
Much as I detest the
get_and_ioremap_resourceobfuscator, it's not even appropriate here since nothing else is using "res".
I got the impression that this local variable is needed to perform a desired function call.
Regards,
Markus
Robin Murphy
reviewerQuoted 6 lines · Markus Elfring
Quoted 3 lines
Quoted 1 line
Thus reuse existing functionality instead of keeping duplicate source code.
Much as I detest the
get_and_ioremap_resourceobfuscator, it's not even appropriate here since nothing else is using "res".I got the impression that this local variable is needed to perform a desired function call.
Yes, the call to devm_ioremap_resource(). Which you're proposing to remove...
Thanks,
Robin.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Thus reuse existing functionality instead of keeping duplicate source code.
Much as I detest the
get_and_ioremap_resourceobfuscator, it's not even appropriate here since nothing else is using "res".I got the impression that this local variable is needed to perform a desired function call.
Yes, the call to
devm_ioremap_resource(). Which you're proposing to remove...
I propose to replace a specific function call combination by an other single call for a known wrapper function. The mentioned variable is preserved for this purpose.
Regards,
Markus
Robin Murphy
reviewerQuoted 4 lines · Markus Elfring
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Thus reuse existing functionality instead of keeping duplicate source code.
Much as I detest the
get_and_ioremap_resourceobfuscator, it's not even appropriate here since nothing else is using "res".
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I got the impression that this local variable is needed to perform a desired function call.
Yes, the call to
devm_ioremap_resource(). Which you're proposing to remove...I propose to replace a specific function call combination by an other single call for a known wrapper function. The mentioned variable is preserved for this purpose.
No. If you believe in cleaning up code, please apply your brain and clean up code *meaningfully* - others seem to have managed it just fine (e.g. [1][2] at random from a quick search on lore). Hell, I think even the original now-deleted script could auto-generate a proper patch for situations where devm_platform_ioremap_resource() was appropriate - there is zero excuse for doing a *worse* job 4 years later.
If on the other hand your interest is not to actually clean up the code for the good of the community, but to stoke your own ego as a "contributor" of shitty patches that annoy people and reinforce the popular impression that you are in fact an AI, please stop, or at the very least please refrain from doing so in any areas I review or maintain.
Thanks,
Robin.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Quoted 3 lines
Quoted 1 line
Thus reuse existing functionality instead of keeping duplicate source code.
Much as I detest the
get_and_ioremap_resourceobfuscator, it's not even appropriate here since nothing else is using "res".
Another adjustment might follow for the application of the function “devm_platform_ioremap_resource”.
https://elixir.bootlin.com/linux/v6.8-rc3/source/drivers/base/platform.c#L112
Regards,
Markus
PATCH v2 1/1 iommu/ipmmu-vmsa: Use devm_platform_ioremap_resource() in ipmmu_probe()
In reply to Robin MurphyFrom: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2024 15:00:23 +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
drivers/iommu/ipmmu-vmsa.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iommu/ipmmu-vmsa.c +1 -3
@@ -1005,7 +1005,6 @@ static const struct of_device_id ipmmu_of_ids[] = {static int ipmmu_probe (struct platform_device *pdev) {struct ipmmu_vmsa_device *mmu; -struct resource *res;int irq;int ret;
@@ -1025,8 +1024,7 @@ static int ipmmu_probe(struct platform_device *pdev)return ret;/* Map I/O memory and request IRQ. */ - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mmu->base =devm_ioremap_resource (&pdev->dev, res); + mmu->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (mmu->base))return PTR_ERR (mmu->base);
--
2.43.0
Re: [PATCH v2] iommu/ipmmu-vmsa: Use devm_platform_ioremap_resource() in ipmmu_probe()
Quoted 16 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2024 15:00:23 +0100A wrapper function is available since the commit
7945f929f1a77a1c8887a97ca07f87626858ff42("drivers: providedevm_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]>---
Quoted 7 lines
v2:
The transformation pattern was adjusted based on advices by known contributors.Examples:
* Doug Anderson
* Geert Uytterhoeven
* Robin Murphy
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds