From: Guenter Roeck <linux@roeck-us.net> To: Wim Van Sebroeck <wim@iguana.be> Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>, Maxime Ripard <maxime.ripard@free-electrons.com>, Chen-Yu Tsai <wens@csie.org>, linux-arm-kernel@lists.infradead.org Subject: [PATCH 55/62] watchdog: sunxi_wdt: Convert to use device managed functions and other improvements Date: Tue, 10 Jan 2017 18:09:09 -0800 [thread overview] Message-ID: <1484100561-17638-4-git-send-email-linux@roeck-us.net> (raw) In-Reply-To: <1484100561-17638-1-git-send-email-linux@roeck-us.net> Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop remove function - Drop platform_set_drvdata() - Use devm_watchdog_register_driver() to register watchdog device - Replace shutdown function with call to watchdog_stop_on_reboot() Cc: Maxime Ripard <maxime.ripard@free-electrons.com> Cc: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> --- drivers/watchdog/sunxi_wdt.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c index 953bb7b7446f..9728fa32c357 100644 --- a/drivers/watchdog/sunxi_wdt.c +++ b/drivers/watchdog/sunxi_wdt.c @@ -242,8 +242,6 @@ static int sunxi_wdt_probe(struct platform_device *pdev) if (!sunxi_wdt) return -EINVAL; - platform_set_drvdata(pdev, sunxi_wdt); - device = of_match_device(sunxi_wdt_dt_ids, &pdev->dev); if (!device) return -ENODEV; @@ -270,7 +268,8 @@ static int sunxi_wdt_probe(struct platform_device *pdev) sunxi_wdt_stop(&sunxi_wdt->wdt_dev); - err = watchdog_register_device(&sunxi_wdt->wdt_dev); + watchdog_stop_on_reboot(&sunxi_wdt->wdt_dev); + err = devm_watchdog_register_device(&pdev->dev, &sunxi_wdt->wdt_dev); if (unlikely(err)) return err; @@ -280,27 +279,8 @@ static int sunxi_wdt_probe(struct platform_device *pdev) return 0; } -static int sunxi_wdt_remove(struct platform_device *pdev) -{ - struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(&sunxi_wdt->wdt_dev); - watchdog_set_drvdata(&sunxi_wdt->wdt_dev, NULL); - - return 0; -} - -static void sunxi_wdt_shutdown(struct platform_device *pdev) -{ - struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev); - - sunxi_wdt_stop(&sunxi_wdt->wdt_dev); -} - static struct platform_driver sunxi_wdt_driver = { .probe = sunxi_wdt_probe, - .remove = sunxi_wdt_remove, - .shutdown = sunxi_wdt_shutdown, .driver = { .name = DRV_NAME, .of_match_table = sunxi_wdt_dt_ids, -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: linux@roeck-us.net (Guenter Roeck) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 55/62] watchdog: sunxi_wdt: Convert to use device managed functions and other improvements Date: Tue, 10 Jan 2017 18:09:09 -0800 [thread overview] Message-ID: <1484100561-17638-4-git-send-email-linux@roeck-us.net> (raw) In-Reply-To: <1484100561-17638-1-git-send-email-linux@roeck-us.net> Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop remove function - Drop platform_set_drvdata() - Use devm_watchdog_register_driver() to register watchdog device - Replace shutdown function with call to watchdog_stop_on_reboot() Cc: Maxime Ripard <maxime.ripard@free-electrons.com> Cc: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> --- drivers/watchdog/sunxi_wdt.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c index 953bb7b7446f..9728fa32c357 100644 --- a/drivers/watchdog/sunxi_wdt.c +++ b/drivers/watchdog/sunxi_wdt.c @@ -242,8 +242,6 @@ static int sunxi_wdt_probe(struct platform_device *pdev) if (!sunxi_wdt) return -EINVAL; - platform_set_drvdata(pdev, sunxi_wdt); - device = of_match_device(sunxi_wdt_dt_ids, &pdev->dev); if (!device) return -ENODEV; @@ -270,7 +268,8 @@ static int sunxi_wdt_probe(struct platform_device *pdev) sunxi_wdt_stop(&sunxi_wdt->wdt_dev); - err = watchdog_register_device(&sunxi_wdt->wdt_dev); + watchdog_stop_on_reboot(&sunxi_wdt->wdt_dev); + err = devm_watchdog_register_device(&pdev->dev, &sunxi_wdt->wdt_dev); if (unlikely(err)) return err; @@ -280,27 +279,8 @@ static int sunxi_wdt_probe(struct platform_device *pdev) return 0; } -static int sunxi_wdt_remove(struct platform_device *pdev) -{ - struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(&sunxi_wdt->wdt_dev); - watchdog_set_drvdata(&sunxi_wdt->wdt_dev, NULL); - - return 0; -} - -static void sunxi_wdt_shutdown(struct platform_device *pdev) -{ - struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev); - - sunxi_wdt_stop(&sunxi_wdt->wdt_dev); -} - static struct platform_driver sunxi_wdt_driver = { .probe = sunxi_wdt_probe, - .remove = sunxi_wdt_remove, - .shutdown = sunxi_wdt_shutdown, .driver = { .name = DRV_NAME, .of_match_table = sunxi_wdt_dt_ids, -- 2.7.4
next prev parent reply other threads:[~2017-01-11 2:09 UTC|newest] Thread overview: 143+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-01-10 23:34 [PATCH 00/62] watchdog: Convert to use device managed functions Guenter Roeck 2017-01-10 23:34 ` [PATCH 01/62] watchdog: asm9260_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-10 23:34 ` [PATCH 02/62] watchdog: aspeed_wdt: Convert to use device managed functions Guenter Roeck 2017-01-11 5:18 ` Joel Stanley 2017-01-10 23:34 ` [PATCH 03/62] watchdog: at91sam9_wdt: " Guenter Roeck 2017-01-10 23:34 ` [PATCH 04/62] watchdog: atlas7_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-10 23:34 ` [PATCH 05/62] watchdog: bcm2835_wdt: " Guenter Roeck 2017-01-10 23:34 ` Guenter Roeck 2017-01-14 6:27 ` Eric Anholt 2017-01-14 6:27 ` Eric Anholt 2017-01-10 23:34 ` [PATCH 06/62] watchdog: bcm47xx_wdt: Convert to use device managed functions Guenter Roeck 2017-01-10 23:34 ` [PATCH 07/62] watchdog: bcm7038_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-10 23:34 ` [PATCH 08/62] watchdog: bcm_kona_wdt: " Guenter Roeck 2017-01-10 23:34 ` [PATCH 09/62] watchdog: cadence_wdt: " Guenter Roeck 2017-01-10 23:34 ` [PATCH 10/62] watchdog: coh901327_wdt: Convert to use device managed functions Guenter Roeck 2017-01-10 23:34 ` Guenter Roeck 2017-01-11 15:48 ` Linus Walleij 2017-01-11 15:48 ` Linus Walleij 2017-01-11 15:48 ` Linus Walleij 2017-01-10 23:34 ` [PATCH 11/62] watchdog: da9052_wdt: " Guenter Roeck 2017-01-17 14:12 ` Adam Thomson 2017-01-10 23:34 ` [PATCH 12/62] watchdog: da9055_wdt: " Guenter Roeck 2017-01-17 13:58 ` Adam Thomson 2017-01-10 23:34 ` [PATCH 13/62] watchdog: da9062_wdt: " Guenter Roeck 2017-01-17 14:17 ` Adam Thomson 2017-01-10 23:34 ` [PATCH 14/62] watchdog: da9063_wdt: " Guenter Roeck 2017-01-17 14:19 ` Adam Thomson 2017-01-10 23:34 ` [PATCH 15/62] watchdog: davinci_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-10 23:34 ` [PATCH 16/62] watchdog: digicolor_wdt: " Guenter Roeck 2017-01-10 23:34 ` Guenter Roeck 2017-01-12 11:47 ` Baruch Siach 2017-01-12 11:47 ` Baruch Siach 2017-01-10 23:34 ` [PATCH 17/62] watchdog: dw_wdt: Convert to use device managed functions Guenter Roeck 2017-01-10 23:34 ` [PATCH 18/62] watchdog: ep93xx_wdt: " Guenter Roeck 2017-01-10 23:34 ` [PATCH 19/62] watchdog: gpio_wdt: " Guenter Roeck 2017-01-10 23:34 ` [PATCH 20/62] watchdog: iTCO_wdt: Replace shutdown function with call to watchdog_stop_on_reboot Guenter Roeck 2017-01-11 23:36 ` Andy Shevchenko 2017-01-10 23:34 ` [PATCH 21/62] watchdog: imgpdc_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-10 23:34 ` [PATCH 22/62] watchdog: imx2_wdt: Convert to use device managed functions Guenter Roeck 2017-01-10 23:34 ` [PATCH 23/62] watchdog: intel-mid_wdt: " Guenter Roeck 2017-01-11 23:36 ` Andy Shevchenko 2017-01-10 23:34 ` [PATCH 24/62] watchdog: jz4740_wdt: " Guenter Roeck 2017-01-10 23:34 ` [PATCH 25/62] watchdog: kempld_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-10 23:34 ` [PATCH 26/62] watchdog: loongson1_wdt: Convert to use device managed functions Guenter Roeck 2017-01-10 23:34 ` [PATCH 27/62] watchdog: lpc18xx_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-10 23:34 ` Guenter Roeck 2017-01-10 23:34 ` [PATCH 28/62] watchdog: max63xx_wdt: Convert to use device managed functions Guenter Roeck 2017-01-10 23:34 ` [PATCH 29/62] watchdog: max77620_wdt: " Guenter Roeck 2017-01-10 23:34 ` [PATCH 30/62] watchdog: mena21_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-13 8:08 ` Johannes Thumshirn 2017-01-11 0:44 ` [PATCH 31/62] watchdog: menf21bmc_wdt: Convert to use device managed functions Guenter Roeck 2017-01-11 0:44 ` [PATCH 32/62] watchdog: meson_gxbb_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-11 0:44 ` Guenter Roeck 2017-01-11 0:44 ` Guenter Roeck 2017-01-11 8:42 ` Neil Armstrong 2017-01-11 8:42 ` Neil Armstrong 2017-01-11 8:42 ` Neil Armstrong 2017-01-11 18:44 ` Kevin Hilman 2017-01-11 18:44 ` Kevin Hilman 2017-01-11 18:44 ` Kevin Hilman 2017-01-11 0:44 ` [PATCH 33/62] watchdog: meson_wdt: " Guenter Roeck 2017-01-11 0:44 ` Guenter Roeck 2017-01-11 0:44 ` Guenter Roeck 2017-01-11 18:45 ` Kevin Hilman 2017-01-11 18:45 ` Kevin Hilman 2017-01-11 18:45 ` Kevin Hilman 2017-01-11 0:44 ` [PATCH 34/62] watchdog: moxart_wdt: Convert to use device managed functions Guenter Roeck 2017-01-11 0:44 ` [PATCH 35/62] watchdog: mpc8xxx_wdt: " Guenter Roeck 2017-01-11 0:44 ` [PATCH 36/62] watchdog: mt7621_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-11 0:44 ` [PATCH 37/62] watchdog: mtk_wdt: " Guenter Roeck 2017-01-11 0:44 ` Guenter Roeck 2017-01-11 0:44 ` [PATCH 38/62] watchdog: nic7018_wdt: Convert to use device managed functions Guenter Roeck 2017-01-11 0:44 ` [PATCH 39/62] watchdog: of_xilinx_wdt: " Guenter Roeck 2017-01-11 0:44 ` Guenter Roeck 2017-01-11 0:44 ` [PATCH 40/62] watchdog: omap_wdt: " Guenter Roeck 2017-01-11 0:44 ` [PATCH 41/62] watchdog: orion_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-11 0:44 ` [PATCH 42/62] watchdog: pic32-dmt: Convert to use device managed functions Guenter Roeck 2017-01-11 0:44 ` [PATCH 43/62] watchdog: pic32-wdt: " Guenter Roeck 2017-01-11 0:44 ` [PATCH 44/62] watchdog: pnx4008_wdt: " Guenter Roeck 2017-01-11 0:44 ` Guenter Roeck 2017-01-12 0:13 ` Vladimir Zapolskiy 2017-01-12 0:13 ` Vladimir Zapolskiy 2017-01-11 0:44 ` [PATCH 45/62] watchdog: qcom-wdt: " Guenter Roeck 2017-01-11 0:44 ` [PATCH 46/62] watchdog: renesas_wdt: " Guenter Roeck 2017-01-11 0:44 ` [PATCH 47/62] watchdog: retu_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-11 0:44 ` [PATCH 48/62] watchdog: rt2880_wdt: " Guenter Roeck 2017-01-11 0:44 ` [PATCH 49/62] watchdog: sama5d4_wdt: Convert to use device managed functions Guenter Roeck 2017-01-11 0:44 ` [PATCH 50/62] watchdog: sbsa_gwdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-11 0:45 ` [PATCH 51/62] watchdog: shwdt: " Guenter Roeck 2017-01-11 2:09 ` [PATCH 52/62] watchdog: sirfsoc_wdt: " Guenter Roeck 2017-01-11 2:09 ` Guenter Roeck 2017-01-11 2:09 ` [PATCH 53/62] watchdog: st_lpc_wdt: Convert to use device managed functions Guenter Roeck 2017-01-11 2:09 ` Guenter Roeck 2017-01-11 2:09 ` [PATCH 54/62] watchdog: stmp3xxx_rtc_wdt: " Guenter Roeck 2017-01-11 2:09 ` Guenter Roeck [this message] 2017-01-11 2:09 ` [PATCH 55/62] watchdog: sunxi_wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-11 12:15 ` Maxime Ripard 2017-01-11 12:15 ` Maxime Ripard 2017-01-11 2:09 ` [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Guenter Roeck 2017-01-11 2:09 ` Guenter Roeck 2017-01-11 9:07 ` Marc Gonzalez 2017-01-11 9:07 ` Marc Gonzalez 2017-01-11 10:52 ` Guenter Roeck 2017-01-11 10:52 ` Guenter Roeck 2017-01-11 12:31 ` Marc Gonzalez 2017-01-11 12:31 ` Marc Gonzalez 2017-01-11 14:25 ` Guenter Roeck 2017-01-11 14:25 ` Guenter Roeck 2017-01-11 14:43 ` Måns Rullgård 2017-01-11 14:43 ` Måns Rullgård 2017-01-11 15:28 ` Marc Gonzalez 2017-01-11 15:28 ` Marc Gonzalez 2017-01-11 17:51 ` Guenter Roeck 2017-01-11 17:51 ` Guenter Roeck 2017-01-12 9:44 ` Marc Gonzalez 2017-01-12 9:44 ` Marc Gonzalez 2017-01-12 9:57 ` Uwe Kleine-König 2017-01-12 9:57 ` Uwe Kleine-König 2017-01-12 11:24 ` Måns Rullgård 2017-01-12 11:24 ` Måns Rullgård 2017-01-12 12:15 ` Marc Gonzalez 2017-01-12 12:15 ` Marc Gonzalez 2017-01-11 14:39 ` Uwe Kleine-König 2017-01-11 14:39 ` Uwe Kleine-König 2017-01-11 14:50 ` Vladimir Zapolskiy 2017-01-11 14:50 ` Vladimir Zapolskiy 2017-01-11 17:28 ` Guenter Roeck 2017-01-11 17:28 ` Guenter Roeck 2017-01-13 5:17 ` Guenter Roeck 2017-01-13 5:17 ` Guenter Roeck 2017-01-12 0:12 ` Andy Shevchenko 2017-01-12 0:12 ` Andy Shevchenko 2017-01-12 1:29 ` Guenter Roeck 2017-01-12 1:29 ` Guenter Roeck 2017-01-11 2:09 ` [PATCH 57/62] watchdog: tegra_wdt: " Guenter Roeck [not found] ` <1484100561-17638-6-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org> 2017-01-19 11:04 ` Thierry Reding 2017-01-19 11:04 ` Thierry Reding 2017-01-11 2:09 ` [PATCH 58/62] watchdog: ts4800_wdt: " Guenter Roeck 2017-01-11 2:09 ` [PATCH 59/62] watchdog: twl4030_wdt: " Guenter Roeck 2017-01-11 2:09 ` [PATCH 60/62] watchdog: txx9wdt: Convert to use device managed functions and other improvements Guenter Roeck 2017-01-11 2:09 ` [PATCH 61/62] watchdog: ux500_wdt: Convert to use device managed functions Guenter Roeck 2017-01-11 2:09 ` [PATCH 62/62] watchdog: wm831x_wdt: " Guenter Roeck 2017-01-12 10:04 ` Charles Keepax
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1484100561-17638-4-git-send-email-linux@roeck-us.net \ --to=linux@roeck-us.net \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-watchdog@vger.kernel.org \ --cc=maxime.ripard@free-electrons.com \ --cc=wens@csie.org \ --cc=wim@iguana.be \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.