lkml.org 
[lkml]   [2019]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] watchdog: Convert to use devm_platform_ioremap_resource
From
Date
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 <joel@jms.id.au>
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Baruch Siach <baruch@tkos.co.il>
> Cc: Keguang Zhang <keguang.zhang@gmail.com>
> Cc: Vladimir Zapolskiy <vz@mleia.com>
> Cc: Kevin Hilman <khilman@baylibre.com>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: Avi Fishman <avifishman70@gmail.com>
> Cc: Nancy Yuen <yuenn@google.com>
> Cc: Brendan Higgins <brendanhiggins@google.com>
> Cc: Wan ZongShun <mcuos.com@gmail.com>
> Cc: Michal Simek <michal.simek@xilinx.com>
> Cc: Sylvain Lemieux <slemieux.tyco@gmail.com>
> Cc: Kukjin Kim <kgene@kernel.org>
> Cc: Barry Song <baohua@kernel.org>
> Cc: Orson Zhai <orsonzhai@gmail.com>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> Cc: Maxime Ripard <maxime.ripard@bootlin.com>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Cc: Marc Gonzalez <marc.w.gonzalez@free.fr>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Shawn Guo <shawnguo@kernel.org>
> Signed-off-by: Guenter Roeck <linux@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 <vz@mleia.com>

--
Best wishes,
Vladimir

\
 
 \ /
  Last update: 2019-04-05 20:00    [W:0.089 / U:2.704 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site