linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] i2c: busses: convert to devm_platform_get_and_ioremap_resource
@ 2020-04-14 13:48 Dejin Zheng
  2020-04-15 10:21 ` Wolfram Sang
  0 siblings, 1 reply; 6+ messages in thread
From: Dejin Zheng @ 2020-04-14 13:48 UTC (permalink / raw)
  To: michal.simek, wsa+renesas, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, alain.volmat, linux-i2c
  Cc: linux-kernel, Dejin Zheng

use devm_platform_get_and_ioremap_resource() to simplify code, which
contains platform_get_resource() and devm_ioremap_resource(), it also
get the resource for use by the following code.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
---
 drivers/i2c/busses/i2c-cadence.c      | 3 +--
 drivers/i2c/busses/i2c-pca-platform.c | 3 +--
 drivers/i2c/busses/i2c-rcar.c         | 4 +---
 drivers/i2c/busses/i2c-stm32f7.c      | 3 +--
 4 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index 89d58f7d2a25..803c802611eb 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -906,8 +906,7 @@ static int cdns_i2c_probe(struct platform_device *pdev)
 		id->quirks = data->quirks;
 	}
 
-	r_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	id->membase = devm_ioremap_resource(&pdev->dev, r_mem);
+	id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem);
 	if (IS_ERR(id->membase))
 		return PTR_ERR(id->membase);
 
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index 635dd697ac0b..546426a470cc 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -149,8 +149,7 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
 	if (!i2c)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	i2c->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	i2c->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
 	if (IS_ERR(i2c->reg_base))
 		return PTR_ERR(i2c->reg_base);
 
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 3b5397aa4ca6..a45c4bf1ec01 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -938,9 +938,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->clk);
 	}
 
-	priv->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	priv->io = devm_ioremap_resource(dev, priv->res);
+	priv->io = devm_platform_get_and_ioremap_resource(pdev, 0, &priv->res);
 	if (IS_ERR(priv->io))
 		return PTR_ERR(priv->io);
 
diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 330ffed011e0..cf48f8df4423 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -1940,8 +1940,7 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
 	if (!i2c_dev)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	i2c_dev->base = devm_ioremap_resource(&pdev->dev, res);
+	i2c_dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
 	if (IS_ERR(i2c_dev->base))
 		return PTR_ERR(i2c_dev->base);
 	phy_addr = (dma_addr_t)res->start;
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] i2c: busses: convert to devm_platform_get_and_ioremap_resource
  2020-04-14 13:48 [PATCH v1] i2c: busses: convert to devm_platform_get_and_ioremap_resource Dejin Zheng
@ 2020-04-15 10:21 ` Wolfram Sang
  2020-04-15 16:07   ` Dejin Zheng
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2020-04-15 10:21 UTC (permalink / raw)
  To: Dejin Zheng
  Cc: michal.simek, wsa+renesas, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, alain.volmat, linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 671 bytes --]

On Tue, Apr 14, 2020 at 09:48:27PM +0800, Dejin Zheng wrote:
> use devm_platform_get_and_ioremap_resource() to simplify code, which
> contains platform_get_resource() and devm_ioremap_resource(), it also
> get the resource for use by the following code.
> 
> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>

Applied to for-next, because it seems 'the new way' but...

> -	r_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	id->membase = devm_ioremap_resource(&pdev->dev, r_mem);
> +	id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem);

... guys, do you really think this one line reduction improves
readability? Oh well...


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] i2c: busses: convert to devm_platform_get_and_ioremap_resource
  2020-04-15 10:21 ` Wolfram Sang
@ 2020-04-15 16:07   ` Dejin Zheng
  2020-04-17 20:46     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Dejin Zheng @ 2020-04-15 16:07 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: michal.simek, wsa+renesas, pierre-yves.mordret, mcoquelin.stm32,
	alexandre.torgue, alain.volmat, linux-i2c, linux-kernel

On Wed, Apr 15, 2020 at 12:21:58PM +0200, Wolfram Sang wrote:
> On Tue, Apr 14, 2020 at 09:48:27PM +0800, Dejin Zheng wrote:
> > use devm_platform_get_and_ioremap_resource() to simplify code, which
> > contains platform_get_resource() and devm_ioremap_resource(), it also
> > get the resource for use by the following code.
> > 
> > Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> 
> Applied to for-next, because it seems 'the new way' but...
> 
> > -	r_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -	id->membase = devm_ioremap_resource(&pdev->dev, r_mem);
> > +	id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem);
> 
> ... guys, do you really think this one line reduction improves
> readability? Oh well...
>
Wolfram, Thank you for accepting it. From my personal point of view,
as long as the direction is correct, even small improvements are
worth doing. Thanks again for your tolerance.

BR,
Dejin



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] i2c: busses: convert to devm_platform_get_and_ioremap_resource
  2020-04-15 16:07   ` Dejin Zheng
