Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1556162
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 62/62] watchdog: wm831x_wdt: Convert to use device managed functions |
| Date | 2017-01-11 03:20 +0100 |
| Message-ID | <sYgG5-Sm-13@gated-at.bofh.it> (permalink) |
| References | <sYebf-7JK-3@gated-at.bofh.it> <sYgwq-Pc-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Use device managed functions to simplify error handling, reduce
source code size, improve readability, and reduce the likelyhood of bugs.
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
- Replace 'goto l; ... l: return e;' with 'return e;'
- Replace 'val = e; return val;' with 'return e;'
- Drop assignments to otherwise unused variables
- Replace 'if (e) { return expr; }' with 'if (e) return expr;'
- Drop remove function
- Drop platform_set_drvdata()
- Use devm_watchdog_register_driver() to register watchdog device
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/watchdog/wm831x_wdt.c | 31 +++++++------------------------
1 file changed, 7 insertions(+), 24 deletions(-)
diff --git a/drivers/watchdog/wm831x_wdt.c b/drivers/watchdog/wm831x_wdt.c
index 8d1184aee932..1ddc1f742cd4 100644
--- a/drivers/watchdog/wm831x_wdt.c
+++ b/drivers/watchdog/wm831x_wdt.c
@@ -194,7 +194,7 @@ static int wm831x_wdt_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err(wm831x->dev, "Failed to read watchdog status: %d\n",
ret);
- goto err;
+ return ret;
}
reg = ret;
@@ -203,10 +203,8 @@ static int wm831x_wdt_probe(struct platform_device *pdev)
driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data),
GFP_KERNEL);
- if (!driver_data) {
- ret = -ENOMEM;
- goto err;
- }
+ if (!driver_data)
+ return -ENOMEM;
mutex_init(&driver_data->lock);
driver_data->wm831x = wm831x;
@@ -253,7 +251,7 @@ static int wm831x_wdt_probe(struct platform_device *pdev)
dev_err(wm831x->dev,
"Failed to request update GPIO: %d\n",
ret);
- goto err;
+ return ret;
}
driver_data->update_gpio = pdata->update_gpio;
@@ -269,37 +267,22 @@ static int wm831x_wdt_probe(struct platform_device *pdev)
} else {
dev_err(wm831x->dev,
"Failed to unlock security key: %d\n", ret);
- goto err;
+ return ret;
}
}
- ret = watchdog_register_device(&driver_data->wdt);
+ ret = devm_watchdog_register_device(&pdev->dev, &driver_data->wdt);
if (ret != 0) {
dev_err(wm831x->dev, "watchdog_register_device() failed: %d\n",
ret);
- goto err;
+ return ret;
}
- platform_set_drvdata(pdev, driver_data);
-
- return 0;
-
-err:
- return ret;
-}
-
-static int wm831x_wdt_remove(struct platform_device *pdev)
-{
- struct wm831x_wdt_drvdata *driver_data = platform_get_drvdata(pdev);
-
- watchdog_unregister_device(&driver_data->wdt);
-
return 0;
}
static struct platform_driver wm831x_wdt_driver = {
.probe = wm831x_wdt_probe,
- .remove = wm831x_wdt_remove,
.driver = {
.name = "wm831x-watchdog",
},
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/62] watchdog: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
[PATCH 22/62] watchdog: imx2_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
[PATCH 12/62] watchdog: da9055_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
[PATCH 04/62] watchdog: atlas7_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
[PATCH 15/62] watchdog: davinci_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
[PATCH 29/62] watchdog: max77620_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
[PATCH 08/62] watchdog: bcm_kona_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
[PATCH 30/62] watchdog: mena21_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
Re: [PATCH 30/62] watchdog: mena21_wdt: Convert to use device managed functions and other improvements Johannes Thumshirn <morbidrsa@gmail.com> - 2017-01-13 09:10 +0100
[PATCH 02/62] watchdog: aspeed_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
Re: [PATCH 02/62] watchdog: aspeed_wdt: Convert to use device managed functions Joel Stanley <joel@jms.id.au> - 2017-01-11 06:20 +0100
[PATCH 03/62] watchdog: at91sam9_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
[PATCH 25/62] watchdog: kempld_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
[PATCH 09/62] watchdog: cadence_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:40 +0100
[PATCH 05/62] watchdog: bcm2835_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:50 +0100
Re: [PATCH 05/62] watchdog: bcm2835_wdt: Convert to use device managed functions and other improvements Eric Anholt <eric@anholt.net> - 2017-01-14 07:30 +0100
[PATCH 21/62] watchdog: imgpdc_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:50 +0100
[PATCH 19/62] watchdog: gpio_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:50 +0100
[PATCH 10/62] watchdog: coh901327_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 00:50 +0100
Re: [PATCH 10/62] watchdog: coh901327_wdt: Convert to use device managed functions Linus Walleij <linus.walleij@linaro.org> - 2017-01-11 16:50 +0100
[PATCH 38/62] watchdog: nic7018_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 49/62] watchdog: sama5d4_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 40/62] watchdog: omap_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 39/62] watchdog: of_xilinx_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 36/62] watchdog: mt7621_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 42/62] watchdog: pic32-dmt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 35/62] watchdog: mpc8xxx_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 46/62] watchdog: renesas_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 32/62] watchdog: meson_gxbb_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
Re: [PATCH 32/62] watchdog: meson_gxbb_wdt: Convert to use device managed functions and other improvements Neil Armstrong <narmstrong@baylibre.com> - 2017-01-11 09:50 +0100
Re: [PATCH 32/62] watchdog: meson_gxbb_wdt: Convert to use device managed functions and other improvements Kevin Hilman <khilman@baylibre.com> - 2017-01-11 19:50 +0100
[PATCH 41/62] watchdog: orion_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 34/62] watchdog: moxart_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 47/62] watchdog: retu_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 37/62] watchdog: mtk_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 50/62] watchdog: sbsa_gwdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 43/62] watchdog: pic32-wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 44/62] watchdog: pnx4008_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
Re: [PATCH 44/62] watchdog: pnx4008_wdt: Convert to use device managed functions Vladimir Zapolskiy <vz@mleia.com> - 2017-01-12 01:20 +0100
[PATCH 45/62] watchdog: qcom-wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 31/62] watchdog: menf21bmc_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 48/62] watchdog: rt2880_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 51/62] watchdog: shwdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
[PATCH 33/62] watchdog: meson_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 01:50 +0100
Re: [PATCH 33/62] watchdog: meson_wdt: Convert to use device managed functions and other improvements Kevin Hilman <khilman@baylibre.com> - 2017-01-11 19:50 +0100
[PATCH 53/62] watchdog: st_lpc_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:10 +0100
[PATCH 52/62] watchdog: sirfsoc_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:10 +0100
[PATCH 55/62] watchdog: sunxi_wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:10 +0100
Re: [PATCH 55/62] watchdog: sunxi_wdt: Convert to use device managed functions and other improvements Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-01-11 13:20 +0100
[PATCH 57/62] watchdog: tegra_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:20 +0100
[PATCH 61/62] watchdog: ux500_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:20 +0100
[PATCH 60/62] watchdog: txx9wdt: Convert to use device managed functions and other improvements Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:20 +0100
[PATCH 59/62] watchdog: twl4030_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:20 +0100
[PATCH 62/62] watchdog: wm831x_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:20 +0100
Re: [PATCH 62/62] watchdog: wm831x_wdt: Convert to use device managed functions Charles Keepax <ckeepax@opensource.wolfsonmicro.com> - 2017-01-12 11:30 +0100
[PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:20 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Marc Gonzalez <marc_gonzalez@sigmadesigns.com> - 2017-01-11 10:10 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 12:00 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Marc Gonzalez <marc_gonzalez@sigmadesigns.com> - 2017-01-11 13:40 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 15:30 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Måns Rullgård <mans@mansr.com> - 2017-01-11 15:50 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Marc Gonzalez <marc_gonzalez@sigmadesigns.com> - 2017-01-11 16:30 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 19:00 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Marc Gonzalez <marc_gonzalez@sigmadesigns.com> - 2017-01-12 10:50 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2017-01-12 11:00 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Måns Rullgård <mans@mansr.com> - 2017-01-12 12:30 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Marc Gonzalez <marc_gonzalez@sigmadesigns.com> - 2017-01-12 13:20 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2017-01-11 15:40 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com> - 2017-01-11 16:00 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 18:30 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-13 06:20 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-01-12 01:20 +0100
Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-12 02:40 +0100
[PATCH 54/62] watchdog: stmp3xxx_rtc_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:20 +0100
[PATCH 58/62] watchdog: ts4800_wdt: Convert to use device managed functions Guenter Roeck <linux@roeck-us.net> - 2017-01-11 03:20 +0100
csiph-web