On 04/02/2019 10:01 PM, Guenter Roeck wrote:
> Use devm_platform_ioremap_resource to reduce source code size,
> improve readability, and reduce the likelyhood of bugs.
> 
> The conversion was done automatically with coccinelle using the
> following semantic patch.
> 
> @r@
> identifier res, pdev;
> expression a;
> expression index;
> expression e;
> @@
> 
> <+...
> - res = platform_get_resource(pdev, IORESOURCE_MEM, index);
> - a = devm_ioremap_resource(e, res);
> + a = devm_platform_ioremap_resource(pdev, index);
> ...+>
> 
> @depends on r@
> identifier r.res;
> @@
> - struct resource *res;
>   ... when != res
> 
> @@
> identifier res, pdev;
> expression index;
> expression a;
> @@
> - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, index);
> - a = devm_ioremap_resource(&pdev->dev, res);
> + a = devm_platform_ioremap_resource(pdev, index);
> 
> Cc: Joel Stanley <j...@jms.id.au>
> Cc: Nicolas Ferre <nicolas.fe...@microchip.com>
> Cc: Alexandre Belloni <alexandre.bell...@bootlin.com>
> Cc: Florian Fainelli <f.faine...@gmail.com>
> Cc: Linus Walleij <linus.wall...@linaro.org>
> Cc: Baruch Siach <bar...@tkos.co.il>
> Cc: Keguang Zhang <keguang.zh...@gmail.com>
> Cc: Vladimir Zapolskiy <v...@mleia.com>
> Cc: Kevin Hilman <khil...@baylibre.com>
> Cc: Matthias Brugger <matthias....@gmail.com>
> Cc: Avi Fishman <avifishma...@gmail.com>
> Cc: Nancy Yuen <yu...@google.com>
> Cc: Brendan Higgins <brendanhigg...@google.com>
> Cc: Wan ZongShun <mcuos....@gmail.com>
> Cc: Michal Simek <michal.si...@xilinx.com>
> Cc: Sylvain Lemieux <slemieux.t...@gmail.com>
> Cc: Kukjin Kim <kg...@kernel.org>
> Cc: Barry Song <bao...@kernel.org>
> Cc: Orson Zhai <orsonz...@gmail.com>
> Cc: Patrice Chotard <patrice.chot...@st.com>
> Cc: Maxime Coquelin <mcoquelin.st...@gmail.com>
> Cc: Maxime Ripard <maxime.rip...@bootlin.com>
> Cc: Chen-Yu Tsai <w...@csie.org>
> Cc: Marc Gonzalez <marc.w.gonza...@free.fr>
> Cc: Thierry Reding <thierry.red...@gmail.com>
> Cc: Shawn Guo <shawn...@kernel.org>
> Signed-off-by: Guenter Roeck <li...@roeck-us.net>
> ---
>  drivers/watchdog/asm9260_wdt.c    | 4 +---
>  drivers/watchdog/aspeed_wdt.c     | 4 +---
>  drivers/watchdog/at91sam9_wdt.c   | 4 +---
>  drivers/watchdog/ath79_wdt.c      | 4 +---
>  drivers/watchdog/atlas7_wdt.c     | 4 +---
>  drivers/watchdog/bcm7038_wdt.c    | 4 +---
>  drivers/watchdog/bcm_kona_wdt.c   | 4 +---
>  drivers/watchdog/cadence_wdt.c    | 4 +---
>  drivers/watchdog/coh901327_wdt.c  | 4 +---
>  drivers/watchdog/davinci_wdt.c    | 4 +---
>  drivers/watchdog/digicolor_wdt.c  | 4 +---
>  drivers/watchdog/dw_wdt.c         | 4 +---
>  drivers/watchdog/ep93xx_wdt.c     | 4 +---
>  drivers/watchdog/ftwdt010_wdt.c   | 4 +---
>  drivers/watchdog/imgpdc_wdt.c     | 4 +---
>  drivers/watchdog/jz4740_wdt.c     | 4 +---
>  drivers/watchdog/lantiq_wdt.c     | 4 +---
>  drivers/watchdog/loongson1_wdt.c  | 4 +---
>  drivers/watchdog/lpc18xx_wdt.c    | 4 +---
>  drivers/watchdog/max63xx_wdt.c    | 4 +---
>  drivers/watchdog/meson_gxbb_wdt.c | 4 +---
>  drivers/watchdog/meson_wdt.c      | 4 +---
>  drivers/watchdog/moxart_wdt.c     | 4 +---
>  drivers/watchdog/mpc8xxx_wdt.c    | 3 +--
>  drivers/watchdog/mt7621_wdt.c     | 5 +----
>  drivers/watchdog/mtk_wdt.c        | 4 +---
>  drivers/watchdog/npcm_wdt.c       | 4 +---
>  drivers/watchdog/nuc900_wdt.c     | 4 +---
>  drivers/watchdog/of_xilinx_wdt.c  | 4 +---
>  drivers/watchdog/omap_wdt.c       | 4 +---
>  drivers/watchdog/orion_wdt.c      | 6 ++----
>  drivers/watchdog/pic32-dmt.c      | 4 +---
>  drivers/watchdog/pic32-wdt.c      | 4 +---
>  drivers/watchdog/pnx4008_wdt.c    | 4 +---
>  drivers/watchdog/renesas_wdt.c    | 4 +---
>  drivers/watchdog/rt2880_wdt.c     | 4 +---
>  drivers/watchdog/rtd119x_wdt.c    | 4 +---
>  drivers/watchdog/rza_wdt.c        | 4 +---
>  drivers/watchdog/s3c2410_wdt.c    | 4 +---
>  drivers/watchdog/sama5d4_wdt.c    | 4 +---
>  drivers/watchdog/sbsa_gwdt.c      | 7 ++-----
>  drivers/watchdog/shwdt.c          | 4 +---
>  drivers/watchdog/sirfsoc_wdt.c    | 4 +---
>  drivers/watchdog/sprd_wdt.c       | 4 +---
>  drivers/watchdog/st_lpc_wdt.c     | 4 +---
>  drivers/watchdog/stm32_iwdg.c     | 4 +---
>  drivers/watchdog/sunxi_wdt.c      | 4 +---
>  drivers/watchdog/tangox_wdt.c     | 4 +---
>  drivers/watchdog/tegra_wdt.c      | 4 +---
>  drivers/watchdog/ts72xx_wdt.c     | 7 ++-----
>  drivers/watchdog/txx9wdt.c        | 4 +---
>  drivers/watchdog/zx2967_wdt.c     | 4 +---
>  52 files changed, 55 insertions(+), 161 deletions(-)