@ 2020-04-17 20:46     ` Andy Shevchenko
  2020-04-18  4:06       ` Dejin Zheng
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2020-04-17 20:46 UTC (permalink / raw)
  To: Dejin Zheng
  Cc: Wolfram Sang, Michal Simek, Wolfram Sang, Pierre Yves MORDRET,
	Maxime Coquelin, Alexandre TORGUE, Alain Volmat, linux-i2c,
	Linux Kernel Mailing List

On Thu, Apr 16, 2020 at 3:19 AM Dejin Zheng <zhengdejin5@gmail.com> wrote:
>
> On Wed, Apr 15, 2020 at 12:21:58PM +0200, Wolfram Sang wrote:
> > On Tue, Apr 14, 2020 at 09:48:27PM +0800, Dejin Zheng wrote:
> > > use devm_platform_get_and_ioremap_resource() to simplify code, which
> > > contains platform_get_resource() and devm_ioremap_resource(), it also
> > > get the resource for use by the following code.
> > >
> > > Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> >
> > Applied to for-next, because it seems 'the new way' but...
> >
> > > -   r_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > -   id->membase = devm_ioremap_resource(&pdev->dev, r_mem);
> > > +   id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem);
> >
> > ... guys, do you really think this one line reduction improves
> > readability? Oh well...
> >
> Wolfram, Thank you for accepting it. From my personal point of view,
> as long as the direction is correct, even small improvements are
> worth doing. Thanks again for your tolerance.

Do you have plans to move on from janitor work to something serious?

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] i2c: busses: convert to devm_platform_get_and_ioremap_resource
  2020-04-17 20:46     ` Andy Shevchenko
@ 2020-04-18  4:06       ` Dejin Zheng
  0 siblings, 0 replies; 6+ messages in thread
From: Dejin Zheng @ 2020-04-18  4:06 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Wolfram Sang, Michal Simek, Wolfram Sang, Pierre Yves MORDRET,
	Maxime Coquelin, Alexandre TORGUE, Alain Volmat, linux-i2c,
	Linux Kernel Mailing List

On Fri, Apr 17, 2020 at 11:46:33PM +0300, Andy Shevchenko wrote:
> On Thu, Apr 16, 2020 at 3:19 AM Dejin Zheng <zhengdejin5@gmail.com> wrote:
> >
> > On Wed, Apr 15, 2020 at 12:21:58PM +0200, Wolfram Sang wrote:
> > > On Tue, Apr 14, 2020 at 09:48:27PM +0800, Dejin Zheng wrote:
> > > > use devm_platform_get_and_ioremap_resource() to simplify code, which
> > > > contains platform_get_resource() and devm_ioremap_resource(), it also
> > > > get the resource for use by the following code.
> > > >
> > > > Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> > >
> > > Applied to for-next, because it seems 'the new way' but...
> > >
> > > > -   r_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > > -   id->membase = devm_ioremap_resource(&pdev->dev, r_mem);
> > > > +   id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem);
> > >
> > > ... guys, do you really think this one line reduction improves
> > > readability? Oh well...
> > >
> > Wolfram, Thank you for accepting it. From my personal point of view,
> > as long as the direction is correct, even small improvements are
> > worth doing. Thanks again for your tolerance.
> 
> Do you have plans to move on from janitor work to something serious?
>
Andy, I want to do��but I don��t know where to start, Could you give me
some suggestions? Thanks very much!

BR,
Dejin
> -- 
> With Best Regards,
> Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] i2c: busses: convert to devm_platform_get_and_ioremap_resource
@ 2020-04-17 20:36 Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2020-04-17 20:36 UTC (permalink / raw)
  To: Dejin Zheng, linux-i2c
  Cc: kernel-janitors, linux-kernel, Wolfram Sang, Vignesh Raghavendra,
	Thor Thayer, Patrick Williams, Alain Volmat, Alexandre Torgue,
	Maxime Coquelin, Michal Simek, Pierre-Yves Mordret,
	Krzysztof Kozlowski, Krzysztof Adamski, Andy Shevchenko,
	Ard Biesheuvel, Bjorn Andersson, Barry Song, Bartosz Golaszewski,
	Dong Aisheng, George Cherian

> use devm_platform_get_and_ioremap_resource() to simplify code, which
> contains platform_get_resource() and devm_ioremap_resource(), it also
> get the resource for use by the following code.

I suggest to improve also this change description.

I have tried another script variant out for the semantic patch language.
This source code analysis approach would propose to transform
15 source files (for example in the directory “drivers/i2c”
of the software “Linux next-20200417”).
Would you like to take another look at corresponding change possibilities?

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-18  4:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 13:48 [PATCH v1] i2c: busses: convert to devm_platform_get_and_ioremap_resource Dejin Zheng
2020-04-15 10:21 ` Wolfram Sang
2020-04-15 16:07   ` Dejin Zheng
2020-04-17 20:46     ` Andy Shevchenko
2020-04-18  4:06       ` Dejin Zheng
2020-04-17 20:36 Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).