Skip to contentSkip to conversation

iio: adc: at91-adc: Use devm_platform_ioremap_resource

PATCH In review Aishwarya R 4 participants 10 messages Apr 9, 2020 – Apr 13, 2020

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

PATCH 1/1 iio: adc: at91-adc: Use devm_platform_ioremap_resource

Use the helper function that wraps the calls to platform_get_resource() and devm_ioremap_resource() together.

---
 drivers/iio/adc/at91_adc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/adc/at91_adc.c +1 -4
index abe99856c823..0368b6dc6d60 100644
@@ -1152,7 +1152,6 @@ static int at91_adc_probe(struct platform_device *pdev)
 	int ret;
 	struct iio_dev *idev;
 	struct at91_adc_state *st;
-	struct resource *res;
 	u32 reg;
 
 	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
@@ -1182,9 +1181,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 	if (st->irq < 0)
 		return -ENODEV;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	st->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	st->reg_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(st->reg_base))
 		return PTR_ERR(st->reg_base);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Aishwarya R

Use the helper function that wraps the calls to platform_get_resource() and devm_ioremap_resource() together.

Please elaborate the actual value of doing that.

Quoted 31 lines
---
 drivers/iio/adc/at91_adc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/adc/at91_adc.c +1 -4
index abe99856c823..0368b6dc6d60 100644
@@ -1152,7 +1152,6 @@ static int at91_adc_probe(struct platform_device *pdev)
 	int ret;
 	struct iio_dev *idev;
 	struct at91_adc_state *st;
-	struct resource *res;
 	u32 reg;
 
 	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
@@ -1182,9 +1181,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 	if (st->irq < 0)
 		return -ENODEV;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	st->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	st->reg_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(st->reg_base))
 		return PTR_ERR(st->reg_base);
 
Signature · 1 line
2.17.1
Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw
Quoted 6 lines · Alexandre Belloni
Quoted 3 lines · Aishwarya R

Use the helper function that wraps the calls to platform_get_resource() and devm_ioremap_resource() together.

Please elaborate the actual value of doing that.

Please, elaborate actual value of not doing that.

Yes, I know that you are p* off of these changes, but why you not going further and forbid all clean ups we are doing in the code?

To the point. Above change is reducing code base and showing the new comers modern APIs to use.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Alexandre Belloni
Quoted 3 lines · Aishwarya R

Use the helper function that wraps the calls to platform_get_resource() and devm_ioremap_resource() together.

Please elaborate the actual value of doing that.

Quoted 8 lines

Please, elaborate actual value of not doing that.

Yes, I know that you are p* off of these changes, but why you not going further and forbid all clean ups we are doing in the code?

To the point. Above change is reducing code base and showing the new comers modern APIs to use.

The value of doing it is to reduce the code size by 16 bytes. The same people doing that will actively ruin that by adding error string for error that will never ever happen.

Also, the commit message is definitively lacking. A good commit message would say that the patch has been generated using coccinelle, that no testing has been done and that no thought has been given.

It would definitively make sense to send one patch per subsystem instead of having 475 different patches each changing only one location.

The whole "let's let newcomers fix trivial bugs" thing is definitively not working and it is not leading to an increase of the number of useful reviewers and contributors

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw
Quoted 15 lines · Alexandre Belloni
Quoted 14 lines · Andy Shevchenko
Quoted 6 lines · Alexandre Belloni
Quoted 3 lines · Aishwarya R

Use the helper function that wraps the calls to platform_get_resource() and devm_ioremap_resource() together.

Please elaborate the actual value of doing that.

Please, elaborate actual value of not doing that.

Yes, I know that you are p* off of these changes, but why you not going further and forbid all clean ups we are doing in the code?

Quoted 6 lines
Quoted 2 lines

To the point. Above change is reducing code base and showing the new comers modern APIs to use.

The value of doing it is to reduce the code size by 16 bytes. The same people doing that will actively ruin that by adding error string for error that will never ever happen.

I don't see it in the patch we are discussing, so, not an argument.

Quoted 3 lines

Also, the commit message is definitively lacking. A good commit message would say that the patch has been generated using coccinelle, that no testing has been done and that no thought has been given.

That's I agree with.
But somebody need to teach people how to do it better.

Quoted 2 lines

It would definitively make sense to send one patch per subsystem instead of having 475 different patches each changing only one location.

Depends on the maintainer and subsystem. This is arguable argument. In my subsystems (let's forget about PDx86, where one per subsystem in principle is not working by nature of the subsystem, but consider others I'm maintaining) I prefer to have a possibility to track changes independently on driver basis.

Quoted 3 lines

The whole "let's let newcomers fix trivial bugs" thing is definitively not working and it is not leading to an increase of the number of useful reviewers and contributors

Semi-agree. That people can be self-organized into a reviewer gang and try to learn together.
In any case, as for maintainers, the task has not only technical aspects, but mentoring as well.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#5 lore raw
Quoted 33 lines · On Fri, 10 Apr 2020 19:37:25 +0300 Andy Shevchenko <[email protected]>…
Quoted 15 lines · Alexandre Belloni
Quoted 14 lines · Andy Shevchenko
Quoted 6 lines · Alexandre Belloni
Quoted 3 lines · Aishwarya R

Use the helper function that wraps the calls to platform_get_resource() and devm_ioremap_resource() together.

Please elaborate the actual value of doing that.

Please, elaborate actual value of not doing that.

