* [PATCH] media: ti: Use devm_platform_get_and_ioremap_resource() in ti_csi2rx_probe()
@ 2024-02-05 12:20 Markus Elfring
2024-02-06 9:53 ` Jai Luthra
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2024-02-05 12:20 UTC (permalink / raw)
To: linux-media, kernel-janitors, Jai Luthra, Mauro Carvalho Chehab; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Feb 2024 13:14:00 +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 <elfring@users.sourceforge.net>
---
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
index 2b078c5d7f5d..6ff066097346 100644
--- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
+++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
@@ -1100,9 +1100,7 @@ static int ti_csi2rx_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, csi);
mutex_init(&csi->mutex);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- csi->shim = devm_ioremap_resource(&pdev->dev, res);
+ csi->shim = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(csi->shim)) {
ret = PTR_ERR(csi->shim);
goto err_mutex;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] media: ti: Use devm_platform_get_and_ioremap_resource() in ti_csi2rx_probe()
2024-02-05 12:20 [PATCH] media: ti: Use devm_platform_get_and_ioremap_resource() in ti_csi2rx_probe() Markus Elfring
@ 2024-02-06 9:53 ` Jai Luthra
2024-02-06 14:37 ` [PATCH v2] media: ti: Use devm_platform_ioremap_resource() " Markus Elfring
0 siblings, 1 reply; 4+ messages in thread
From: Jai Luthra @ 2024-02-06 9:53 UTC (permalink / raw)
To: Markus Elfring; +Cc: linux-media, kernel-janitors, Mauro Carvalho Chehab, LKML
[-- Attachment #1: Type: text/plain, Size: 1800 bytes --]
Hi Markus,
Thanks for the patch.
On Feb 05, 2024 at 13:20:30 +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 5 Feb 2024 13:14:00 +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 <elfring@users.sourceforge.net>
> ---
> drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> index 2b078c5d7f5d..6ff066097346 100644
> --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> @@ -1100,9 +1100,7 @@ static int ti_csi2rx_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, csi);
>
> mutex_init(&csi->mutex);
> -
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
As this "res" variable is not used anywhere else, it would be better to
drop the declaration for it and instead call:
csi->shim = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
With that change,
Reviewed-by: Jai Luthra <j-luthra@ti.com>
> - csi->shim = devm_ioremap_resource(&pdev->dev, res);
> + csi->shim = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> if (IS_ERR(csi->shim)) {
> ret = PTR_ERR(csi->shim);
> goto err_mutex;
> --
> 2.43.0
>
--
Thanks,
Jai
GPG Fingerprint: 4DE0 D818 E5D5 75E8 D45A AFC5 43DE 91F9 249A 7145
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] media: ti: Use devm_platform_ioremap_resource() in ti_csi2rx_probe()
2024-02-06 9:53 ` Jai Luthra
@ 2024-02-06 14:37 ` Markus Elfring
2024-02-07 15:18 ` Jai Luthra
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2024-02-06 14:37 UTC (permalink / raw)
To: Jai Luthra, linux-media, kernel-janitors, Mauro Carvalho Chehab; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2024 15:30:13 +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 <elfring@users.sourceforge.net>
---
v2:
The transformation pattern was adjusted based on advices by known contributors.
Examples:
* Doug Anderson
* Geert Uytterhoeven
* Robin Murphy
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
index 2b078c5d7f5d..54aba055c96b 100644
--- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
+++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
@@ -1089,7 +1089,6 @@ static void ti_csi2rx_cleanup_vb2q(struct ti_csi2rx_dev *csi)
static int ti_csi2rx_probe(struct platform_device *pdev)
{
struct ti_csi2rx_dev *csi;
- struct resource *res;
int ret;
csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL);
@@ -1100,9 +1099,7 @@ static int ti_csi2rx_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, csi);
mutex_init(&csi->mutex);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- csi->shim = devm_ioremap_resource(&pdev->dev, res);
+ csi->shim = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(csi->shim)) {
ret = PTR_ERR(csi->shim);
goto err_mutex;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] media: ti: Use devm_platform_ioremap_resource() in ti_csi2rx_probe()
2024-02-06 14:37 ` [PATCH v2] media: ti: Use devm_platform_ioremap_resource() " Markus Elfring
@ 2024-02-07 15:18 ` Jai Luthra
0 siblings, 0 replies; 4+ messages in thread
From: Jai Luthra @ 2024-02-07 15:18 UTC (permalink / raw)
To: Markus Elfring; +Cc: linux-media, kernel-janitors, Mauro Carvalho Chehab, LKML
[-- Attachment #1: Type: text/plain, Size: 2104 bytes --]
Hi Markus,
On Feb 06, 2024 at 15:37:30 +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 6 Feb 2024 15:30:13 +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 <elfring@users.sourceforge.net>
Reviewed-by: Jai Luthra <j-luthra@ti.com>
> ---
>
> v2:
> The transformation pattern was adjusted based on advices by known contributors.
>
> Examples:
> * Doug Anderson
> * Geert Uytterhoeven
> * Robin Murphy
>
>
> drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> index 2b078c5d7f5d..54aba055c96b 100644
> --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> @@ -1089,7 +1089,6 @@ static void ti_csi2rx_cleanup_vb2q(struct ti_csi2rx_dev *csi)
> static int ti_csi2rx_probe(struct platform_device *pdev)
> {
> struct ti_csi2rx_dev *csi;
> - struct resource *res;
> int ret;
>
> csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL);
> @@ -1100,9 +1099,7 @@ static int ti_csi2rx_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, csi);
>
> mutex_init(&csi->mutex);
> -
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - csi->shim = devm_ioremap_resource(&pdev->dev, res);
> + csi->shim = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(csi->shim)) {
> ret = PTR_ERR(csi->shim);
> goto err_mutex;
> --
> 2.43.0
>
--
Thanks,
Jai
GPG Fingerprint: 4DE0 D818 E5D5 75E8 D45A AFC5 43DE 91F9 249A 7145
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-07 15:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-05 12:20 [PATCH] media: ti: Use devm_platform_get_and_ioremap_resource() in ti_csi2rx_probe() Markus Elfring
2024-02-06 9:53 ` Jai Luthra
2024-02-06 14:37 ` [PATCH v2] media: ti: Use devm_platform_ioremap_resource() " Markus Elfring
2024-02-07 15:18 ` Jai Luthra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox