2020-05-03 13:12:20

by Aishwarya Ramakrishnan

[permalink] [raw]
Subject: [PATCH] i2c: img-scb: Use devm_platform_ioremap_resource and remove superfluous error message.

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

The function platform_get_irq can log an error by itself.
Omit a redundant message for exception handling in the
calling function.

Suggested by coccinelle.

Signed-off-by: Aishwarya Ramakrishnan <[email protected]>
---
drivers/i2c/busses/i2c-img-scb.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index 422097a31c95..98a89301ed2a 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -1330,7 +1330,6 @@ static int img_i2c_probe(struct platform_device *pdev)
{
struct device_node *node = pdev->dev.of_node;
struct img_i2c *i2c;
- struct resource *res;
int irq, ret;
u32 val;

@@ -1338,16 +1337,13 @@ static int img_i2c_probe(struct platform_device *pdev)
if (!i2c)
return -ENOMEM;

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- i2c->base = devm_ioremap_resource(&pdev->dev, res);
+ i2c->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(i2c->base))
return PTR_ERR(i2c->base);

irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "can't get irq number\n");
+ if (irq < 0)
return irq;
- }

i2c->sys_clk = devm_clk_get(&pdev->dev, "sys");
if (IS_ERR(i2c->sys_clk)) {
--
2.17.1


2020-05-03 16:31:26

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] i2c: img-scb: Use devm_platform_ioremap_resource and remove superfluous error message.

On Sun, May 3, 2020 at 4:13 PM Aishwarya Ramakrishnan
<[email protected]> wrote:
>
> Use the helper function that wraps the calls to
> platform_get_resource() and devm_ioremap_resource()
> together.
>
> The function platform_get_irq can log an error by itself.
> Omit a redundant message for exception handling in the
> calling function.
>
> Suggested by coccinelle.

Should be two patches, each of which with an explanation given. (And
of course you have to mention after cutter line '---' what kind of
tests you performed?)

--
With Best Regards,
Andy Shevchenko