From: linux@roeck-us.net (Guenter Roeck)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 05/62] watchdog: bcm2835_wdt: Convert to use device managed functions and other improvements
Date: Tue, 10 Jan 2017 15:34:22 -0800 [thread overview]
Message-ID: <1484091325-9199-6-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1484091325-9199-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
- Replace of_iomap() with platform_get_resource() followed by
devm_ioremap_resource()
- Replace &pdev->dev with dev if 'struct device *dev' is a declared
variable
- Use devm_watchdog_register_driver() to register watchdog device
- Replace shutdown function with call to watchdog_stop_on_reboot()
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Lee Jones <lee@kernel.org>
Cc: Eric Anholt <eric@anholt.net>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Ray Jui <rjui@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: bcm-kernel-feedback-list at broadcom.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/watchdog/bcm2835_wdt.c | 27 ++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)
diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c
index 4e0adb6c88f0..496f6c106bb1 100644
--- a/drivers/watchdog/bcm2835_wdt.c
+++ b/drivers/watchdog/bcm2835_wdt.c
@@ -172,8 +172,8 @@ static void bcm2835_power_off(void)
static int bcm2835_wdt_probe(struct platform_device *pdev)
{
+ struct resource *res;
struct device *dev = &pdev->dev;
- struct device_node *np = dev->of_node;
struct bcm2835_wdt *wdt;
int err;
@@ -184,16 +184,15 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)
spin_lock_init(&wdt->lock);
- wdt->base = of_iomap(np, 0);
- if (!wdt->base) {
- dev_err(dev, "Failed to remap watchdog regs");
- return -ENODEV;
- }
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ wdt->base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(wdt->base))
+ return PTR_ERR(wdt->base);
watchdog_set_drvdata(&bcm2835_wdt_wdd, wdt);
watchdog_init_timeout(&bcm2835_wdt_wdd, heartbeat, dev);
watchdog_set_nowayout(&bcm2835_wdt_wdd, nowayout);
- bcm2835_wdt_wdd.parent = &pdev->dev;
+ bcm2835_wdt_wdd.parent = dev;
if (bcm2835_wdt_is_running(wdt)) {
/*
* The currently active timeout value (set by the
@@ -208,10 +207,10 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)
watchdog_set_restart_priority(&bcm2835_wdt_wdd, 128);
- err = watchdog_register_device(&bcm2835_wdt_wdd);
+ watchdog_stop_on_reboot(&bcm2835_wdt_wdd);
+ err = devm_watchdog_register_device(dev, &bcm2835_wdt_wdd);
if (err) {
dev_err(dev, "Failed to register watchdog device");
- iounmap(wdt->base);
return err;
}
@@ -224,21 +223,12 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)
static int bcm2835_wdt_remove(struct platform_device *pdev)
{
- struct bcm2835_wdt *wdt = platform_get_drvdata(pdev);
-
if (pm_power_off == bcm2835_power_off)
pm_power_off = NULL;
- watchdog_unregister_device(&bcm2835_wdt_wdd);
- iounmap(wdt->base);
return 0;
}
-static void bcm2835_wdt_shutdown(struct platform_device *pdev)
-{
- bcm2835_wdt_stop(&bcm2835_wdt_wdd);
-}
-
static const struct of_device_id bcm2835_wdt_of_match[] = {
{ .compatible = "brcm,bcm2835-pm-wdt", },
{},
@@ -248,7 +238,6 @@ MODULE_DEVICE_TABLE(of, bcm2835_wdt_of_match);
static struct platform_driver bcm2835_wdt_driver = {
.probe = bcm2835_wdt_probe,
.remove = bcm2835_wdt_remove,
- .shutdown = bcm2835_wdt_shutdown,
.driver = {
.name = "bcm2835-wdt",
.of_match_table = bcm2835_wdt_of_match,
--
2.7.4
next parent reply other threads:[~2017-01-10 23:34 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1484091325-9199-1-git-send-email-linux@roeck-us.net>
2017-01-10 23:34 ` Guenter Roeck [this message]
2017-01-14 6:27 ` [PATCH 05/62] watchdog: bcm2835_wdt: Convert to use device managed functions and other improvements Eric Anholt
2017-01-10 23:34 ` [PATCH 10/62] watchdog: coh901327_wdt: Convert to use device managed functions Guenter Roeck
2017-01-11 15:48 ` Linus Walleij
2017-01-10 23:34 ` [PATCH 16/62] watchdog: digicolor_wdt: Convert to use device managed functions and other improvements Guenter Roeck
2017-01-12 11:47 ` Baruch Siach
2017-01-10 23:34 ` [PATCH 27/62] watchdog: lpc18xx_wdt: " Guenter Roeck
[not found] ` <1484095516-12720-1-git-send-email-linux@roeck-us.net>
2017-01-11 0:44 ` [PATCH 32/62] watchdog: meson_gxbb_wdt: " Guenter Roeck
2017-01-11 8:42 ` Neil Armstrong
2017-01-11 18:44 ` Kevin Hilman
2017-01-11 0:44 ` [PATCH 33/62] watchdog: meson_wdt: " Guenter Roeck
2017-01-11 18:45 ` Kevin Hilman
2017-01-11 0:44 ` [PATCH 37/62] watchdog: mtk_wdt: " Guenter Roeck
2017-01-11 0:44 ` [PATCH 39/62] watchdog: of_xilinx_wdt: Convert to use device managed functions Guenter Roeck
2017-01-11 0:44 ` [PATCH 44/62] watchdog: pnx4008_wdt: " Guenter Roeck
2017-01-12 0:13 ` Vladimir Zapolskiy
2017-01-11 2:09 ` [PATCH 52/62] watchdog: sirfsoc_wdt: Convert to use device managed functions and other improvements 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 ` [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 2:09 ` [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Guenter Roeck
2017-01-11 9:07 ` Marc Gonzalez
2017-01-11 10:52 ` Guenter Roeck
2017-01-11 12:31 ` Marc Gonzalez
2017-01-11 14:25 ` Guenter Roeck
2017-01-11 14:43 ` Måns Rullgård
2017-01-11 15:28 ` Marc Gonzalez
2017-01-11 17:51 ` Guenter Roeck
2017-01-12 9:44 ` Marc Gonzalez
2017-01-12 9:57 ` Uwe Kleine-König
2017-01-12 11:24 ` Måns Rullgård
2017-01-12 12:15 ` Marc Gonzalez
2017-01-11 14:39 ` Uwe Kleine-König
2017-01-11 14:50 ` Vladimir Zapolskiy
2017-01-11 17:28 ` Guenter Roeck
2017-01-13 5:17 ` Guenter Roeck
2017-01-12 0:12 ` Andy Shevchenko
2017-01-12 1:29 ` Guenter Roeck
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=1484091325-9199-6-git-send-email-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-arm-kernel@lists.infradead.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).