Yes, I know that you are p* off of these changes, but why you not going further and forbid all clean ups we are doing in the code?

Quoted 6 lines
Quoted 2 lines

To the point. Above change is reducing code base and showing the new comers modern APIs to use.

The value of doing it is to reduce the code size by 16 bytes. The same people doing that will actively ruin that by adding error string for error that will never ever happen.

I don't see it in the patch we are discussing, so, not an argument.

Quoted 3 lines

Also, the commit message is definitively lacking. A good commit message would say that the patch has been generated using coccinelle, that no testing has been done and that no thought has been given.

That's I agree with.
But somebody need to teach people how to do it better.

Quoted 8 lines
Quoted 2 lines

It would definitively make sense to send one patch per subsystem instead of having 475 different patches each changing only one location.

Depends on the maintainer and subsystem. This is arguable argument. In my subsystems (let's forget about PDx86, where one per subsystem in principle is not working by nature of the subsystem, but consider others I'm maintaining) I prefer to have a possibility to track changes independently on driver basis.

Likewise. I often request patches are broken out.

Quoted 10 lines
Quoted 4 lines

The whole "let's let newcomers fix trivial bugs" thing is definitively not working and it is not leading to an increase of the number of useful reviewers and contributors

Semi-agree. That people can be self-organized into a reviewer gang and try to learn together.
In any case, as for maintainers, the task has not only technical aspects, but mentoring as well.

It would be interesting to see if we do have examples of people who have started with cleanup patches and moved on to more interesting things. Some of the outreach programs that start with simple patches as a means of getting familiar with the tools have led to more significant improvements but those are somewhat of a special case.

I'd rather have hundreds of people send me these sorts of patches a year than loose one potential long term contributor.

Jonathan

p.s. Aishwarya - You've been a bit unlucky in a sense here running into the latest instance of a very long term debate!

#6 lore raw

PATCH 1/1 iio: adc: at91-adc: Use devm_platform_ioremap_resource

In reply to Aishwarya R

Use helper function to simply the code.
The devm_platform_ioremap_resource() helper in the kernel which helps to make code cleaner a tad by replacing few "boilerplate" lines of code with a single line.

maintainer
#7 lore raw
In reply to Aishwarya R
Quoted 5 lines · On Thu, 9 Apr 2020 20:41:23 +0530 Aishwarya R <[email protected]> wrote:

Use the helper function that wraps the calls to platform_get_resource() and devm_ioremap_resource() together.

Hi Aishwarya R,

Thanks for the patch. Good to add a little more detail to the description and note that I do prefer one patch per driver for IIO drivers.

One other thing. Please use full name for the signed-off-by. I see you use a longer form in your email later in the thread. The DCO is a formal legal statement
https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin
so we tend to be fussy!

Thanks,

Jonathan

Quoted 27 lines
---
 drivers/iio/adc/at91_adc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/adc/at91_adc.c +1 -4
index abe99856c823..0368b6dc6d60 100644
@@ -1152,7 +1152,6 @@ static int at91_adc_probe(struct platform_device *pdev)
 	int ret;
 	struct iio_dev *idev;
 	struct at91_adc_state *st;
-	struct resource *res;
 	u32 reg;
 
 	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
@@ -1182,9 +1181,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 	if (st->irq < 0)
 		return -ENODEV;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	st->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	st->reg_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(st->reg_base))
 		return PTR_ERR(st->reg_base);
 
#8 lore raw

PATCH 1/1 iio: adc: at91-adc: Use devm_platform_ioremap_resource

In reply to Aishwarya R

From: Aishwarya Ramakrishnan <[email protected]>

Use the helper function that wraps the calls to platform_get_resource() and devm_ioremap_resource() together. It reduces boilerplate and suggested by coccinelle.

---
 drivers/iio/adc/at91_adc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/adc/at91_adc.c +1 -4
index abe99856c823..0368b6dc6d60 100644
@@ -1152,7 +1152,6 @@ static int at91_adc_probe(struct platform_device *pdev)
 	int ret;
 	struct iio_dev *idev;
 	struct at91_adc_state *st;
-	struct resource *res;
 	u32 reg;
 
 	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
@@ -1182,9 +1181,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 	if (st->irq < 0)
 		return -ENODEV;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	st->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	st->reg_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(st->reg_base))
 		return PTR_ERR(st->reg_base);
 
Signature · 1 line
2.17.1
maintainer
#9 lore raw
Quoted 7 lines · On Sun, 12 Apr 2020 19:26:42 +0530 Aishwarya R <[email protected]> wrote:

From: Aishwarya Ramakrishnan <[email protected]>

Use the helper function that wraps the calls to platform_get_resource() and devm_ioremap_resource() together. It reduces boilerplate and suggested by coccinelle.

Same comments as the previous patch. Applied anyway (this time) mostly because it's quicker for me than insisting on a v3.

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 27 lines
---
 drivers/iio/adc/at91_adc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/iio/adc/at91_adc.c +1 -4
index abe99856c823..0368b6dc6d60 100644
@@ -1152,7 +1152,6 @@ static int at91_adc_probe(struct platform_device *pdev)
 	int ret;
 	struct iio_dev *idev;
 	struct at91_adc_state *st;
-	struct resource *res;
 	u32 reg;
 
 	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
@@ -1182,9 +1181,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 	if (st->irq < 0)
 		return -ENODEV;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	st->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	st->reg_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(st->reg_base))
 		return PTR_ERR(st->reg_base);