diff mbox series

[08/11] i2c: sh_mobile: Use devm_platform_get_and_ioremap_resource()

Message ID 20230705135159.33327-8-frank.li@vivo.com (mailing list archive)
State Accepted
Delegated to: Geert Uytterhoeven
Headers show
Series None | expand

Commit Message

Yangtao Li July 5, 2023, 1:51 p.m. UTC
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/i2c/busses/i2c-sh_mobile.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Geert Uytterhoeven July 5, 2023, 2:44 p.m. UTC | #1
Hi Yangtao,

On Wed, Jul 5, 2023 at 3:56 PM Yangtao Li <frank.li@vivo.com> wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Thanks for your patch!

> --- a/drivers/i2c/busses/i2c-sh_mobile.c
> +++ b/drivers/i2c/busses/i2c-sh_mobile.c
> @@ -893,12 +893,10 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
>         pd->dev = &dev->dev;
>         platform_set_drvdata(dev, pd);
>
> -       res = platform_get_resource(dev, IORESOURCE_MEM, 0);
> -
> -       pd->res = res;
> -       pd->reg = devm_ioremap_resource(&dev->dev, res);
> +       pd->reg = devm_platform_get_and_ioremap_resource(pdev, 0, &res);

"pdev" does not exist in this context.
Please try to at least compile-test your patches before submitting them.

>         if (IS_ERR(pd->reg))
>                 return PTR_ERR(pd->reg);
> +       pd->res = res;

While at it, you could get rid of "res", and replace it by "pd->res" in the
above call to devm_platform_get_and_ioremap_resource().

>
>         ret = of_property_read_u32(dev->dev.of_node, "clock-frequency", &bus_speed);
>         pd->bus_speed = (ret || !bus_speed) ? I2C_MAX_STANDARD_MODE_FREQ : bus_speed;

Gr{oetje,eeting}s,

                        Geert
Wolfram Sang July 6, 2023, 7:21 p.m. UTC | #2
> Please try to at least compile-test your patches before submitting them.

Yes and no. Not "please try" but "please do". Rejecting this series
until it has been build tested.
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 21717b943a9e..e2da633b5e9d 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -893,12 +893,10 @@  static int sh_mobile_i2c_probe(struct platform_device *dev)
 	pd->dev = &dev->dev;
 	platform_set_drvdata(dev, pd);
 
-	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
-
-	pd->res = res;
-	pd->reg = devm_ioremap_resource(&dev->dev, res);
+	pd->reg = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
 	if (IS_ERR(pd->reg))
 		return PTR_ERR(pd->reg);
+	pd->res = res;
 
 	ret = of_property_read_u32(dev->dev.of_node, "clock-frequency", &bus_speed);
 	pd->bus_speed = (ret || !bus_speed) ? I2C_MAX_STANDARD_MODE_FREQ : bus_speed;