[snip]

> diff --git a/drivers/watchdog/lpc18xx_wdt.c b/drivers/watchdog/lpc18xx_wdt.c
> index 331cadb459ac..f6f66634cedf 100644
> --- a/drivers/watchdog/lpc18xx_wdt.c
> +++ b/drivers/watchdog/lpc18xx_wdt.c
> @@ -204,15 +204,13 @@ static int lpc18xx_wdt_probe(struct platform_device 
> *pdev)
>  {
>       struct lpc18xx_wdt_dev *lpc18xx_wdt;
>       struct device *dev = &pdev->dev;
> -     struct resource *res;
>       int ret;
>  
>       lpc18xx_wdt = devm_kzalloc(dev, sizeof(*lpc18xx_wdt), GFP_KERNEL);
>       if (!lpc18xx_wdt)
>               return -ENOMEM;
>  
> -     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -     lpc18xx_wdt->base = devm_ioremap_resource(dev, res);
> +     lpc18xx_wdt->base = devm_platform_ioremap_resource(pdev, 0);
>       if (IS_ERR(lpc18xx_wdt->base))
>               return PTR_ERR(lpc18xx_wdt->base);
>  

[snip]

> diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
> index 8e261799c84e..24c266a9e1dc 100644
> --- a/drivers/watchdog/pnx4008_wdt.c
> +++ b/drivers/watchdog/pnx4008_wdt.c
> @@ -185,13 +185,11 @@ static struct watchdog_device pnx4008_wdd = {
>  
>  static int pnx4008_wdt_probe(struct platform_device *pdev)
>  {
> -     struct resource *r;
>       int ret = 0;
>  
>       watchdog_init_timeout(&pnx4008_wdd, heartbeat, &pdev->dev);
>  
> -     r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -     wdt_base = devm_ioremap_resource(&pdev->dev, r);
> +     wdt_base = devm_platform_ioremap_resource(pdev, 0);
>       if (IS_ERR(wdt_base))
>               return PTR_ERR(wdt_base);
>  

For lpc18xx_wdt.c and pnx4008_wdt.c:

Acked-by: Vladimir Zapolskiy <v...@mleia.com>

--
Best wishes,
Vladimir

Reply via email to