2020-09-18 08:23:41

by Wangshaobo (bobo)

[permalink] [raw]
Subject: [PATCH -next] i2c: at91: Use devm_platform_get_and_ioremap_resource()

Make use of devm_platform_get_and_ioremap_resource() provided by
driver core platform instead of duplicated analogue.

Signed-off-by: Wang ShaoBo <[email protected]>
---
drivers/i2c/busses/i2c-at91-core.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91-core.c b/drivers/i2c/busses/i2c-at91-core.c
index e14edd236108..5b7781302852 100644
--- a/drivers/i2c/busses/i2c-at91-core.c
+++ b/drivers/i2c/busses/i2c-at91-core.c
@@ -207,19 +207,16 @@ static int at91_twi_probe(struct platform_device *pdev)

dev->dev = &pdev->dev;

- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!mem)
- return -ENODEV;
+ dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
+ if (IS_ERR(dev->base))
+ return PTR_ERR(dev->base);
+
phy_addr = mem->start;

dev->pdata = at91_twi_get_driver_data(pdev);
if (!dev->pdata)
return -ENODEV;

- dev->base = devm_ioremap_resource(&pdev->dev, mem);
- if (IS_ERR(dev->base))
- return PTR_ERR(dev->base);
-
dev->irq = platform_get_irq(pdev, 0);
if (dev->irq < 0)
return dev->irq;
--
2.17.1


2020-10-10 23:00:31

by Codrin Ciubotariu

[permalink] [raw]
Subject: Re: [PATCH -next] i2c: at91: Use devm_platform_get_and_ioremap_resource()

On 18.09.2020 11:21, Wang ShaoBo wrote:
> Make use of devm_platform_get_and_ioremap_resource() provided by
> driver core platform instead of duplicated analogue.
>
> Signed-off-by: Wang ShaoBo <[email protected]>

Reviewed-by: Codrin Ciubotariu <[email protected]>

Thanks!

> ---
> drivers/i2c/busses/i2c-at91-core.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-at91-core.c b/drivers/i2c/busses/i2c-at91-core.c
> index e14edd236108..5b7781302852 100644
> --- a/drivers/i2c/busses/i2c-at91-core.c
> +++ b/drivers/i2c/busses/i2c-at91-core.c
> @@ -207,19 +207,16 @@ static int at91_twi_probe(struct platform_device *pdev)
>
> dev->dev = &pdev->dev;
>
> - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!mem)
> - return -ENODEV;
> + dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
> + if (IS_ERR(dev->base))
> + return PTR_ERR(dev->base);
> +
> phy_addr = mem->start;
>
> dev->pdata = at91_twi_get_driver_data(pdev);
> if (!dev->pdata)
> return -ENODEV;
>
> - dev->base = devm_ioremap_resource(&pdev->dev, mem);
> - if (IS_ERR(dev->base))
> - return PTR_ERR(dev->base);
> -
> dev->irq = platform_get_irq(pdev, 0);
> if (dev->irq < 0)
> return dev->irq;
> --
> 2.17.1
>