diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-13 09:20:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-13 09:20:42 -0400 |
commit | 55472bae5331f33582d9f0e8919fed8bebcda0da (patch) | |
tree | 4e9d910e8f5de08d1ceb45509ff42641fcd0a6e7 | |
parent | d7a02fa0a8f9ec1b81d57628ca9834563208ef33 (diff) | |
parent | a9f0bda567e32a2b44165b067adfc4a4f56d1815 (diff) |
Merge tag 'linux-watchdog-5.2-rc1' of git://www.linux-watchdog.org/linux-watchdog
Pull watchdog updates from Wim Van Sebroeck:
- a new watchdog driver for the ROHM BD70528 watchdog block
- a new watchdog driver for the i.MX system controller watchdog
- conversions to use device managed functions and other improvements
- refactor watchdog_init_timeout
- make watchdog core configurable as module
- pretimeout governors improvements
- a lot of other fixes
* tag 'linux-watchdog-5.2-rc1' of git://www.linux-watchdog.org/linux-watchdog: (114 commits)
watchdog: Enforce that at least one pretimeout governor is enabled
watchdog: stm32: add dynamic prescaler support
watchdog: Improve Kconfig entry ordering and dependencies
watchdog: npcm: Enable modular builds
watchdog: Make watchdog core configurable as module
watchdog: Move pretimeout governor configuration up
watchdog: Use depends instead of select for pretimeout governors
watchdog: rtd119x: drop unused module.h include
watchdog: intel_scu: make it explicitly non-modular
watchdog: coh901327: make it explicitly non-modular
watchdog: ziirave_wdt: drop warning after calling watchdog_init_timeout
watchdog: xen_wdt: drop warning after calling watchdog_init_timeout
watchdog: stm32_iwdg: drop warning after calling watchdog_init_timeout
watchdog: st_lpc_wdt: drop warning after calling watchdog_init_timeout
watchdog: sp5100_tco: drop warning after calling watchdog_init_timeout
watchdog: renesas_wdt: drop warning after calling watchdog_init_timeout
watchdog: nic7018_wdt: drop warning after calling watchdog_init_timeout
watchdog: ni903x_wdt: drop warning after calling watchdog_init_timeout
watchdog: imx_sc_wdt: drop warning after calling watchdog_init_timeout
watchdog: i6300esb: drop warning after calling watchdog_init_timeout
...
99 files changed, 1490 insertions, 1537 deletions
diff --git a/Documentation/devicetree/bindings/watchdog/fsl-imx-sc-wdt.txt b/Documentation/devicetree/bindings/watchdog/fsl-imx-sc-wdt.txt new file mode 100644 index 000000000000..02b87e92ae68 --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/fsl-imx-sc-wdt.txt | |||
@@ -0,0 +1,24 @@ | |||
1 | * Freescale i.MX System Controller Watchdog | ||
2 | |||
3 | i.MX system controller watchdog is for i.MX SoCs with system controller inside, | ||
4 | the watchdog is managed by system controller, users can ONLY communicate with | ||
5 | system controller from secure mode for watchdog operations, so Linux i.MX system | ||
6 | controller watchdog driver will call ARM SMC API and trap into ARM-Trusted-Firmware | ||
7 | for watchdog operations, ARM-Trusted-Firmware is running at secure EL3 mode and | ||
8 | it will request system controller to execute the watchdog operation passed from | ||
9 | Linux kernel. | ||
10 | |||
11 | Required properties: | ||
12 | - compatible: Should be : | ||
13 | "fsl,imx8qxp-sc-wdt" | ||
14 | followed by "fsl,imx-sc-wdt"; | ||
15 | |||
16 | Optional properties: | ||
17 | - timeout-sec : Contains the watchdog timeout in seconds. | ||
18 | |||
19 | Examples: | ||
20 | |||
21 | watchdog { | ||
22 | compatible = "fsl,imx8qxp-sc-wdt", "fsl,imx-sc-wdt"; | ||
23 | timeout-sec = <60>; | ||
24 | }; | ||
diff --git a/Documentation/devicetree/bindings/watchdog/mtk-wdt.txt b/Documentation/devicetree/bindings/watchdog/mtk-wdt.txt index 8682d6a93e5b..fd380eb28df5 100644 --- a/Documentation/devicetree/bindings/watchdog/mtk-wdt.txt +++ b/Documentation/devicetree/bindings/watchdog/mtk-wdt.txt | |||
@@ -9,6 +9,7 @@ Required properties: | |||
9 | "mediatek,mt7622-wdt", "mediatek,mt6589-wdt": for MT7622 | 9 | "mediatek,mt7622-wdt", "mediatek,mt6589-wdt": for MT7622 |
10 | "mediatek,mt7623-wdt", "mediatek,mt6589-wdt": for MT7623 | 10 | "mediatek,mt7623-wdt", "mediatek,mt6589-wdt": for MT7623 |
11 | "mediatek,mt7629-wdt", "mediatek,mt6589-wdt": for MT7629 | 11 | "mediatek,mt7629-wdt", "mediatek,mt6589-wdt": for MT7629 |
12 | "mediatek,mt8516-wdt", "mediatek,mt6589-wdt": for MT8516 | ||
12 | 13 | ||
13 | - reg : Specifies base physical address and size of the registers. | 14 | - reg : Specifies base physical address and size of the registers. |
14 | 15 | ||
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 242eea859637..7ea60371bda0 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -30,7 +30,7 @@ menuconfig WATCHDOG | |||
30 | if WATCHDOG | 30 | if WATCHDOG |
31 | 31 | ||
32 | config WATCHDOG_CORE | 32 | config WATCHDOG_CORE |
33 | bool "WatchDog Timer Driver Core" | 33 | tristate "WatchDog Timer Driver Core" |
34 | ---help--- | 34 | ---help--- |
35 | Say Y here if you want to use the new watchdog timer driver core. | 35 | Say Y here if you want to use the new watchdog timer driver core. |
36 | This driver provides a framework for all watchdog timer drivers | 36 | This driver provides a framework for all watchdog timer drivers |
@@ -63,6 +63,66 @@ config WATCHDOG_SYSFS | |||
63 | Say Y here if you want to enable watchdog device status read through | 63 | Say Y here if you want to enable watchdog device status read through |
64 | sysfs attributes. | 64 | sysfs attributes. |
65 | 65 | ||
66 | comment "Watchdog Pretimeout Governors" | ||
67 | |||
68 | config WATCHDOG_PRETIMEOUT_GOV | ||
69 | bool "Enable watchdog pretimeout governors" | ||
70 | depends on WATCHDOG_CORE | ||
71 | help | ||
72 | The option allows to select watchdog pretimeout governors. | ||
73 | |||
74 | config WATCHDOG_PRETIMEOUT_GOV_SEL | ||
75 | tristate | ||
76 | depends on WATCHDOG_PRETIMEOUT_GOV | ||
77 | default m | ||
78 | select WATCHDOG_PRETIMEOUT_GOV_PANIC if WATCHDOG_PRETIMEOUT_GOV_NOOP=n | ||
79 | |||
80 | if WATCHDOG_PRETIMEOUT_GOV | ||
81 | |||
82 | config WATCHDOG_PRETIMEOUT_GOV_NOOP | ||
83 | tristate "Noop watchdog pretimeout governor" | ||
84 | depends on WATCHDOG_CORE | ||
85 | default WATCHDOG_CORE | ||
86 | help | ||
87 | Noop watchdog pretimeout governor, only an informational | ||
88 | message is added to kernel log buffer. | ||
89 | |||
90 | config WATCHDOG_PRETIMEOUT_GOV_PANIC | ||
91 | tristate "Panic watchdog pretimeout governor" | ||
92 | depends on WATCHDOG_CORE | ||
93 | default WATCHDOG_CORE | ||
94 | help | ||
95 | Panic watchdog pretimeout governor, on watchdog pretimeout | ||
96 | event put the kernel into panic. | ||
97 | |||
98 | choice | ||
99 | prompt "Default Watchdog Pretimeout Governor" | ||
100 | default WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC | ||
101 | help | ||
102 | This option selects a default watchdog pretimeout governor. | ||
103 | The governor takes its action, if a watchdog is capable | ||
104 | to report a pretimeout event. | ||
105 | |||
106 | config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP | ||
107 | bool "noop" | ||
108 | depends on WATCHDOG_PRETIMEOUT_GOV_NOOP | ||
109 | help | ||
110 | Use noop watchdog pretimeout governor by default. If noop | ||
111 | governor is selected by a user, write a short message to | ||
112 | the kernel log buffer and don't do any system changes. | ||
113 | |||
114 | config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC | ||
115 | bool "panic" | ||
116 | depends on WATCHDOG_PRETIMEOUT_GOV_PANIC | ||
117 | help | ||
118 | Use panic watchdog pretimeout governor by default, if | ||
119 | a watchdog pretimeout event happens, consider that | ||
120 | a watchdog feeder is dead and reboot is unavoidable. | ||
121 | |||
122 | endchoice | ||
123 | |||
124 | endif # WATCHDOG_PRETIMEOUT_GOV | ||
125 | |||
66 | # | 126 | # |
67 | # General Watchdog drivers | 127 | # General Watchdog drivers |
68 | # | 128 | # |
@@ -90,6 +150,18 @@ config SOFT_WATCHDOG_PRETIMEOUT | |||
90 | watchdog. Be aware that governors might affect the watchdog because it | 150 | watchdog. Be aware that governors might affect the watchdog because it |
91 | is purely software, e.g. the panic governor will stall it! | 151 | is purely software, e.g. the panic governor will stall it! |
92 | 152 | ||
153 | config BD70528_WATCHDOG | ||
154 | tristate "ROHM BD70528 PMIC Watchdog" | ||
155 | depends on MFD_ROHM_BD70528 | ||
156 | select WATCHDOG_CORE | ||
157 | help | ||
158 | Support for the watchdog in the ROHM BD70528 PMIC. Watchdog trigger | ||
159 | cause system reset. | ||
160 | |||
161 | Say Y here to include support for the ROHM BD70528 watchdog. | ||
162 | Alternatively say M to compile the driver as a module, | ||
163 | which will be called bd70528_wdt. | ||
164 | |||
93 | config DA9052_WATCHDOG | 165 | config DA9052_WATCHDOG |
94 | tristate "Dialog DA9052 Watchdog" | 166 | tristate "Dialog DA9052 Watchdog" |
95 | depends on PMIC_DA9052 || COMPILE_TEST | 167 | depends on PMIC_DA9052 || COMPILE_TEST |
@@ -552,7 +624,7 @@ config COH901327_WATCHDOG | |||
552 | compiled as a module. | 624 | compiled as a module. |
553 | 625 | ||
554 | config NPCM7XX_WATCHDOG | 626 | config NPCM7XX_WATCHDOG |
555 | bool "Nuvoton NPCM750 watchdog" | 627 | tristate "Nuvoton NPCM750 watchdog" |
556 | depends on ARCH_NPCM || COMPILE_TEST | 628 | depends on ARCH_NPCM || COMPILE_TEST |
557 | default y if ARCH_NPCM7XX | 629 | default y if ARCH_NPCM7XX |
558 | select WATCHDOG_CORE | 630 | select WATCHDOG_CORE |
@@ -641,6 +713,22 @@ config IMX2_WDT | |||
641 | To compile this driver as a module, choose M here: the | 713 | To compile this driver as a module, choose M here: the |
642 | module will be called imx2_wdt. | 714 | module will be called imx2_wdt. |
643 | 715 | ||
716 | config IMX_SC_WDT | ||
717 | tristate "IMX SC Watchdog" | ||
718 | depends on HAVE_ARM_SMCCC | ||
719 | select WATCHDOG_CORE | ||
720 | help | ||
721 | This is the driver for the system controller watchdog | ||
722 | on the NXP i.MX SoCs with system controller inside, the | ||
723 | watchdog driver will call ARM SMC API and trap into | ||
724 | ARM-Trusted-Firmware for operations, ARM-Trusted-Firmware | ||
725 | will request system controller to execute the operations. | ||
726 | If you have one of these processors and wish to have | ||
727 | watchdog support enabled, say Y, otherwise say N. | ||
728 | |||
729 | To compile this driver as a module, choose M here: the | ||
730 | module will be called imx_sc_wdt. | ||
731 | |||
644 | config UX500_WATCHDOG | 732 | config UX500_WATCHDOG |
645 | tristate "ST-Ericsson Ux500 watchdog" | 733 | tristate "ST-Ericsson Ux500 watchdog" |
646 | depends on MFD_DB8500_PRCMU | 734 | depends on MFD_DB8500_PRCMU |
@@ -1179,6 +1267,15 @@ config HP_WATCHDOG | |||
1179 | To compile this driver as a module, choose M here: the module will be | 1267 | To compile this driver as a module, choose M here: the module will be |
1180 | called hpwdt. | 1268 | called hpwdt. |
1181 | 1269 | ||
1270 | config HPWDT_NMI_DECODING | ||
1271 | bool "NMI support for the HP ProLiant iLO2+ Hardware Watchdog Timer" | ||
1272 | depends on HP_WATCHDOG | ||
1273 | default y | ||
1274 | help | ||
1275 | Enables the NMI handler for the watchdog pretimeout NMI and the iLO | ||
1276 | "Generate NMI to System" virtual button. When an NMI is claimed | ||
1277 | by the driver, panic is called. | ||
1278 | |||
1182 | config KEMPLD_WDT | 1279 | config KEMPLD_WDT |
1183 | tristate "Kontron COM Watchdog Timer" | 1280 | tristate "Kontron COM Watchdog Timer" |
1184 | depends on MFD_KEMPLD | 1281 | depends on MFD_KEMPLD |
@@ -1190,15 +1287,6 @@ config KEMPLD_WDT | |||
1190 | This driver can also be built as a module. If so, the module will be | 1287 | This driver can also be built as a module. If so, the module will be |
1191 | called kempld_wdt. | 1288 | called kempld_wdt. |
1192 | 1289 | ||
1193 | config HPWDT_NMI_DECODING | ||
1194 | bool "NMI support for the HP ProLiant iLO2+ Hardware Watchdog Timer" | ||
1195 | depends on HP_WATCHDOG | ||
1196 | default y | ||
1197 | help | ||
1198 | Enables the NMI handler for the watchdog pretimeout NMI and the iLO | ||
1199 | "Generate NMI to System" virtual button. When an NMI is claimed | ||
1200 | by the driver, panic is called. | ||
1201 | |||
1202 | config SC1200_WDT | 1290 | config SC1200_WDT |
1203 | tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog" | 1291 | tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog" |
1204 | depends on X86 | 1292 | depends on X86 |
@@ -1647,7 +1735,7 @@ config BCM_KONA_WDT | |||
1647 | 1735 | ||
1648 | config BCM_KONA_WDT_DEBUG | 1736 | config BCM_KONA_WDT_DEBUG |
1649 | bool "DEBUGFS support for BCM Kona Watchdog" | 1737 | bool "DEBUGFS support for BCM Kona Watchdog" |
1650 | depends on BCM_KONA_WDT || COMPILE_TEST | 1738 | depends on BCM_KONA_WDT |
1651 | help | 1739 | help |
1652 | If enabled, adds /sys/kernel/debug/bcm_kona_wdt/info which provides | 1740 | If enabled, adds /sys/kernel/debug/bcm_kona_wdt/info which provides |
1653 | access to the driver's internal data structures as well as watchdog | 1741 | access to the driver's internal data structures as well as watchdog |
@@ -2024,53 +2112,4 @@ config USBPCWATCHDOG | |||
2024 | 2112 | ||
2025 | Most people will say N. | 2113 | Most people will say N. |
2026 | 2114 | ||
2027 | comment "Watchdog Pretimeout Governors" | ||
2028 | |||
2029 | config WATCHDOG_PRETIMEOUT_GOV | ||
2030 | bool "Enable watchdog pretimeout governors" | ||
2031 | help | ||
2032 | The option allows to select watchdog pretimeout governors. | ||
2033 | |||
2034 | if WATCHDOG_PRETIMEOUT_GOV | ||
2035 | |||
2036 | choice | ||
2037 | prompt "Default Watchdog Pretimeout Governor" | ||
2038 | default WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC | ||
2039 | help | ||
2040 | This option selects a default watchdog pretimeout governor. | ||
2041 | The governor takes its action, if a watchdog is capable | ||
2042 | to report a pretimeout event. | ||
2043 | |||
2044 | config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP | ||
2045 | bool "noop" | ||
2046 | select WATCHDOG_PRETIMEOUT_GOV_NOOP | ||
2047 | help | ||
2048 | Use noop watchdog pretimeout governor by default. If noop | ||
2049 | governor is selected by a user, write a short message to | ||
2050 | the kernel log buffer and don't do any system changes. | ||
2051 | |||
2052 | config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC | ||
2053 | bool "panic" | ||
2054 | select WATCHDOG_PRETIMEOUT_GOV_PANIC | ||
2055 | help | ||
2056 | Use panic watchdog pretimeout governor by default, if | ||
2057 | a watchdog pretimeout event happens, consider that | ||
2058 | a watchdog feeder is dead and reboot is unavoidable. | ||
2059 | |||
2060 | endchoice | ||
2061 | |||
2062 | config WATCHDOG_PRETIMEOUT_GOV_NOOP | ||
2063 | tristate "Noop watchdog pretimeout governor" | ||
2064 | help | ||
2065 | Noop watchdog pretimeout governor, only an informational | ||
2066 | message is added to kernel log buffer. | ||
2067 | |||
2068 | config WATCHDOG_PRETIMEOUT_GOV_PANIC | ||
2069 | tristate "Panic watchdog pretimeout governor" | ||
2070 | help | ||
2071 | Panic watchdog pretimeout governor, on watchdog pretimeout | ||
2072 | event put the kernel into panic. | ||
2073 | |||
2074 | endif # WATCHDOG_PRETIMEOUT_GOV | ||
2075 | |||
2076 | endif # WATCHDOG | 2115 | endif # WATCHDOG |
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index ba930e464657..7caa920e7e60 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile | |||
@@ -68,6 +68,7 @@ obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o | |||
68 | obj-$(CONFIG_TS4800_WATCHDOG) += ts4800_wdt.o | 68 | obj-$(CONFIG_TS4800_WATCHDOG) += ts4800_wdt.o |
69 | obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o | 69 | obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o |
70 | obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o | 70 | obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o |
71 | obj-$(CONFIG_IMX_SC_WDT) += imx_sc_wdt.o | ||
71 | obj-$(CONFIG_UX500_WATCHDOG) += ux500_wdt.o | 72 | obj-$(CONFIG_UX500_WATCHDOG) += ux500_wdt.o |
72 | obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o | 73 | obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o |
73 | obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o | 74 | obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o |
@@ -205,6 +206,7 @@ obj-$(CONFIG_WATCHDOG_SUN4V) += sun4v_wdt.o | |||
205 | obj-$(CONFIG_XEN_WDT) += xen_wdt.o | 206 | obj-$(CONFIG_XEN_WDT) += xen_wdt.o |
206 | 207 | ||
207 | # Architecture Independent | 208 | # Architecture Independent |
209 | obj-$(CONFIG_BD70528_WATCHDOG) += bd70528_wdt.o | ||
208 | obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o | 210 | obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o |
209 | obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o | 211 | obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o |
210 | obj-$(CONFIG_DA9062_WATCHDOG) += da9062_wdt.o | 212 | obj-$(CONFIG_DA9062_WATCHDOG) += da9062_wdt.o |
diff --git a/drivers/watchdog/alim7101_wdt.c b/drivers/watchdog/alim7101_wdt.c index 7e9884960eb9..689b8a0593c1 100644 --- a/drivers/watchdog/alim7101_wdt.c +++ b/drivers/watchdog/alim7101_wdt.c | |||
@@ -277,8 +277,8 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
277 | return -EINVAL; | 277 | return -EINVAL; |
278 | timeout = new_timeout; | 278 | timeout = new_timeout; |
279 | wdt_keepalive(); | 279 | wdt_keepalive(); |
280 | /* Fall through */ | ||
281 | } | 280 | } |
281 | /* Fall through */ | ||
282 | case WDIOC_GETTIMEOUT: | 282 | case WDIOC_GETTIMEOUT: |
283 | return put_user(timeout, p); | 283 | return put_user(timeout, p); |
284 | default: | 284 | default: |
diff --git a/drivers/watchdog/armada_37xx_wdt.c b/drivers/watchdog/armada_37xx_wdt.c index 4b4054f54df9..e5dcb26d85f0 100644 --- a/drivers/watchdog/armada_37xx_wdt.c +++ b/drivers/watchdog/armada_37xx_wdt.c | |||
@@ -244,6 +244,11 @@ static const struct watchdog_ops armada_37xx_wdt_ops = { | |||
244 | .get_timeleft = armada_37xx_wdt_get_timeleft, | 244 | .get_timeleft = armada_37xx_wdt_get_timeleft, |
245 | }; | 245 | }; |
246 | 246 | ||
247 | static void armada_clk_disable_unprepare(void *data) | ||
248 | { | ||
249 | clk_disable_unprepare(data); | ||
250 | } | ||
251 | |||
247 | static int armada_37xx_wdt_probe(struct platform_device *pdev) | 252 | static int armada_37xx_wdt_probe(struct platform_device *pdev) |
248 | { | 253 | { |
249 | struct armada_37xx_watchdog *dev; | 254 | struct armada_37xx_watchdog *dev; |
@@ -278,12 +283,14 @@ static int armada_37xx_wdt_probe(struct platform_device *pdev) | |||
278 | ret = clk_prepare_enable(dev->clk); | 283 | ret = clk_prepare_enable(dev->clk); |
279 | if (ret) | 284 | if (ret) |
280 | return ret; | 285 | return ret; |
286 | ret = devm_add_action_or_reset(&pdev->dev, | ||
287 | armada_clk_disable_unprepare, dev->clk); | ||
288 | if (ret) | ||
289 | return ret; | ||
281 | 290 | ||
282 | dev->clk_rate = clk_get_rate(dev->clk); | 291 | dev->clk_rate = clk_get_rate(dev->clk); |
283 | if (!dev->clk_rate) { | 292 | if (!dev->clk_rate) |
284 | ret = -EINVAL; | 293 | return -EINVAL; |
285 | goto disable_clk; | ||
286 | } | ||
287 | 294 | ||
288 | /* | 295 | /* |
289 | * Since the timeout in seconds is given as 32 bit unsigned int, and | 296 | * Since the timeout in seconds is given as 32 bit unsigned int, and |
@@ -307,35 +314,15 @@ static int armada_37xx_wdt_probe(struct platform_device *pdev) | |||
307 | set_bit(WDOG_HW_RUNNING, &dev->wdt.status); | 314 | set_bit(WDOG_HW_RUNNING, &dev->wdt.status); |
308 | 315 | ||
309 | watchdog_set_nowayout(&dev->wdt, nowayout); | 316 | watchdog_set_nowayout(&dev->wdt, nowayout); |
310 | ret = watchdog_register_device(&dev->wdt); | 317 | watchdog_stop_on_reboot(&dev->wdt); |
318 | ret = devm_watchdog_register_device(&pdev->dev, &dev->wdt); | ||
311 | if (ret) | 319 | if (ret) |
312 | goto disable_clk; | 320 | return ret; |
313 | 321 | ||
314 | dev_info(&pdev->dev, "Initial timeout %d sec%s\n", | 322 | dev_info(&pdev->dev, "Initial timeout %d sec%s\n", |
315 | dev->wdt.timeout, nowayout ? ", nowayout" : ""); | 323 | dev->wdt.timeout, nowayout ? ", nowayout" : ""); |
316 | 324 | ||
317 | return 0; | 325 | return 0; |
318 | |||
319 | disable_clk: | ||
320 | clk_disable_unprepare(dev->clk); | ||
321 | return ret; | ||
322 | } | ||
323 | |||
324 | static int armada_37xx_wdt_remove(struct platform_device *pdev) | ||
325 | { | ||
326 | struct watchdog_device *wdt = platform_get_drvdata(pdev); | ||
327 | struct armada_37xx_watchdog *dev = watchdog_get_drvdata(wdt); | ||
328 | |||
329 | watchdog_unregister_device(wdt); | ||
330 | clk_disable_unprepare(dev->clk); | ||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | static void armada_37xx_wdt_shutdown(struct platform_device *pdev) | ||
335 | { | ||
336 | struct watchdog_device *wdt = platform_get_drvdata(pdev); | ||
337 | |||
338 | armada_37xx_wdt_stop(wdt); | ||
339 | } | 326 | } |
340 | 327 | ||
341 | static int __maybe_unused armada_37xx_wdt_suspend(struct device *dev) | 328 | static int __maybe_unused armada_37xx_wdt_suspend(struct device *dev) |
@@ -370,8 +357,6 @@ MODULE_DEVICE_TABLE(of, armada_37xx_wdt_match); | |||
370 | 357 | ||
371 | static struct platform_driver armada_37xx_wdt_driver = { | 358 | static struct platform_driver armada_37xx_wdt_driver = { |
372 | .probe = armada_37xx_wdt_probe, | 359 | .probe = armada_37xx_wdt_probe, |
373 | .remove = armada_37xx_wdt_remove, | ||
374 | .shutdown = armada_37xx_wdt_shutdown, | ||
375 | .driver = { | 360 | .driver = { |
376 | .name = "armada_37xx_wdt", | 361 | .name = "armada_37xx_wdt", |
377 | .of_match_table = of_match_ptr(armada_37xx_wdt_match), | 362 | .of_match_table = of_match_ptr(armada_37xx_wdt_match), |
diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c index 9768e44ffeb8..c5b9aae544dd 100644 --- a/drivers/watchdog/asm9260_wdt.c +++ b/drivers/watchdog/asm9260_wdt.c | |||
@@ -196,6 +196,11 @@ static const struct watchdog_ops asm9260_wdt_ops = { | |||
196 | .restart = asm9260_restart, | 196 | .restart = asm9260_restart, |
197 | }; | 197 | }; |
198 | 198 | ||
199 | static void asm9260_clk_disable_unprepare(void *data) | ||
200 | { | ||
201 | clk_disable_unprepare(data); | ||
202 | } | ||
203 | |||
199 | static int asm9260_wdt_get_dt_clks(struct asm9260_wdt_priv *priv) | 204 | static int asm9260_wdt_get_dt_clks(struct asm9260_wdt_priv *priv) |
200 | { | 205 | { |
201 | int err; | 206 | int err; |
@@ -219,26 +224,32 @@ static int asm9260_wdt_get_dt_clks(struct asm9260_wdt_priv *priv) | |||
219 | dev_err(priv->dev, "Failed to enable ahb_clk!\n"); | 224 | dev_err(priv->dev, "Failed to enable ahb_clk!\n"); |
220 | return err; | 225 | return err; |
221 | } | 226 | } |
227 | err = devm_add_action_or_reset(priv->dev, | ||
228 | asm9260_clk_disable_unprepare, | ||
229 | priv->clk_ahb); | ||
230 | if (err) | ||
231 | return err; | ||
222 | 232 | ||
223 | err = clk_set_rate(priv->clk, CLOCK_FREQ); | 233 | err = clk_set_rate(priv->clk, CLOCK_FREQ); |
224 | if (err) { | 234 | if (err) { |
225 | clk_disable_unprepare(priv->clk_ahb); | ||
226 | dev_err(priv->dev, "Failed to set rate!\n"); | 235 | dev_err(priv->dev, "Failed to set rate!\n"); |
227 | return err; | 236 | return err; |
228 | } | 237 | } |
229 | 238 | ||
230 | err = clk_prepare_enable(priv->clk); | 239 | err = clk_prepare_enable(priv->clk); |
231 | if (err) { | 240 | if (err) { |
232 | clk_disable_unprepare(priv->clk_ahb); | ||
233 | dev_err(priv->dev, "Failed to enable clk!\n"); | 241 | dev_err(priv->dev, "Failed to enable clk!\n"); |
234 | return err; | 242 | return err; |
235 | } | 243 | } |
244 | err = devm_add_action_or_reset(priv->dev, | ||
245 | asm9260_clk_disable_unprepare, | ||
246 | priv->clk); | ||
247 | if (err) | ||
248 | return err; | ||
236 | 249 | ||
237 | /* wdt has internal divider */ | 250 | /* wdt has internal divider */ |
238 | clk = clk_get_rate(priv->clk); | 251 | clk = clk_get_rate(priv->clk); |
239 | if (!clk) { | 252 | if (!clk) { |
240 | clk_disable_unprepare(priv->clk); | ||
241 | clk_disable_unprepare(priv->clk_ahb); | ||
242 | dev_err(priv->dev, "Failed, clk is 0!\n"); | 253 | dev_err(priv->dev, "Failed, clk is 0!\n"); |
243 | return -EINVAL; | 254 | return -EINVAL; |
244 | } | 255 | } |
@@ -274,25 +285,23 @@ static void asm9260_wdt_get_dt_mode(struct asm9260_wdt_priv *priv) | |||
274 | 285 | ||
275 | static int asm9260_wdt_probe(struct platform_device *pdev) | 286 | static int asm9260_wdt_probe(struct platform_device *pdev) |
276 | { | 287 | { |
288 | struct device *dev = &pdev->dev; | ||
277 | struct asm9260_wdt_priv *priv; | 289 | struct asm9260_wdt_priv *priv; |
278 | struct watchdog_device *wdd; | 290 | struct watchdog_device *wdd; |
279 | struct resource *res; | ||
280 | int ret; | 291 | int ret; |
281 | static const char * const mode_name[] = { "hw", "sw", "debug", }; | 292 | static const char * const mode_name[] = { "hw", "sw", "debug", }; |
282 | 293 | ||
283 | priv = devm_kzalloc(&pdev->dev, sizeof(struct asm9260_wdt_priv), | 294 | priv = devm_kzalloc(dev, sizeof(struct asm9260_wdt_priv), GFP_KERNEL); |
284 | GFP_KERNEL); | ||
285 | if (!priv) | 295 | if (!priv) |
286 | return -ENOMEM; | 296 | return -ENOMEM; |
287 | 297 | ||
288 | priv->dev = &pdev->dev; | 298 | priv->dev = dev; |
289 | 299 | ||
290 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 300 | priv->iobase = devm_platform_ioremap_resource(pdev, 0); |
291 | priv->iobase = devm_ioremap_resource(&pdev->dev, res); | ||
292 | if (IS_ERR(priv->iobase)) | 301 | if (IS_ERR(priv->iobase)) |
293 | return PTR_ERR(priv->iobase); | 302 | return PTR_ERR(priv->iobase); |
294 | 303 | ||
295 | priv->rst = devm_reset_control_get_exclusive(&pdev->dev, "wdt_rst"); | 304 | priv->rst = devm_reset_control_get_exclusive(dev, "wdt_rst"); |
296 | if (IS_ERR(priv->rst)) | 305 | if (IS_ERR(priv->rst)) |
297 | return PTR_ERR(priv->rst); | 306 | return PTR_ERR(priv->rst); |
298 | 307 | ||
@@ -305,7 +314,7 @@ static int asm9260_wdt_probe(struct platform_device *pdev) | |||
305 | wdd->ops = &asm9260_wdt_ops; | 314 | wdd->ops = &asm9260_wdt_ops; |
306 | wdd->min_timeout = 1; | 315 | wdd->min_timeout = 1; |
307 | wdd->max_timeout = BM_WDTC_MAX(priv->wdt_freq); | 316 | wdd->max_timeout = BM_WDTC_MAX(priv->wdt_freq); |
308 | wdd->parent = &pdev->dev; | 317 | wdd->parent = dev; |
309 | 318 | ||
310 | watchdog_set_drvdata(wdd, priv); | 319 | watchdog_set_drvdata(wdd, priv); |
311 | 320 | ||
@@ -315,7 +324,7 @@ static int asm9260_wdt_probe(struct platform_device *pdev) | |||
315 | * the max instead. | 324 | * the max instead. |
316 | */ | 325 | */ |
317 | wdd->timeout = ASM9260_WDT_DEFAULT_TIMEOUT; | 326 | wdd->timeout = ASM9260_WDT_DEFAULT_TIMEOUT; |
318 | watchdog_init_timeout(wdd, 0, &pdev->dev); | 327 | watchdog_init_timeout(wdd, 0, dev); |
319 | 328 | ||
320 | asm9260_wdt_get_dt_mode(priv); | 329 | asm9260_wdt_get_dt_mode(priv); |
321 | 330 | ||
@@ -327,49 +336,25 @@ static int asm9260_wdt_probe(struct platform_device *pdev) | |||
327 | * Not all supported platforms specify an interrupt for the | 336 | * Not all supported platforms specify an interrupt for the |
328 | * watchdog, so let's make it optional. | 337 | * watchdog, so let's make it optional. |
329 | */ | 338 | */ |
330 | ret = devm_request_irq(&pdev->dev, priv->irq, | 339 | ret = devm_request_irq(dev, priv->irq, asm9260_wdt_irq, 0, |
331 | asm9260_wdt_irq, 0, pdev->name, priv); | 340 | pdev->name, priv); |
332 | if (ret < 0) | 341 | if (ret < 0) |
333 | dev_warn(&pdev->dev, "failed to request IRQ\n"); | 342 | dev_warn(dev, "failed to request IRQ\n"); |
334 | } | 343 | } |
335 | 344 | ||
336 | watchdog_set_restart_priority(wdd, 128); | 345 | watchdog_set_restart_priority(wdd, 128); |
337 | 346 | ||
338 | ret = watchdog_register_device(wdd); | 347 | watchdog_stop_on_reboot(wdd); |
348 | watchdog_stop_on_unregister(wdd); | ||
349 | ret = devm_watchdog_register_device(dev, wdd); | ||
339 | if (ret) | 350 | if (ret) |
340 | goto clk_off; | 351 | return ret; |
341 | 352 | ||
342 | platform_set_drvdata(pdev, priv); | 353 | platform_set_drvdata(pdev, priv); |
343 | 354 | ||
344 | dev_info(&pdev->dev, "Watchdog enabled (timeout: %d sec, mode: %s)\n", | 355 | dev_info(dev, "Watchdog enabled (timeout: %d sec, mode: %s)\n", |
345 | wdd->timeout, mode_name[priv->mode]); | 356 | wdd->timeout, mode_name[priv->mode]); |
346 | return 0; | 357 | return 0; |
347 | |||
348 | clk_off: | ||
349 | clk_disable_unprepare(priv->clk); | ||
350 | clk_disable_unprepare(priv->clk_ahb); | ||
351 | return ret; | ||
352 | } | ||
353 | |||
354 | static void asm9260_wdt_shutdown(struct platform_device *pdev) | ||
355 | { | ||
356 | struct asm9260_wdt_priv *priv = platform_get_drvdata(pdev); | ||
357 | |||
358 | asm9260_wdt_disable(&priv->wdd); | ||
359 | } | ||
360 | |||
361 | static int asm9260_wdt_remove(struct platform_device *pdev) | ||
362 | { | ||
363 | struct asm9260_wdt_priv *priv = platform_get_drvdata(pdev); | ||
364 | |||
365 | asm9260_wdt_disable(&priv->wdd); | ||
366 | |||
367 | watchdog_unregister_device(&priv->wdd); | ||
368 | |||
369 | clk_disable_unprepare(priv->clk); | ||
370 | clk_disable_unprepare(priv->clk_ahb); | ||
371 | |||
372 | return 0; | ||
373 | } | 358 | } |
374 | 359 | ||
375 | static const struct of_device_id asm9260_wdt_of_match[] = { | 360 | static const struct of_device_id asm9260_wdt_of_match[] = { |
@@ -384,8 +369,6 @@ static struct platform_driver asm9260_wdt_driver = { | |||
384 | .of_match_table = asm9260_wdt_of_match, | 369 | .of_match_table = asm9260_wdt_of_match, |
385 | }, | 370 | }, |
386 | .probe = asm9260_wdt_probe, | 371 | .probe = asm9260_wdt_probe, |
387 | .remove = asm9260_wdt_remove, | ||
388 | .shutdown = asm9260_wdt_shutdown, | ||
389 | }; | 372 | }; |
390 | module_platform_driver(asm9260_wdt_driver); | 373 | module_platform_driver(asm9260_wdt_driver); |
391 | 374 | ||
diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c index 1abe4d021fd2..34117745c65f 100644 --- a/drivers/watchdog/aspeed_wdt.c +++ b/drivers/watchdog/aspeed_wdt.c | |||
@@ -187,22 +187,21 @@ static const struct watchdog_info aspeed_wdt_info = { | |||
187 | 187 | ||
188 | static int aspeed_wdt_probe(struct platform_device *pdev) | 188 | static int aspeed_wdt_probe(struct platform_device *pdev) |
189 | { | 189 | { |
190 | struct device *dev = &pdev->dev; | ||
190 | const struct aspeed_wdt_config *config; | 191 | const struct aspeed_wdt_config *config; |
191 | const struct of_device_id *ofdid; | 192 | const struct of_device_id *ofdid; |
192 | struct aspeed_wdt *wdt; | 193 | struct aspeed_wdt *wdt; |
193 | struct resource *res; | ||
194 | struct device_node *np; | 194 | struct device_node *np; |
195 | const char *reset_type; | 195 | const char *reset_type; |
196 | u32 duration; | 196 | u32 duration; |
197 | u32 status; | 197 | u32 status; |
198 | int ret; | 198 | int ret; |
199 | 199 | ||
200 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 200 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
201 | if (!wdt) | 201 | if (!wdt) |
202 | return -ENOMEM; | 202 | return -ENOMEM; |
203 | 203 | ||
204 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 204 | wdt->base = devm_platform_ioremap_resource(pdev, 0); |
205 | wdt->base = devm_ioremap_resource(&pdev->dev, res); | ||
206 | if (IS_ERR(wdt->base)) | 205 | if (IS_ERR(wdt->base)) |
207 | return PTR_ERR(wdt->base); | 206 | return PTR_ERR(wdt->base); |
208 | 207 | ||
@@ -214,12 +213,12 @@ static int aspeed_wdt_probe(struct platform_device *pdev) | |||
214 | wdt->wdd.info = &aspeed_wdt_info; | 213 | wdt->wdd.info = &aspeed_wdt_info; |
215 | wdt->wdd.ops = &aspeed_wdt_ops; | 214 | wdt->wdd.ops = &aspeed_wdt_ops; |
216 | wdt->wdd.max_hw_heartbeat_ms = WDT_MAX_TIMEOUT_MS; | 215 | wdt->wdd.max_hw_heartbeat_ms = WDT_MAX_TIMEOUT_MS; |
217 | wdt->wdd.parent = &pdev->dev; | 216 | wdt->wdd.parent = dev; |
218 | 217 | ||
219 | wdt->wdd.timeout = WDT_DEFAULT_TIMEOUT; | 218 | wdt->wdd.timeout = WDT_DEFAULT_TIMEOUT; |
220 | watchdog_init_timeout(&wdt->wdd, 0, &pdev->dev); | 219 | watchdog_init_timeout(&wdt->wdd, 0, dev); |
221 | 220 | ||
222 | np = pdev->dev.of_node; | 221 | np = dev->of_node; |
223 | 222 | ||
224 | ofdid = of_match_node(aspeed_wdt_of_table, np); | 223 | ofdid = of_match_node(aspeed_wdt_of_table, np); |
225 | if (!ofdid) | 224 | if (!ofdid) |
@@ -288,11 +287,11 @@ static int aspeed_wdt_probe(struct platform_device *pdev) | |||
288 | u32 max_duration = config->ext_pulse_width_mask + 1; | 287 | u32 max_duration = config->ext_pulse_width_mask + 1; |
289 | 288 | ||
290 | if (duration == 0 || duration > max_duration) { | 289 | if (duration == 0 || duration > max_duration) { |
291 | dev_err(&pdev->dev, "Invalid pulse duration: %uus\n", | 290 | dev_err(dev, "Invalid pulse duration: %uus\n", |
292 | duration); | 291 | duration); |
293 | duration = max(1U, min(max_duration, duration)); | 292 | duration = max(1U, min(max_duration, duration)); |
294 | dev_info(&pdev->dev, "Pulse duration set to %uus\n", | 293 | dev_info(dev, "Pulse duration set to %uus\n", |
295 | duration); | 294 | duration); |
296 | } | 295 | } |
297 | 296 | ||
298 | /* | 297 | /* |
@@ -314,9 +313,9 @@ static int aspeed_wdt_probe(struct platform_device *pdev) | |||
314 | if (status & WDT_TIMEOUT_STATUS_BOOT_SECONDARY) | 313 | if (status & WDT_TIMEOUT_STATUS_BOOT_SECONDARY) |
315 | wdt->wdd.bootstatus = WDIOF_CARDRESET; | 314 | wdt->wdd.bootstatus = WDIOF_CARDRESET; |
316 | 315 | ||
317 | ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdd); | 316 | ret = devm_watchdog_register_device(dev, &wdt->wdd); |
318 | if (ret) { | 317 | if (ret) { |
319 | dev_err(&pdev->dev, "failed to register\n"); | 318 | dev_err(dev, "failed to register\n"); |
320 | return ret; | 319 | return ret; |
321 | } | 320 | } |
322 | 321 | ||
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index f4050a229eb5..292b5a1ca831 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c | |||
@@ -327,7 +327,6 @@ static inline int of_at91wdt_init(struct device_node *np, struct at91wdt *wdt) | |||
327 | 327 | ||
328 | static int __init at91wdt_probe(struct platform_device *pdev) | 328 | static int __init at91wdt_probe(struct platform_device *pdev) |
329 | { | 329 | { |
330 | struct resource *r; | ||
331 | int err; | 330 | int err; |
332 | struct at91wdt *wdt; | 331 | struct at91wdt *wdt; |
333 | 332 | ||
@@ -346,8 +345,7 @@ static int __init at91wdt_probe(struct platform_device *pdev) | |||
346 | wdt->wdd.min_timeout = 1; | 345 | wdt->wdd.min_timeout = 1; |
347 | wdt->wdd.max_timeout = 0xFFFF; | 346 | wdt->wdd.max_timeout = 0xFFFF; |
348 | 347 | ||
349 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 348 | wdt->base = devm_platform_ioremap_resource(pdev, 0); |
350 | wdt->base = devm_ioremap_resource(&pdev->dev, r); | ||
351 | if (IS_ERR(wdt->base)) | 349 | if (IS_ERR(wdt->base)) |
352 | return PTR_ERR(wdt->base); | 350 | return PTR_ERR(wdt->base); |
353 | 351 | ||
diff --git a/drivers/watchdog/ath79_wdt.c b/drivers/watchdog/ath79_wdt.c index 4f56b63f9691..02234c254b10 100644 --- a/drivers/watchdog/ath79_wdt.c +++ b/drivers/watchdog/ath79_wdt.c | |||
@@ -250,15 +250,13 @@ static struct miscdevice ath79_wdt_miscdev = { | |||
250 | 250 | ||
251 | static int ath79_wdt_probe(struct platform_device *pdev) | 251 | static int ath79_wdt_probe(struct platform_device *pdev) |
252 | { | 252 | { |
253 | struct resource *res; | ||
254 | u32 ctrl; | 253 | u32 ctrl; |
255 | int err; | 254 | int err; |
256 | 255 | ||
257 | if (wdt_base) | 256 | if (wdt_base) |
258 | return -EBUSY; | 257 | return -EBUSY; |
259 | 258 | ||
260 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 259 | wdt_base = devm_platform_ioremap_resource(pdev, 0); |
261 | wdt_base = devm_ioremap_resource(&pdev->dev, res); | ||
262 | if (IS_ERR(wdt_base)) | 260 | if (IS_ERR(wdt_base)) |
263 | return PTR_ERR(wdt_base); | 261 | return PTR_ERR(wdt_base); |
264 | 262 | ||
diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c index 4abdcabd8219..79337d2a8a8e 100644 --- a/drivers/watchdog/atlas7_wdt.c +++ b/drivers/watchdog/atlas7_wdt.c | |||
@@ -125,80 +125,57 @@ static const struct of_device_id atlas7_wdt_ids[] = { | |||
125 | {} | 125 | {} |
126 | }; | 126 | }; |
127 | 127 | ||
128 | static void atlas7_clk_disable_unprepare(void *data) | ||
129 | { | ||
130 | clk_disable_unprepare(data); | ||
131 | } | ||
132 | |||
128 | static int atlas7_wdt_probe(struct platform_device *pdev) | 133 | static int atlas7_wdt_probe(struct platform_device *pdev) |
129 | { | 134 | { |
130 | struct device_node *np = pdev->dev.of_node; | 135 | struct device *dev = &pdev->dev; |
131 | struct atlas7_wdog *wdt; | 136 | struct atlas7_wdog *wdt; |
132 | struct resource *res; | ||
133 | struct clk *clk; | 137 | struct clk *clk; |
134 | int ret; | 138 | int ret; |
135 | 139 | ||
136 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 140 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
137 | if (!wdt) | 141 | if (!wdt) |
138 | return -ENOMEM; | 142 | return -ENOMEM; |
139 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 143 | wdt->base = devm_platform_ioremap_resource(pdev, 0); |
140 | wdt->base = devm_ioremap_resource(&pdev->dev, res); | ||
141 | if (IS_ERR(wdt->base)) | 144 | if (IS_ERR(wdt->base)) |
142 | return PTR_ERR(wdt->base); | 145 | return PTR_ERR(wdt->base); |
143 | 146 | ||
144 | clk = of_clk_get(np, 0); | 147 | clk = devm_clk_get(dev, NULL); |
145 | if (IS_ERR(clk)) | 148 | if (IS_ERR(clk)) |
146 | return PTR_ERR(clk); | 149 | return PTR_ERR(clk); |
147 | ret = clk_prepare_enable(clk); | 150 | ret = clk_prepare_enable(clk); |
148 | if (ret) { | 151 | if (ret) { |
149 | dev_err(&pdev->dev, "clk enable failed\n"); | 152 | dev_err(dev, "clk enable failed\n"); |
150 | goto err; | 153 | return ret; |
151 | } | 154 | } |
155 | ret = devm_add_action_or_reset(dev, atlas7_clk_disable_unprepare, clk); | ||
156 | if (ret) | ||
157 | return ret; | ||
152 | 158 | ||
153 | /* disable watchdog hardware */ | 159 | /* disable watchdog hardware */ |
154 | writel(0, wdt->base + ATLAS7_WDT_CNT_CTRL); | 160 | writel(0, wdt->base + ATLAS7_WDT_CNT_CTRL); |
155 | 161 | ||
156 | wdt->tick_rate = clk_get_rate(clk); | 162 | wdt->tick_rate = clk_get_rate(clk); |
157 | if (!wdt->tick_rate) { | 163 | if (!wdt->tick_rate) |
158 | ret = -EINVAL; | 164 | return -EINVAL; |
159 | goto err1; | ||
160 | } | ||
161 | 165 | ||
162 | wdt->clk = clk; | 166 | wdt->clk = clk; |
163 | atlas7_wdd.min_timeout = 1; | 167 | atlas7_wdd.min_timeout = 1; |
164 | atlas7_wdd.max_timeout = UINT_MAX / wdt->tick_rate; | 168 | atlas7_wdd.max_timeout = UINT_MAX / wdt->tick_rate; |
165 | 169 | ||
166 | watchdog_init_timeout(&atlas7_wdd, 0, &pdev->dev); | 170 | watchdog_init_timeout(&atlas7_wdd, 0, dev); |
167 | watchdog_set_nowayout(&atlas7_wdd, nowayout); | 171 | watchdog_set_nowayout(&atlas7_wdd, nowayout); |
168 | 172 | ||
169 | watchdog_set_drvdata(&atlas7_wdd, wdt); | 173 | watchdog_set_drvdata(&atlas7_wdd, wdt); |
170 | platform_set_drvdata(pdev, &atlas7_wdd); | 174 | platform_set_drvdata(pdev, &atlas7_wdd); |
171 | 175 | ||
172 | ret = watchdog_register_device(&atlas7_wdd); | 176 | watchdog_stop_on_reboot(&atlas7_wdd); |
173 | if (ret) | 177 | watchdog_stop_on_unregister(&atlas7_wdd); |
174 | goto err1; | 178 | return devm_watchdog_register_device(dev, &atlas7_wdd); |
175 | |||
176 | return 0; | ||
177 | |||
178 | err1: | ||
179 | clk_disable_unprepare(clk); | ||
180 | err: | ||
181 | clk_put(clk); | ||
182 | return ret; | ||
183 | } | ||
184 | |||
185 | static void atlas7_wdt_shutdown(struct platform_device *pdev) | ||
186 | { | ||
187 | struct watchdog_device *wdd = platform_get_drvdata(pdev); | ||
188 | struct atlas7_wdog *wdt = watchdog_get_drvdata(wdd); | ||
189 | |||
190 | atlas7_wdt_disable(wdd); | ||
191 | clk_disable_unprepare(wdt->clk); | ||
192 | } | ||
193 | |||
194 | static int atlas7_wdt_remove(struct platform_device *pdev) | ||
195 | { | ||
196 | struct watchdog_device *wdd = platform_get_drvdata(pdev); | ||
197 | struct atlas7_wdog *wdt = watchdog_get_drvdata(wdd); | ||
198 | |||
199 | atlas7_wdt_shutdown(pdev); | ||
200 | clk_put(wdt->clk); | ||
201 | return 0; | ||
202 | } | 179 | } |
203 | 180 | ||
204 | static int __maybe_unused atlas7_wdt_suspend(struct device *dev) | 181 | static int __maybe_unused atlas7_wdt_suspend(struct device *dev) |
@@ -236,8 +213,6 @@ static struct platform_driver atlas7_wdt_driver = { | |||
236 | .of_match_table = atlas7_wdt_ids, | 213 | .of_match_table = atlas7_wdt_ids, |
237 | }, | 214 | }, |
238 | .probe = atlas7_wdt_probe, | 215 | .probe = atlas7_wdt_probe, |
239 | .remove = atlas7_wdt_remove, | ||
240 | .shutdown = atlas7_wdt_shutdown, | ||
241 | }; | 216 | }; |
242 | module_platform_driver(atlas7_wdt_driver); | 217 | module_platform_driver(atlas7_wdt_driver); |
243 | 218 | ||
diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c index 1834524ae373..560c1c54c177 100644 --- a/drivers/watchdog/bcm2835_wdt.c +++ b/drivers/watchdog/bcm2835_wdt.c | |||
@@ -177,7 +177,6 @@ static int bcm2835_wdt_probe(struct platform_device *pdev) | |||
177 | wdt = devm_kzalloc(dev, sizeof(struct bcm2835_wdt), GFP_KERNEL); | 177 | wdt = devm_kzalloc(dev, sizeof(struct bcm2835_wdt), GFP_KERNEL); |
178 | if (!wdt) | 178 | if (!wdt) |
179 | return -ENOMEM; | 179 | return -ENOMEM; |
180 | platform_set_drvdata(pdev, wdt); | ||
181 | 180 | ||
182 | spin_lock_init(&wdt->lock); | 181 | spin_lock_init(&wdt->lock); |
183 | 182 | ||
diff --git a/drivers/watchdog/bcm7038_wdt.c b/drivers/watchdog/bcm7038_wdt.c index ce3f646e8077..d3d88f6703d7 100644 --- a/drivers/watchdog/bcm7038_wdt.c +++ b/drivers/watchdog/bcm7038_wdt.c | |||
@@ -107,11 +107,15 @@ static const struct watchdog_ops bcm7038_wdt_ops = { | |||
107 | .get_timeleft = bcm7038_wdt_get_timeleft, | 107 | .get_timeleft = bcm7038_wdt_get_timeleft, |
108 | }; | 108 | }; |
109 | 109 | ||
110 | static void bcm7038_clk_disable_unprepare(void *data) | ||
111 | { | ||
112 | clk_disable_unprepare(data); | ||
113 | } | ||
114 | |||
110 | static int bcm7038_wdt_probe(struct platform_device *pdev) | 115 | static int bcm7038_wdt_probe(struct platform_device *pdev) |
111 | { | 116 | { |
112 | struct device *dev = &pdev->dev; | 117 | struct device *dev = &pdev->dev; |
113 | struct bcm7038_watchdog *wdt; | 118 | struct bcm7038_watchdog *wdt; |
114 | struct resource *res; | ||
115 | int err; | 119 | int err; |
116 | 120 | ||
117 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); | 121 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
@@ -120,8 +124,7 @@ static int bcm7038_wdt_probe(struct platform_device *pdev) | |||
120 | 124 | ||
121 | platform_set_drvdata(pdev, wdt); | 125 | platform_set_drvdata(pdev, wdt); |
122 | 126 | ||
123 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 127 | wdt->base = devm_platform_ioremap_resource(pdev, 0); |
124 | wdt->base = devm_ioremap_resource(dev, res); | ||
125 | if (IS_ERR(wdt->base)) | 128 | if (IS_ERR(wdt->base)) |
126 | return PTR_ERR(wdt->base); | 129 | return PTR_ERR(wdt->base); |
127 | 130 | ||
@@ -131,6 +134,11 @@ static int bcm7038_wdt_probe(struct platform_device *pdev) | |||
131 | err = clk_prepare_enable(wdt->clk); | 134 | err = clk_prepare_enable(wdt->clk); |
132 | if (err) | 135 | if (err) |
133 | return err; | 136 | return err; |
137 | err = devm_add_action_or_reset(dev, | ||
138 | bcm7038_clk_disable_unprepare, | ||
139 | wdt->clk); | ||
140 | if (err) | ||
141 | return err; | ||
134 | wdt->rate = clk_get_rate(wdt->clk); | 142 | wdt->rate = clk_get_rate(wdt->clk); |
135 | /* Prevent divide-by-zero exception */ | 143 | /* Prevent divide-by-zero exception */ |
136 | if (!wdt->rate) | 144 | if (!wdt->rate) |
@@ -148,10 +156,11 @@ static int bcm7038_wdt_probe(struct platform_device *pdev) | |||
148 | wdt->wdd.parent = dev; | 156 | wdt->wdd.parent = dev; |
149 | watchdog_set_drvdata(&wdt->wdd, wdt); | 157 | watchdog_set_drvdata(&wdt->wdd, wdt); |
150 | 158 | ||
151 | err = watchdog_register_device(&wdt->wdd); | 159 | watchdog_stop_on_reboot(&wdt->wdd); |
160 | watchdog_stop_on_unregister(&wdt->wdd); | ||
161 | err = devm_watchdog_register_device(dev, &wdt->wdd); | ||
152 | if (err) { | 162 | if (err) { |
153 | dev_err(dev, "Failed to register watchdog device\n"); | 163 | dev_err(dev, "Failed to register watchdog device\n"); |
154 | clk_disable_unprepare(wdt->clk); | ||
155 | return err; | 164 | return err; |
156 | } | 165 | } |
157 | 166 | ||
@@ -160,19 +169,6 @@ static int bcm7038_wdt_probe(struct platform_device *pdev) | |||
160 | return 0; | 169 | return 0; |
161 | } | 170 | } |
162 | 171 | ||
163 | static int bcm7038_wdt_remove(struct platform_device *pdev) | ||
164 | { | ||
165 | struct bcm7038_watchdog *wdt = platform_get_drvdata(pdev); | ||
166 | |||
167 | if (!nowayout) | ||
168 | bcm7038_wdt_stop(&wdt->wdd); | ||
169 | |||
170 | watchdog_unregister_device(&wdt->wdd); | ||
171 | clk_disable_unprepare(wdt->clk); | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | #ifdef CONFIG_PM_SLEEP | 172 | #ifdef CONFIG_PM_SLEEP |
177 | static int bcm7038_wdt_suspend(struct device *dev) | 173 | static int bcm7038_wdt_suspend(struct device *dev) |
178 | { | 174 | { |
@@ -198,14 +194,6 @@ static int bcm7038_wdt_resume(struct device *dev) | |||
198 | static SIMPLE_DEV_PM_OPS(bcm7038_wdt_pm_ops, bcm7038_wdt_suspend, | 194 | static SIMPLE_DEV_PM_OPS(bcm7038_wdt_pm_ops, bcm7038_wdt_suspend, |
199 | bcm7038_wdt_resume); | 195 | bcm7038_wdt_resume); |
200 | 196 | ||
201 | static void bcm7038_wdt_shutdown(struct platform_device *pdev) | ||
202 | { | ||
203 | struct bcm7038_watchdog *wdt = platform_get_drvdata(pdev); | ||
204 | |||
205 | if (watchdog_active(&wdt->wdd)) | ||
206 | bcm7038_wdt_stop(&wdt->wdd); | ||
207 | } | ||
208 | |||
209 | static const struct of_device_id bcm7038_wdt_match[] = { | 197 | static const struct of_device_id bcm7038_wdt_match[] = { |
210 | { .compatible = "brcm,bcm7038-wdt" }, | 198 | { .compatible = "brcm,bcm7038-wdt" }, |
211 | {}, | 199 | {}, |
@@ -214,8 +202,6 @@ MODULE_DEVICE_TABLE(of, bcm7038_wdt_match); | |||
214 | 202 | ||
215 | static struct platform_driver bcm7038_wdt_driver = { | 203 | static struct platform_driver bcm7038_wdt_driver = { |
216 | .probe = bcm7038_wdt_probe, | 204 | .probe = bcm7038_wdt_probe, |
217 | .remove = bcm7038_wdt_remove, | ||
218 | .shutdown = bcm7038_wdt_shutdown, | ||
219 | .driver = { | 205 | .driver = { |
220 | .name = "bcm7038-wdt", | 206 | .name = "bcm7038-wdt", |
221 | .of_match_table = bcm7038_wdt_match, | 207 | .of_match_table = bcm7038_wdt_match, |
diff --git a/drivers/watchdog/bcm_kona_wdt.c b/drivers/watchdog/bcm_kona_wdt.c index 4249b47902bd..e2ad44816359 100644 --- a/drivers/watchdog/bcm_kona_wdt.c +++ b/drivers/watchdog/bcm_kona_wdt.c | |||
@@ -271,16 +271,10 @@ static struct watchdog_device bcm_kona_wdt_wdd = { | |||
271 | .timeout = SECWDOG_MAX_COUNT >> SECWDOG_DEFAULT_RESOLUTION, | 271 | .timeout = SECWDOG_MAX_COUNT >> SECWDOG_DEFAULT_RESOLUTION, |
272 | }; | 272 | }; |
273 | 273 | ||
274 | static void bcm_kona_wdt_shutdown(struct platform_device *pdev) | ||
275 | { | ||
276 | bcm_kona_wdt_stop(&bcm_kona_wdt_wdd); | ||
277 | } | ||
278 | |||
279 | static int bcm_kona_wdt_probe(struct platform_device *pdev) | 274 | static int bcm_kona_wdt_probe(struct platform_device *pdev) |
280 | { | 275 | { |
281 | struct device *dev = &pdev->dev; | 276 | struct device *dev = &pdev->dev; |
282 | struct bcm_kona_wdt *wdt; | 277 | struct bcm_kona_wdt *wdt; |
283 | struct resource *res; | ||
284 | int ret; | 278 | int ret; |
285 | 279 | ||
286 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); | 280 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
@@ -289,8 +283,7 @@ static int bcm_kona_wdt_probe(struct platform_device *pdev) | |||
289 | 283 | ||
290 | spin_lock_init(&wdt->lock); | 284 | spin_lock_init(&wdt->lock); |
291 | 285 | ||
292 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 286 | wdt->base = devm_platform_ioremap_resource(pdev, 0); |
293 | wdt->base = devm_ioremap_resource(dev, res); | ||
294 | if (IS_ERR(wdt->base)) | 287 | if (IS_ERR(wdt->base)) |
295 | return -ENODEV; | 288 | return -ENODEV; |
296 | 289 | ||
@@ -303,7 +296,7 @@ static int bcm_kona_wdt_probe(struct platform_device *pdev) | |||
303 | 296 | ||
304 | platform_set_drvdata(pdev, wdt); | 297 | platform_set_drvdata(pdev, wdt); |
305 | watchdog_set_drvdata(&bcm_kona_wdt_wdd, wdt); | 298 | watchdog_set_drvdata(&bcm_kona_wdt_wdd, wdt); |
306 | bcm_kona_wdt_wdd.parent = &pdev->dev; | 299 | bcm_kona_wdt_wdd.parent = dev; |
307 | 300 | ||
308 | ret = bcm_kona_wdt_set_timeout_reg(&bcm_kona_wdt_wdd, 0); | 301 | ret = bcm_kona_wdt_set_timeout_reg(&bcm_kona_wdt_wdd, 0); |
309 | if (ret) { | 302 | if (ret) { |
@@ -311,7 +304,9 @@ static int bcm_kona_wdt_probe(struct platform_device *pdev) | |||
311 | return ret; | 304 | return ret; |
312 | } | 305 | } |
313 | 306 | ||
314 | ret = watchdog_register_device(&bcm_kona_wdt_wdd); | 307 | watchdog_stop_on_reboot(&bcm_kona_wdt_wdd); |
308 | watchdog_stop_on_unregister(&bcm_kona_wdt_wdd); | ||
309 | ret = devm_watchdog_register_device(dev, &bcm_kona_wdt_wdd); | ||
315 | if (ret) { | 310 | if (ret) { |
316 | dev_err(dev, "Failed to register watchdog device"); | 311 | dev_err(dev, "Failed to register watchdog device"); |
317 | return ret; | 312 | return ret; |
@@ -326,8 +321,6 @@ static int bcm_kona_wdt_probe(struct platform_device *pdev) | |||
326 | static int bcm_kona_wdt_remove(struct platform_device *pdev) | 321 | static int bcm_kona_wdt_remove(struct platform_device *pdev) |
327 | { | 322 | { |
328 | bcm_kona_wdt_debug_exit(pdev); | 323 | bcm_kona_wdt_debug_exit(pdev); |
329 | bcm_kona_wdt_shutdown(pdev); | ||
330 | watchdog_unregister_device(&bcm_kona_wdt_wdd); | ||
331 | dev_dbg(&pdev->dev, "Watchdog driver disabled"); | 324 | dev_dbg(&pdev->dev, "Watchdog driver disabled"); |
332 | 325 | ||
333 | return 0; | 326 | return 0; |
@@ -346,7 +339,6 @@ static struct platform_driver bcm_kona_wdt_driver = { | |||
346 | }, | 339 | }, |
347 | .probe = bcm_kona_wdt_probe, | 340 | .probe = bcm_kona_wdt_probe, |
348 | .remove = bcm_kona_wdt_remove, | 341 | .remove = bcm_kona_wdt_remove, |
349 | .shutdown = bcm_kona_wdt_shutdown, | ||
350 | }; | 342 | }; |
351 | 343 | ||
352 | module_platform_driver(bcm_kona_wdt_driver); | 344 | module_platform_driver(bcm_kona_wdt_driver); |
diff --git a/drivers/watchdog/bd70528_wdt.c b/drivers/watchdog/bd70528_wdt.c new file mode 100644 index 000000000000..b0152fef4fc7 --- /dev/null +++ b/drivers/watchdog/bd70528_wdt.c | |||
@@ -0,0 +1,290 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | // Copyright (C) 2018 ROHM Semiconductors | ||
3 | // ROHM BD70528MWV watchdog driver | ||
4 | |||
5 | #include <linux/bcd.h> | ||
6 | #include <linux/kernel.h> | ||
7 | #include <linux/mfd/rohm-bd70528.h> | ||
8 | #include <linux/module.h> | ||
9 | #include <linux/of.h> | ||
10 | #include <linux/platform_device.h> | ||
11 | #include <linux/regmap.h> | ||
12 | #include <linux/watchdog.h> | ||
13 | |||
14 | /* | ||
15 | * Max time we can set is 1 hour, 59 minutes and 59 seconds | ||
16 | * and Minimum time is 1 second | ||
17 | */ | ||
18 | #define WDT_MAX_MS ((2 * 60 * 60 - 1) * 1000) | ||
19 | #define WDT_MIN_MS 1000 | ||
20 | #define DEFAULT_TIMEOUT 60 | ||
21 | |||
22 | #define WD_CTRL_MAGIC1 0x55 | ||
23 | #define WD_CTRL_MAGIC2 0xAA | ||
24 | |||
25 | struct wdtbd70528 { | ||
26 | struct device *dev; | ||
27 | struct regmap *regmap; | ||
28 | struct rohm_regmap_dev *mfd; | ||
29 | struct watchdog_device wdt; | ||
30 | }; | ||
31 | |||
32 | /** | ||
33 | * bd70528_wdt_set - arm or disarm watchdog timer | ||
34 | * | ||
35 | * @data: device data for the PMIC instance we want to operate on | ||
36 | * @enable: new state of WDT. zero to disable, non zero to enable | ||
37 | * @old_state: previous state of WDT will be filled here | ||
38 | * | ||
39 | * Arm or disarm WDT on BD70528 PMIC. Expected to be called only by | ||
40 | * BD70528 RTC and BD70528 WDT drivers. The rtc_timer_lock must be taken | ||
41 | * by calling bd70528_wdt_lock before calling bd70528_wdt_set. | ||
42 | */ | ||
43 | int bd70528_wdt_set(struct rohm_regmap_dev *data, int enable, int *old_state) | ||
44 | { | ||
45 | int ret, i; | ||
46 | unsigned int tmp; | ||
47 | struct bd70528_data *bd70528 = container_of(data, struct bd70528_data, | ||
48 | chip); | ||
49 | u8 wd_ctrl_arr[3] = { WD_CTRL_MAGIC1, WD_CTRL_MAGIC2, 0 }; | ||
50 | u8 *wd_ctrl = &wd_ctrl_arr[2]; | ||
51 | |||
52 | ret = regmap_read(bd70528->chip.regmap, BD70528_REG_WDT_CTRL, &tmp); | ||
53 | if (ret) | ||
54 | return ret; | ||
55 | |||
56 | *wd_ctrl = (u8)tmp; | ||
57 | |||
58 | if (old_state) { | ||
59 | if (*wd_ctrl & BD70528_MASK_WDT_EN) | ||
60 | *old_state |= BD70528_WDT_STATE_BIT; | ||
61 | else | ||
62 | *old_state &= ~BD70528_WDT_STATE_BIT; | ||
63 | if ((!enable) == (!(*old_state & BD70528_WDT_STATE_BIT))) | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | if (enable) { | ||
68 | if (*wd_ctrl & BD70528_MASK_WDT_EN) | ||
69 | return 0; | ||
70 | *wd_ctrl |= BD70528_MASK_WDT_EN; | ||
71 | } else { | ||
72 | if (*wd_ctrl & BD70528_MASK_WDT_EN) | ||
73 | *wd_ctrl &= ~BD70528_MASK_WDT_EN; | ||
74 | else | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | for (i = 0; i < 3; i++) { | ||
79 | ret = regmap_write(bd70528->chip.regmap, BD70528_REG_WDT_CTRL, | ||
80 | wd_ctrl_arr[i]); | ||
81 | if (ret) | ||
82 | return ret; | ||
83 | } | ||
84 | |||
85 | ret = regmap_read(bd70528->chip.regmap, BD70528_REG_WDT_CTRL, &tmp); | ||
86 | if ((tmp & BD70528_MASK_WDT_EN) != (*wd_ctrl & BD70528_MASK_WDT_EN)) { | ||
87 | dev_err(bd70528->chip.dev, | ||
88 | "Watchdog ctrl mismatch (hw) 0x%x (set) 0x%x\n", | ||
89 | tmp, *wd_ctrl); | ||
90 | ret = -EIO; | ||
91 | } | ||
92 | |||
93 | return ret; | ||
94 | } | ||
95 | EXPORT_SYMBOL(bd70528_wdt_set); | ||
96 | |||
97 | /** | ||
98 | * bd70528_wdt_lock - take WDT lock | ||
99 | * | ||
100 | * @bd70528: device data for the PMIC instance we want to operate on | ||
101 | * | ||
102 | * Lock WDT for arming/disarming in order to avoid race condition caused | ||
103 | * by WDT state changes initiated by WDT and RTC drivers. | ||
104 | */ | ||
105 | void bd70528_wdt_lock(struct rohm_regmap_dev *data) | ||
106 | { | ||
107 | struct bd70528_data *bd70528 = container_of(data, struct bd70528_data, | ||
108 | chip); | ||
109 | |||
110 | mutex_lock(&bd70528->rtc_timer_lock); | ||
111 | } | ||
112 | EXPORT_SYMBOL(bd70528_wdt_lock); | ||
113 | |||
114 | /** | ||
115 | * bd70528_wdt_unlock - unlock WDT lock | ||
116 | * | ||
117 | * @bd70528: device data for the PMIC instance we want to operate on | ||
118 | * | ||
119 | * Unlock WDT lock which has previously been taken by call to | ||
120 | * bd70528_wdt_lock. | ||
121 | */ | ||
122 | void bd70528_wdt_unlock(struct rohm_regmap_dev *data) | ||
123 | { | ||
124 | struct bd70528_data *bd70528 = container_of(data, struct bd70528_data, | ||
125 | chip); | ||
126 | |||
127 | mutex_unlock(&bd70528->rtc_timer_lock); | ||
128 | } | ||
129 | EXPORT_SYMBOL(bd70528_wdt_unlock); | ||
130 | |||
131 | static int bd70528_wdt_set_locked(struct wdtbd70528 *w, int enable) | ||
132 | { | ||
133 | return bd70528_wdt_set(w->mfd, enable, NULL); | ||
134 | } | ||
135 | |||
136 | static int bd70528_wdt_change(struct wdtbd70528 *w, int enable) | ||
137 | { | ||
138 | int ret; | ||
139 | |||
140 | bd70528_wdt_lock(w->mfd); | ||
141 | ret = bd70528_wdt_set_locked(w, enable); | ||
142 | bd70528_wdt_unlock(w->mfd); | ||
143 | |||
144 | return ret; | ||
145 | } | ||
146 | |||
147 | static int bd70528_wdt_start(struct watchdog_device *wdt) | ||
148 | { | ||
149 | struct wdtbd70528 *w = watchdog_get_drvdata(wdt); | ||
150 | |||
151 | dev_dbg(w->dev, "WDT ping...\n"); | ||
152 | return bd70528_wdt_change(w, 1); | ||
153 | } | ||
154 | |||
155 | static int bd70528_wdt_stop(struct watchdog_device *wdt) | ||
156 | { | ||
157 | struct wdtbd70528 *w = watchdog_get_drvdata(wdt); | ||
158 | |||
159 | dev_dbg(w->dev, "WDT stopping...\n"); | ||
160 | return bd70528_wdt_change(w, 0); | ||
161 | } | ||
162 | |||
163 | static int bd70528_wdt_set_timeout(struct watchdog_device *wdt, | ||
164 | unsigned int timeout) | ||
165 | { | ||
166 | unsigned int hours; | ||
167 | unsigned int minutes; | ||
168 | unsigned int seconds; | ||
169 | int ret; | ||
170 | struct wdtbd70528 *w = watchdog_get_drvdata(wdt); | ||
171 | |||
172 | seconds = timeout; | ||
173 | hours = timeout / (60 * 60); | ||
174 | /* Maximum timeout is 1h 59m 59s => hours is 1 or 0 */ | ||
175 | if (hours) | ||
176 | seconds -= (60 * 60); | ||
177 | minutes = seconds / 60; | ||
178 | seconds = seconds % 60; | ||
179 | |||
180 | bd70528_wdt_lock(w->mfd); | ||
181 | |||
182 | ret = bd70528_wdt_set_locked(w, 0); | ||
183 | if (ret) | ||
184 | goto out_unlock; | ||
185 | |||
186 | ret = regmap_update_bits(w->regmap, BD70528_REG_WDT_HOUR, | ||
187 | BD70528_MASK_WDT_HOUR, hours); | ||
188 | if (ret) { | ||
189 | dev_err(w->dev, "Failed to set WDT hours\n"); | ||
190 | goto out_en_unlock; | ||
191 | } | ||
192 | ret = regmap_update_bits(w->regmap, BD70528_REG_WDT_MINUTE, | ||
193 | BD70528_MASK_WDT_MINUTE, bin2bcd(minutes)); | ||
194 | if (ret) { | ||
195 | dev_err(w->dev, "Failed to set WDT minutes\n"); | ||
196 | goto out_en_unlock; | ||
197 | } | ||
198 | ret = regmap_update_bits(w->regmap, BD70528_REG_WDT_SEC, | ||
199 | BD70528_MASK_WDT_SEC, bin2bcd(seconds)); | ||
200 | if (ret) | ||
201 | dev_err(w->dev, "Failed to set WDT seconds\n"); | ||
202 | else | ||
203 | dev_dbg(w->dev, "WDT tmo set to %u\n", timeout); | ||
204 | |||
205 | out_en_unlock: | ||
206 | ret = bd70528_wdt_set_locked(w, 1); | ||
207 | out_unlock: | ||
208 | bd70528_wdt_unlock(w->mfd); | ||
209 | |||
210 | return ret; | ||
211 | } | ||
212 | |||
213 | static const struct watchdog_info bd70528_wdt_info = { | ||
214 | .identity = "bd70528-wdt", | ||
215 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, | ||
216 | }; | ||
217 | |||
218 | static const struct watchdog_ops bd70528_wdt_ops = { | ||
219 | .start = bd70528_wdt_start, | ||
220 | .stop = bd70528_wdt_stop, | ||
221 | .set_timeout = bd70528_wdt_set_timeout, | ||
222 | }; | ||
223 | |||
224 | static int bd70528_wdt_probe(struct platform_device *pdev) | ||
225 | { | ||
226 | struct rohm_regmap_dev *bd70528; | ||
227 | struct wdtbd70528 *w; | ||
228 | int ret; | ||
229 | unsigned int reg; | ||
230 | |||
231 | bd70528 = dev_get_drvdata(pdev->dev.parent); | ||
232 | if (!bd70528) { | ||
233 | dev_err(&pdev->dev, "No MFD driver data\n"); | ||
234 | return -EINVAL; | ||
235 | } | ||
236 | w = devm_kzalloc(&pdev->dev, sizeof(*w), GFP_KERNEL); | ||
237 | if (!w) | ||
238 | return -ENOMEM; | ||
239 | |||
240 | w->regmap = bd70528->regmap; | ||
241 | w->mfd = bd70528; | ||
242 | w->dev = &pdev->dev; | ||
243 | |||
244 | w->wdt.info = &bd70528_wdt_info; | ||
245 | w->wdt.ops = &bd70528_wdt_ops; | ||
246 | w->wdt.min_hw_heartbeat_ms = WDT_MIN_MS; | ||
247 | w->wdt.max_hw_heartbeat_ms = WDT_MAX_MS; | ||
248 | w->wdt.parent = pdev->dev.parent; | ||
249 | w->wdt.timeout = DEFAULT_TIMEOUT; | ||
250 | watchdog_set_drvdata(&w->wdt, w); | ||
251 | watchdog_init_timeout(&w->wdt, 0, pdev->dev.parent); | ||
252 | |||
253 | ret = bd70528_wdt_set_timeout(&w->wdt, w->wdt.timeout); | ||
254 | if (ret) { | ||
255 | dev_err(&pdev->dev, "Failed to set the watchdog timeout\n"); | ||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | bd70528_wdt_lock(w->mfd); | ||
260 | ret = regmap_read(w->regmap, BD70528_REG_WDT_CTRL, ®); | ||
261 | bd70528_wdt_unlock(w->mfd); | ||
262 | |||
263 | if (ret) { | ||
264 | dev_err(&pdev->dev, "Failed to get the watchdog state\n"); | ||
265 | return ret; | ||
266 | } | ||
267 | if (reg & BD70528_MASK_WDT_EN) { | ||
268 | dev_dbg(&pdev->dev, "watchdog was running during probe\n"); | ||
269 | set_bit(WDOG_HW_RUNNING, &w->wdt.status); | ||
270 | } | ||
271 | |||
272 | ret = devm_watchdog_register_device(&pdev->dev, &w->wdt); | ||
273 | if (ret < 0) | ||
274 | dev_err(&pdev->dev, "watchdog registration failed: %d\n", ret); | ||
275 | |||
276 | return ret; | ||
277 | } | ||
278 | |||
279 | static struct platform_driver bd70528_wdt = { | ||
280 | .driver = { | ||
281 | .name = "bd70528-wdt" | ||
282 | }, | ||
283 | .probe = bd70528_wdt_probe, | ||
284 | }; | ||
285 | |||
286 | module_platform_driver(bd70528_wdt); | ||
287 | |||
288 | MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>"); | ||
289 | MODULE_DESCRIPTION("BD70528 watchdog driver"); | ||
290 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index c3924356d173..a22f2d431a35 100644 --- a/drivers/watchdog/cadence_wdt.c +++ b/drivers/watchdog/cadence_wdt.c | |||
@@ -274,6 +274,11 @@ static const struct watchdog_ops cdns_wdt_ops = { | |||
274 | .set_timeout = cdns_wdt_settimeout, | 274 | .set_timeout = cdns_wdt_settimeout, |
275 | }; | 275 | }; |
276 | 276 | ||
277 | static void cdns_clk_disable_unprepare(void *data) | ||
278 | { | ||
279 | clk_disable_unprepare(data); | ||
280 | } | ||
281 | |||
277 | /************************Platform Operations*****************************/ | 282 | /************************Platform Operations*****************************/ |
278 | /** | 283 | /** |
279 | * cdns_wdt_probe - Probe call for the device. | 284 | * cdns_wdt_probe - Probe call for the device. |
@@ -285,13 +290,13 @@ static const struct watchdog_ops cdns_wdt_ops = { | |||
285 | */ | 290 | */ |
286 | static int cdns_wdt_probe(struct platform_device *pdev) | 291 | static int cdns_wdt_probe(struct platform_device *pdev) |
287 | { | 292 | { |
288 | struct resource *res; | 293 | struct device *dev = &pdev->dev; |
289 | int ret, irq; | 294 | int ret, irq; |
290 | unsigned long clock_f; | 295 | unsigned long clock_f; |
291 | struct cdns_wdt *wdt; | 296 | struct cdns_wdt *wdt; |
292 | struct watchdog_device *cdns_wdt_device; | 297 | struct watchdog_device *cdns_wdt_device; |
293 | 298 | ||
294 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 299 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
295 | if (!wdt) | 300 | if (!wdt) |
296 | return -ENOMEM; | 301 | return -ENOMEM; |
297 | 302 | ||
@@ -302,19 +307,18 @@ static int cdns_wdt_probe(struct platform_device *pdev) | |||
302 | cdns_wdt_device->min_timeout = CDNS_WDT_MIN_TIMEOUT; | 307 | cdns_wdt_device->min_timeout = CDNS_WDT_MIN_TIMEOUT; |
303 | cdns_wdt_device->max_timeout = CDNS_WDT_MAX_TIMEOUT; | 308 | cdns_wdt_device->max_timeout = CDNS_WDT_MAX_TIMEOUT; |
304 | 309 | ||
305 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 310 | wdt->regs = devm_platform_ioremap_resource(pdev, 0); |
306 | wdt->regs = devm_ioremap_resource(&pdev->dev, res); | ||
307 | if (IS_ERR(wdt->regs)) | 311 | if (IS_ERR(wdt->regs)) |
308 | return PTR_ERR(wdt->regs); | 312 | return PTR_ERR(wdt->regs); |
309 | 313 | ||
310 | /* Register the interrupt */ | 314 | /* Register the interrupt */ |
311 | wdt->rst = of_property_read_bool(pdev->dev.of_node, "reset-on-timeout"); | 315 | wdt->rst = of_property_read_bool(dev->of_node, "reset-on-timeout"); |
312 | irq = platform_get_irq(pdev, 0); | 316 | irq = platform_get_irq(pdev, 0); |
313 | if (!wdt->rst && irq >= 0) { | 317 | if (!wdt->rst && irq >= 0) { |
314 | ret = devm_request_irq(&pdev->dev, irq, cdns_wdt_irq_handler, 0, | 318 | ret = devm_request_irq(dev, irq, cdns_wdt_irq_handler, 0, |
315 | pdev->name, pdev); | 319 | pdev->name, pdev); |
316 | if (ret) { | 320 | if (ret) { |
317 | dev_err(&pdev->dev, | 321 | dev_err(dev, |
318 | "cannot register interrupt handler err=%d\n", | 322 | "cannot register interrupt handler err=%d\n", |
319 | ret); | 323 | ret); |
320 | return ret; | 324 | return ret; |
@@ -322,30 +326,28 @@ static int cdns_wdt_probe(struct platform_device *pdev) | |||
322 | } | 326 | } |
323 | 327 | ||
324 | /* Initialize the members of cdns_wdt structure */ | 328 | /* Initialize the members of cdns_wdt structure */ |
325 | cdns_wdt_device->parent = &pdev->dev; | 329 | cdns_wdt_device->parent = dev; |
326 | |||
327 | ret = watchdog_init_timeout(cdns_wdt_device, wdt_timeout, &pdev->dev); | ||
328 | if (ret) { | ||
329 | dev_err(&pdev->dev, "unable to set timeout value\n"); | ||
330 | return ret; | ||
331 | } | ||
332 | 330 | ||
331 | watchdog_init_timeout(cdns_wdt_device, wdt_timeout, dev); | ||
333 | watchdog_set_nowayout(cdns_wdt_device, nowayout); | 332 | watchdog_set_nowayout(cdns_wdt_device, nowayout); |
334 | watchdog_stop_on_reboot(cdns_wdt_device); | 333 | watchdog_stop_on_reboot(cdns_wdt_device); |
335 | watchdog_set_drvdata(cdns_wdt_device, wdt); | 334 | watchdog_set_drvdata(cdns_wdt_device, wdt); |
336 | 335 | ||
337 | wdt->clk = devm_clk_get(&pdev->dev, NULL); | 336 | wdt->clk = devm_clk_get(dev, NULL); |
338 | if (IS_ERR(wdt->clk)) { | 337 | if (IS_ERR(wdt->clk)) { |
339 | dev_err(&pdev->dev, "input clock not found\n"); | 338 | dev_err(dev, "input clock not found\n"); |
340 | ret = PTR_ERR(wdt->clk); | 339 | return PTR_ERR(wdt->clk); |
341 | return ret; | ||
342 | } | 340 | } |
343 | 341 | ||
344 | ret = clk_prepare_enable(wdt->clk); | 342 | ret = clk_prepare_enable(wdt->clk); |
345 | if (ret) { | 343 | if (ret) { |
346 | dev_err(&pdev->dev, "unable to enable clock\n"); | 344 | dev_err(dev, "unable to enable clock\n"); |
347 | return ret; | 345 | return ret; |
348 | } | 346 | } |
347 | ret = devm_add_action_or_reset(dev, cdns_clk_disable_unprepare, | ||
348 | wdt->clk); | ||
349 | if (ret) | ||
350 | return ret; | ||
349 | 351 | ||
350 | clock_f = clk_get_rate(wdt->clk); | 352 | clock_f = clk_get_rate(wdt->clk); |
351 | if (clock_f <= CDNS_WDT_CLK_75MHZ) { | 353 | if (clock_f <= CDNS_WDT_CLK_75MHZ) { |
@@ -358,56 +360,20 @@ static int cdns_wdt_probe(struct platform_device *pdev) | |||
358 | 360 | ||
359 | spin_lock_init(&wdt->io_lock); | 361 | spin_lock_init(&wdt->io_lock); |
360 | 362 | ||
361 | ret = watchdog_register_device(cdns_wdt_device); | 363 | watchdog_stop_on_reboot(cdns_wdt_device); |
364 | watchdog_stop_on_unregister(cdns_wdt_device); | ||
365 | ret = devm_watchdog_register_device(dev, cdns_wdt_device); | ||
362 | if (ret) { | 366 | if (ret) { |
363 | dev_err(&pdev->dev, "Failed to register wdt device\n"); | 367 | dev_err(dev, "Failed to register wdt device\n"); |
364 | goto err_clk_disable; | 368 | return ret; |
365 | } | 369 | } |
366 | platform_set_drvdata(pdev, wdt); | 370 | platform_set_drvdata(pdev, wdt); |
367 | 371 | ||
368 | dev_info(&pdev->dev, "Xilinx Watchdog Timer at %p with timeout %ds%s\n", | 372 | dev_info(dev, "Xilinx Watchdog Timer at %p with timeout %ds%s\n", |
369 | wdt->regs, cdns_wdt_device->timeout, | 373 | wdt->regs, cdns_wdt_device->timeout, |
370 | nowayout ? ", nowayout" : ""); | 374 | nowayout ? ", nowayout" : ""); |
371 | 375 | ||
372 | return 0; | 376 | return 0; |
373 | |||
374 | err_clk_disable: | ||
375 | clk_disable_unprepare(wdt->clk); | ||
376 | |||
377 | return ret; | ||
378 | } | ||
379 | |||
380 | /** | ||
381 | * cdns_wdt_remove - Probe call for the device. | ||
382 | * | ||
383 | * @pdev: handle to the platform device structure. | ||
384 | * Return: 0 on success, otherwise negative error. | ||
385 | * | ||
386 | * Unregister the device after releasing the resources. | ||
387 | */ | ||
388 | static int cdns_wdt_remove(struct platform_device *pdev) | ||
389 | { | ||
390 | struct cdns_wdt *wdt = platform_get_drvdata(pdev); | ||
391 | |||
392 | cdns_wdt_stop(&wdt->cdns_wdt_device); | ||
393 | watchdog_unregister_device(&wdt->cdns_wdt_device); | ||
394 | clk_disable_unprepare(wdt->clk); | ||
395 | |||
396 | return 0; | ||
397 | } | ||
398 | |||
399 | /** | ||
400 | * cdns_wdt_shutdown - Stop the device. | ||
401 | * | ||
402 | * @pdev: handle to the platform structure. | ||
403 | * | ||
404 | */ | ||
405 | static void cdns_wdt_shutdown(struct platform_device *pdev) | ||
406 | { | ||
407 | struct cdns_wdt *wdt = platform_get_drvdata(pdev); | ||
408 | |||
409 | cdns_wdt_stop(&wdt->cdns_wdt_device); | ||
410 | clk_disable_unprepare(wdt->clk); | ||
411 | } | 377 | } |
412 | 378 | ||
413 | /** | 379 | /** |
@@ -462,8 +428,6 @@ MODULE_DEVICE_TABLE(of, cdns_wdt_of_match); | |||
462 | /* Driver Structure */ | 428 | /* Driver Structure */ |
463 | static struct platform_driver cdns_wdt_driver = { | 429 | static struct platform_driver cdns_wdt_driver = { |
464 | .probe = cdns_wdt_probe, | 430 | .probe = cdns_wdt_probe, |
465 | .remove = cdns_wdt_remove, | ||
466 | .shutdown = cdns_wdt_shutdown, | ||
467 | .driver = { | 431 | .driver = { |
468 | .name = "cdns-wdt", | 432 | .name = "cdns-wdt", |
469 | .of_match_table = cdns_wdt_of_match, | 433 | .of_match_table = cdns_wdt_of_match, |
diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c index f29d1edc5bad..260c50b08483 100644 --- a/drivers/watchdog/coh901327_wdt.c +++ b/drivers/watchdog/coh901327_wdt.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Watchdog driver for the ST-Ericsson AB COH 901 327 IP core | 6 | * Watchdog driver for the ST-Ericsson AB COH 901 327 IP core |
7 | * Author: Linus Walleij <linus.walleij@stericsson.com> | 7 | * Author: Linus Walleij <linus.walleij@stericsson.com> |
8 | */ | 8 | */ |
9 | #include <linux/module.h> | 9 | #include <linux/moduleparam.h> |
10 | #include <linux/mod_devicetable.h> | 10 | #include <linux/mod_devicetable.h> |
11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
12 | #include <linux/watchdog.h> | 12 | #include <linux/watchdog.h> |
@@ -243,27 +243,15 @@ static struct watchdog_device coh901327_wdt = { | |||
243 | .timeout = U300_WDOG_DEFAULT_TIMEOUT, | 243 | .timeout = U300_WDOG_DEFAULT_TIMEOUT, |
244 | }; | 244 | }; |
245 | 245 | ||
246 | static int __exit coh901327_remove(struct platform_device *pdev) | ||
247 | { | ||
248 | watchdog_unregister_device(&coh901327_wdt); | ||
249 | coh901327_disable(); | ||
250 | free_irq(irq, pdev); | ||
251 | clk_disable_unprepare(clk); | ||
252 | clk_put(clk); | ||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | static int __init coh901327_probe(struct platform_device *pdev) | 246 | static int __init coh901327_probe(struct platform_device *pdev) |
257 | { | 247 | { |
258 | struct device *dev = &pdev->dev; | 248 | struct device *dev = &pdev->dev; |
259 | int ret; | 249 | int ret; |
260 | u16 val; | 250 | u16 val; |
261 | struct resource *res; | ||
262 | 251 | ||
263 | parent = dev; | 252 | parent = dev; |
264 | 253 | ||
265 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 254 | virtbase = devm_platform_ioremap_resource(pdev, 0); |
266 | virtbase = devm_ioremap_resource(dev, res); | ||
267 | if (IS_ERR(virtbase)) | 255 | if (IS_ERR(virtbase)) |
268 | return PTR_ERR(virtbase); | 256 | return PTR_ERR(virtbase); |
269 | 257 | ||
@@ -408,19 +396,13 @@ static struct platform_driver coh901327_driver = { | |||
408 | .driver = { | 396 | .driver = { |
409 | .name = "coh901327_wdog", | 397 | .name = "coh901327_wdog", |
410 | .of_match_table = coh901327_dt_match, | 398 | .of_match_table = coh901327_dt_match, |
399 | .suppress_bind_attrs = true, | ||
411 | }, | 400 | }, |
412 | .remove = __exit_p(coh901327_remove), | ||
413 | .suspend = coh901327_suspend, | 401 | .suspend = coh901327_suspend, |
414 | .resume = coh901327_resume, | 402 | .resume = coh901327_resume, |
415 | }; | 403 | }; |
404 | builtin_platform_driver_probe(coh901327_driver, coh901327_probe); | ||
416 | 405 | ||
417 | module_platform_driver_probe(coh901327_driver, coh901327_probe); | 406 | /* not really modular, but ... */ |
418 | |||
419 | MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>"); | ||
420 | MODULE_DESCRIPTION("COH 901 327 Watchdog"); | ||
421 | |||
422 | module_param(margin, uint, 0); | 407 | module_param(margin, uint, 0); |
423 | MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)"); | 408 | MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)"); |
424 | |||
425 | MODULE_LICENSE("GPL v2"); | ||
426 | MODULE_ALIAS("platform:coh901327-watchdog"); | ||
diff --git a/drivers/watchdog/da9052_wdt.c b/drivers/watchdog/da9052_wdt.c index e263bad99574..a2feef1ff307 100644 --- a/drivers/watchdog/da9052_wdt.c +++ b/drivers/watchdog/da9052_wdt.c | |||
@@ -150,13 +150,13 @@ static const struct watchdog_ops da9052_wdt_ops = { | |||
150 | 150 | ||
151 | static int da9052_wdt_probe(struct platform_device *pdev) | 151 | static int da9052_wdt_probe(struct platform_device *pdev) |
152 | { | 152 | { |
153 | struct da9052 *da9052 = dev_get_drvdata(pdev->dev.parent); | 153 | struct device *dev = &pdev->dev; |
154 | struct da9052 *da9052 = dev_get_drvdata(dev->parent); | ||
154 | struct da9052_wdt_data *driver_data; | 155 | struct da9052_wdt_data *driver_data; |
155 | struct watchdog_device *da9052_wdt; | 156 | struct watchdog_device *da9052_wdt; |
156 | int ret; | 157 | int ret; |
157 | 158 | ||
158 | driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data), | 159 | driver_data = devm_kzalloc(dev, sizeof(*driver_data), GFP_KERNEL); |
159 | GFP_KERNEL); | ||
160 | if (!driver_data) | 160 | if (!driver_data) |
161 | return -ENOMEM; | 161 | return -ENOMEM; |
162 | driver_data->da9052 = da9052; | 162 | driver_data->da9052 = da9052; |
@@ -166,18 +166,17 @@ static int da9052_wdt_probe(struct platform_device *pdev) | |||
166 | da9052_wdt->timeout = DA9052_DEF_TIMEOUT; | 166 | da9052_wdt->timeout = DA9052_DEF_TIMEOUT; |
167 | da9052_wdt->info = &da9052_wdt_info; | 167 | da9052_wdt->info = &da9052_wdt_info; |
168 | da9052_wdt->ops = &da9052_wdt_ops; | 168 | da9052_wdt->ops = &da9052_wdt_ops; |
169 | da9052_wdt->parent = &pdev->dev; | 169 | da9052_wdt->parent = dev; |
170 | watchdog_set_drvdata(da9052_wdt, driver_data); | 170 | watchdog_set_drvdata(da9052_wdt, driver_data); |
171 | 171 | ||
172 | ret = da9052_reg_update(da9052, DA9052_CONTROL_D_REG, | 172 | ret = da9052_reg_update(da9052, DA9052_CONTROL_D_REG, |
173 | DA9052_CONTROLD_TWDSCALE, 0); | 173 | DA9052_CONTROLD_TWDSCALE, 0); |
174 | if (ret < 0) { | 174 | if (ret < 0) { |
175 | dev_err(&pdev->dev, "Failed to disable watchdog bits, %d\n", | 175 | dev_err(dev, "Failed to disable watchdog bits, %d\n", ret); |
176 | ret); | ||
177 | return ret; | 176 | return ret; |
178 | } | 177 | } |
179 | 178 | ||
180 | ret = devm_watchdog_register_device(&pdev->dev, &driver_data->wdt); | 179 | ret = devm_watchdog_register_device(dev, &driver_data->wdt); |
181 | if (ret != 0) { | 180 | if (ret != 0) { |
182 | dev_err(da9052->dev, "watchdog_register_device() failed: %d\n", | 181 | dev_err(da9052->dev, "watchdog_register_device() failed: %d\n", |
183 | ret); | 182 | ret); |
diff --git a/drivers/watchdog/da9055_wdt.c b/drivers/watchdog/da9055_wdt.c index 26a5b2984094..389a4bdd208c 100644 --- a/drivers/watchdog/da9055_wdt.c +++ b/drivers/watchdog/da9055_wdt.c | |||
@@ -119,13 +119,13 @@ static const struct watchdog_ops da9055_wdt_ops = { | |||
119 | 119 | ||
120 | static int da9055_wdt_probe(struct platform_device *pdev) | 120 | static int da9055_wdt_probe(struct platform_device *pdev) |
121 | { | 121 | { |
122 | struct da9055 *da9055 = dev_get_drvdata(pdev->dev.parent); | 122 | struct device *dev = &pdev->dev; |
123 | struct da9055 *da9055 = dev_get_drvdata(dev->parent); | ||
123 | struct da9055_wdt_data *driver_data; | 124 | struct da9055_wdt_data *driver_data; |
124 | struct watchdog_device *da9055_wdt; | 125 | struct watchdog_device *da9055_wdt; |
125 | int ret; | 126 | int ret; |
126 | 127 | ||
127 | driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data), | 128 | driver_data = devm_kzalloc(dev, sizeof(*driver_data), GFP_KERNEL); |
128 | GFP_KERNEL); | ||
129 | if (!driver_data) | 129 | if (!driver_data) |
130 | return -ENOMEM; | 130 | return -ENOMEM; |
131 | 131 | ||
@@ -136,17 +136,17 @@ static int da9055_wdt_probe(struct platform_device *pdev) | |||
136 | da9055_wdt->timeout = DA9055_DEF_TIMEOUT; | 136 | da9055_wdt->timeout = DA9055_DEF_TIMEOUT; |
137 | da9055_wdt->info = &da9055_wdt_info; | 137 | da9055_wdt->info = &da9055_wdt_info; |
138 | da9055_wdt->ops = &da9055_wdt_ops; | 138 | da9055_wdt->ops = &da9055_wdt_ops; |
139 | da9055_wdt->parent = &pdev->dev; | 139 | da9055_wdt->parent = dev; |
140 | watchdog_set_nowayout(da9055_wdt, nowayout); | 140 | watchdog_set_nowayout(da9055_wdt, nowayout); |
141 | watchdog_set_drvdata(da9055_wdt, driver_data); | 141 | watchdog_set_drvdata(da9055_wdt, driver_data); |
142 | 142 | ||
143 | ret = da9055_wdt_stop(da9055_wdt); | 143 | ret = da9055_wdt_stop(da9055_wdt); |
144 | if (ret < 0) { | 144 | if (ret < 0) { |
145 | dev_err(&pdev->dev, "Failed to stop watchdog, %d\n", ret); | 145 | dev_err(dev, "Failed to stop watchdog, %d\n", ret); |
146 | return ret; | 146 | return ret; |
147 | } | 147 | } |
148 | 148 | ||
149 | ret = devm_watchdog_register_device(&pdev->dev, &driver_data->wdt); | 149 | ret = devm_watchdog_register_device(dev, &driver_data->wdt); |
150 | if (ret != 0) | 150 | if (ret != 0) |
151 | dev_err(da9055->dev, "watchdog_register_device() failed: %d\n", | 151 | dev_err(da9055->dev, "watchdog_register_device() failed: %d\n", |
152 | ret); | 152 | ret); |
diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c index fe169d8e1fb2..aac749cfaccb 100644 --- a/drivers/watchdog/da9062_wdt.c +++ b/drivers/watchdog/da9062_wdt.c | |||
@@ -46,14 +46,9 @@ static unsigned int da9062_wdt_timeout_to_sel(unsigned int secs) | |||
46 | 46 | ||
47 | static int da9062_reset_watchdog_timer(struct da9062_watchdog *wdt) | 47 | static int da9062_reset_watchdog_timer(struct da9062_watchdog *wdt) |
48 | { | 48 | { |
49 | int ret; | 49 | return regmap_update_bits(wdt->hw->regmap, DA9062AA_CONTROL_F, |
50 | 50 | DA9062AA_WATCHDOG_MASK, | |
51 | ret = regmap_update_bits(wdt->hw->regmap, | 51 | DA9062AA_WATCHDOG_MASK); |
52 | DA9062AA_CONTROL_F, | ||
53 | DA9062AA_WATCHDOG_MASK, | ||
54 | DA9062AA_WATCHDOG_MASK); | ||
55 | |||
56 | return ret; | ||
57 | } | 52 | } |
58 | 53 | ||
59 | static int da9062_wdt_update_timeout_register(struct da9062_watchdog *wdt, | 54 | static int da9062_wdt_update_timeout_register(struct da9062_watchdog *wdt, |
@@ -190,15 +185,16 @@ MODULE_DEVICE_TABLE(of, da9062_compatible_id_table); | |||
190 | 185 | ||
191 | static int da9062_wdt_probe(struct platform_device *pdev) | 186 | static int da9062_wdt_probe(struct platform_device *pdev) |
192 | { | 187 | { |
188 | struct device *dev = &pdev->dev; | ||
193 | int ret; | 189 | int ret; |
194 | struct da9062 *chip; | 190 | struct da9062 *chip; |
195 | struct da9062_watchdog *wdt; | 191 | struct da9062_watchdog *wdt; |
196 | 192 | ||
197 | chip = dev_get_drvdata(pdev->dev.parent); | 193 | chip = dev_get_drvdata(dev->parent); |
198 | if (!chip) | 194 | if (!chip) |
199 | return -EINVAL; | 195 | return -EINVAL; |
200 | 196 | ||
201 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 197 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
202 | if (!wdt) | 198 | if (!wdt) |
203 | return -ENOMEM; | 199 | return -ENOMEM; |
204 | 200 | ||
@@ -211,13 +207,13 @@ static int da9062_wdt_probe(struct platform_device *pdev) | |||
211 | wdt->wdtdev.min_hw_heartbeat_ms = DA9062_RESET_PROTECTION_MS; | 207 | wdt->wdtdev.min_hw_heartbeat_ms = DA9062_RESET_PROTECTION_MS; |
212 | wdt->wdtdev.timeout = DA9062_WDG_DEFAULT_TIMEOUT; | 208 | wdt->wdtdev.timeout = DA9062_WDG_DEFAULT_TIMEOUT; |
213 | wdt->wdtdev.status = WATCHDOG_NOWAYOUT_INIT_STATUS; | 209 | wdt->wdtdev.status = WATCHDOG_NOWAYOUT_INIT_STATUS; |
214 | wdt->wdtdev.parent = &pdev->dev; | 210 | wdt->wdtdev.parent = dev; |
215 | 211 | ||
216 | watchdog_set_restart_priority(&wdt->wdtdev, 128); | 212 | watchdog_set_restart_priority(&wdt->wdtdev, 128); |
217 | 213 | ||
218 | watchdog_set_drvdata(&wdt->wdtdev, wdt); | 214 | watchdog_set_drvdata(&wdt->wdtdev, wdt); |
219 | 215 | ||
220 | ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdtdev); | 216 | ret = devm_watchdog_register_device(dev, &wdt->wdtdev); |
221 | if (ret < 0) { | 217 | if (ret < 0) { |
222 | dev_err(wdt->hw->dev, | 218 | dev_err(wdt->hw->dev, |
223 | "watchdog registration failed (%d)\n", ret); | 219 | "watchdog registration failed (%d)\n", ret); |
diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c index 384dca16af8b..3d65e92a4e3f 100644 --- a/drivers/watchdog/da9063_wdt.c +++ b/drivers/watchdog/da9063_wdt.c | |||
@@ -188,17 +188,18 @@ static const struct watchdog_ops da9063_watchdog_ops = { | |||
188 | 188 | ||
189 | static int da9063_wdt_probe(struct platform_device *pdev) | 189 | static int da9063_wdt_probe(struct platform_device *pdev) |
190 | { | 190 | { |
191 | struct device *dev = &pdev->dev; | ||
191 | struct da9063 *da9063; | 192 | struct da9063 *da9063; |
192 | struct watchdog_device *wdd; | 193 | struct watchdog_device *wdd; |
193 | 194 | ||
194 | if (!pdev->dev.parent) | 195 | if (!dev->parent) |
195 | return -EINVAL; | 196 | return -EINVAL; |
196 | 197 | ||
197 | da9063 = dev_get_drvdata(pdev->dev.parent); | 198 | da9063 = dev_get_drvdata(dev->parent); |
198 | if (!da9063) | 199 | if (!da9063) |
199 | return -EINVAL; | 200 | return -EINVAL; |
200 | 201 | ||
201 | wdd = devm_kzalloc(&pdev->dev, sizeof(*wdd), GFP_KERNEL); | 202 | wdd = devm_kzalloc(dev, sizeof(*wdd), GFP_KERNEL); |
202 | if (!wdd) | 203 | if (!wdd) |
203 | return -ENOMEM; | 204 | return -ENOMEM; |
204 | 205 | ||
@@ -207,22 +208,24 @@ static int da9063_wdt_probe(struct platform_device *pdev) | |||
207 | wdd->min_timeout = DA9063_WDT_MIN_TIMEOUT; | 208 | wdd->min_timeout = DA9063_WDT_MIN_TIMEOUT; |
208 | wdd->max_timeout = DA9063_WDT_MAX_TIMEOUT; | 209 | wdd->max_timeout = DA9063_WDT_MAX_TIMEOUT; |
209 | wdd->min_hw_heartbeat_ms = DA9063_RESET_PROTECTION_MS; | 210 | wdd->min_hw_heartbeat_ms = DA9063_RESET_PROTECTION_MS; |
210 | wdd->timeout = DA9063_WDG_TIMEOUT; | 211 | wdd->parent = dev; |
211 | wdd->parent = &pdev->dev; | ||
212 | |||
213 | wdd->status = WATCHDOG_NOWAYOUT_INIT_STATUS; | 212 | wdd->status = WATCHDOG_NOWAYOUT_INIT_STATUS; |
214 | 213 | ||
215 | watchdog_set_restart_priority(wdd, 128); | 214 | watchdog_set_restart_priority(wdd, 128); |
216 | |||
217 | watchdog_set_drvdata(wdd, da9063); | 215 | watchdog_set_drvdata(wdd, da9063); |
218 | 216 | ||
217 | /* Set default timeout, maybe override it with DT value, scale it */ | ||
218 | wdd->timeout = DA9063_WDG_TIMEOUT; | ||
219 | watchdog_init_timeout(wdd, 0, dev); | ||
220 | da9063_wdt_set_timeout(wdd, wdd->timeout); | ||
221 | |||
219 | /* Change the timeout to the default value if the watchdog is running */ | 222 | /* Change the timeout to the default value if the watchdog is running */ |
220 | if (da9063_wdt_is_running(da9063)) { | 223 | if (da9063_wdt_is_running(da9063)) { |
221 | da9063_wdt_update_timeout(da9063, DA9063_WDG_TIMEOUT); | 224 | da9063_wdt_update_timeout(da9063, wdd->timeout); |
222 | set_bit(WDOG_HW_RUNNING, &wdd->status); | 225 | set_bit(WDOG_HW_RUNNING, &wdd->status); |
223 | } | 226 | } |
224 | 227 | ||
225 | return devm_watchdog_register_device(&pdev->dev, wdd); | 228 | return devm_watchdog_register_device(dev, wdd); |
226 | } | 229 | } |
227 | 230 | ||
228 | static struct platform_driver da9063_wdt_driver = { | 231 | static struct platform_driver da9063_wdt_driver = { |
diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c index ebb85d60b6d5..7b2ee35b5ffd 100644 --- a/drivers/watchdog/davinci_wdt.c +++ b/drivers/watchdog/davinci_wdt.c | |||
@@ -191,11 +191,15 @@ static const struct watchdog_ops davinci_wdt_ops = { | |||
191 | .restart = davinci_wdt_restart, | 191 | .restart = davinci_wdt_restart, |
192 | }; | 192 | }; |
193 | 193 | ||
194 | static void davinci_clk_disable_unprepare(void *data) | ||
195 | { | ||
196 | clk_disable_unprepare(data); | ||
197 | } | ||
198 | |||
194 | static int davinci_wdt_probe(struct platform_device *pdev) | 199 | static int davinci_wdt_probe(struct platform_device *pdev) |
195 | { | 200 | { |
196 | int ret = 0; | 201 | int ret = 0; |
197 | struct device *dev = &pdev->dev; | 202 | struct device *dev = &pdev->dev; |
198 | struct resource *wdt_mem; | ||
199 | struct watchdog_device *wdd; | 203 | struct watchdog_device *wdd; |
200 | struct davinci_wdt_device *davinci_wdt; | 204 | struct davinci_wdt_device *davinci_wdt; |
201 | 205 | ||
@@ -207,15 +211,19 @@ static int davinci_wdt_probe(struct platform_device *pdev) | |||
207 | 211 | ||
208 | if (IS_ERR(davinci_wdt->clk)) { | 212 | if (IS_ERR(davinci_wdt->clk)) { |
209 | if (PTR_ERR(davinci_wdt->clk) != -EPROBE_DEFER) | 213 | if (PTR_ERR(davinci_wdt->clk) != -EPROBE_DEFER) |
210 | dev_err(&pdev->dev, "failed to get clock node\n"); | 214 | dev_err(dev, "failed to get clock node\n"); |
211 | return PTR_ERR(davinci_wdt->clk); | 215 | return PTR_ERR(davinci_wdt->clk); |
212 | } | 216 | } |
213 | 217 | ||
214 | ret = clk_prepare_enable(davinci_wdt->clk); | 218 | ret = clk_prepare_enable(davinci_wdt->clk); |
215 | if (ret) { | 219 | if (ret) { |
216 | dev_err(&pdev->dev, "failed to prepare clock\n"); | 220 | dev_err(dev, "failed to prepare clock\n"); |
217 | return ret; | 221 | return ret; |
218 | } | 222 | } |
223 | ret = devm_add_action_or_reset(dev, davinci_clk_disable_unprepare, | ||
224 | davinci_wdt->clk); | ||
225 | if (ret) | ||
226 | return ret; | ||
219 | 227 | ||
220 | platform_set_drvdata(pdev, davinci_wdt); | 228 | platform_set_drvdata(pdev, davinci_wdt); |
221 | 229 | ||
@@ -225,7 +233,7 @@ static int davinci_wdt_probe(struct platform_device *pdev) | |||
225 | wdd->min_timeout = 1; | 233 | wdd->min_timeout = 1; |
226 | wdd->max_timeout = MAX_HEARTBEAT; | 234 | wdd->max_timeout = MAX_HEARTBEAT; |
227 | wdd->timeout = DEFAULT_HEARTBEAT; | 235 | wdd->timeout = DEFAULT_HEARTBEAT; |
228 | wdd->parent = &pdev->dev; | 236 | wdd->parent = dev; |
229 | 237 | ||
230 | watchdog_init_timeout(wdd, heartbeat, dev); | 238 | watchdog_init_timeout(wdd, heartbeat, dev); |
231 | 239 | ||
@@ -235,35 +243,17 @@ static int davinci_wdt_probe(struct platform_device *pdev) | |||
235 | watchdog_set_nowayout(wdd, 1); | 243 | watchdog_set_nowayout(wdd, 1); |
236 | watchdog_set_restart_priority(wdd, 128); | 244 | watchdog_set_restart_priority(wdd, 128); |
237 | 245 | ||
238 | wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 246 | davinci_wdt->base = devm_platform_ioremap_resource(pdev, 0); |
239 | davinci_wdt->base = devm_ioremap_resource(dev, wdt_mem); | 247 | if (IS_ERR(davinci_wdt->base)) |
240 | if (IS_ERR(davinci_wdt->base)) { | 248 | return PTR_ERR(davinci_wdt->base); |
241 | ret = PTR_ERR(davinci_wdt->base); | ||
242 | goto err_clk_disable; | ||
243 | } | ||
244 | 249 | ||
245 | ret = watchdog_register_device(wdd); | 250 | ret = devm_watchdog_register_device(dev, wdd); |
246 | if (ret) { | 251 | if (ret) { |
247 | dev_err(dev, "cannot register watchdog device\n"); | 252 | dev_err(dev, "cannot register watchdog device\n"); |
248 | goto err_clk_disable; | 253 | return ret; |
249 | } | 254 | } |
250 | 255 | ||
251 | return 0; | 256 | return 0; |
252 | |||
253 | err_clk_disable: | ||
254 | clk_disable_unprepare(davinci_wdt->clk); | ||
255 | |||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | static int davinci_wdt_remove(struct platform_device *pdev) | ||
260 | { | ||
261 | struct davinci_wdt_device *davinci_wdt = platform_get_drvdata(pdev); | ||
262 | |||
263 | watchdog_unregister_device(&davinci_wdt->wdd); | ||
264 | clk_disable_unprepare(davinci_wdt->clk); | ||
265 | |||
266 | return 0; | ||
267 | } | 257 | } |
268 | 258 | ||
269 | static const struct of_device_id davinci_wdt_of_match[] = { | 259 | static const struct of_device_id davinci_wdt_of_match[] = { |
@@ -278,7 +268,6 @@ static struct platform_driver platform_wdt_driver = { | |||
278 | .of_match_table = davinci_wdt_of_match, | 268 | .of_match_table = davinci_wdt_of_match, |
279 | }, | 269 | }, |
280 | .probe = davinci_wdt_probe, | 270 | .probe = davinci_wdt_probe, |
281 | .remove = davinci_wdt_remove, | ||
282 | }; | 271 | }; |
283 | 272 | ||
284 | module_platform_driver(platform_wdt_driver); | 273 | module_platform_driver(platform_wdt_driver); |
diff --git a/drivers/watchdog/digicolor_wdt.c b/drivers/watchdog/digicolor_wdt.c index a9e11df155b8..8af6e9a67d0d 100644 --- a/drivers/watchdog/digicolor_wdt.c +++ b/drivers/watchdog/digicolor_wdt.c | |||
@@ -116,7 +116,6 @@ static struct watchdog_device dc_wdt_wdd = { | |||
116 | 116 | ||
117 | static int dc_wdt_probe(struct platform_device *pdev) | 117 | static int dc_wdt_probe(struct platform_device *pdev) |
118 | { | 118 | { |
119 | struct resource *res; | ||
120 | struct device *dev = &pdev->dev; | 119 | struct device *dev = &pdev->dev; |
121 | struct dc_wdt *wdt; | 120 | struct dc_wdt *wdt; |
122 | int ret; | 121 | int ret; |
@@ -125,8 +124,7 @@ static int dc_wdt_probe(struct platform_device *pdev) | |||
125 | if (!wdt) | 124 | if (!wdt) |
126 | return -ENOMEM; | 125 | return -ENOMEM; |
127 | 126 | ||
128 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 127 | wdt->base = devm_platform_ioremap_resource(pdev, 0); |
129 | wdt->base = devm_ioremap_resource(dev, res); | ||
130 | if (IS_ERR(wdt->base)) | 128 | if (IS_ERR(wdt->base)) |
131 | return PTR_ERR(wdt->base); | 129 | return PTR_ERR(wdt->base); |
132 | 130 | ||
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c index aa95f57cc1c3..39e43750ab08 100644 --- a/drivers/watchdog/dw_wdt.c +++ b/drivers/watchdog/dw_wdt.c | |||
@@ -238,15 +238,13 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) | |||
238 | struct device *dev = &pdev->dev; | 238 | struct device *dev = &pdev->dev; |
239 | struct watchdog_device *wdd; | 239 | struct watchdog_device *wdd; |
240 | struct dw_wdt *dw_wdt; | 240 | struct dw_wdt *dw_wdt; |
241 | struct resource *mem; | ||
242 | int ret; | 241 | int ret; |
243 | 242 | ||
244 | dw_wdt = devm_kzalloc(dev, sizeof(*dw_wdt), GFP_KERNEL); | 243 | dw_wdt = devm_kzalloc(dev, sizeof(*dw_wdt), GFP_KERNEL); |
245 | if (!dw_wdt) | 244 | if (!dw_wdt) |
246 | return -ENOMEM; | 245 | return -ENOMEM; |
247 | 246 | ||
248 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 247 | dw_wdt->regs = devm_platform_ioremap_resource(pdev, 0); |
249 | dw_wdt->regs = devm_ioremap_resource(dev, mem); | ||
250 | if (IS_ERR(dw_wdt->regs)) | 248 | if (IS_ERR(dw_wdt->regs)) |
251 | return PTR_ERR(dw_wdt->regs); | 249 | return PTR_ERR(dw_wdt->regs); |
252 | 250 | ||
diff --git a/drivers/watchdog/ebc-c384_wdt.c b/drivers/watchdog/ebc-c384_wdt.c index 4c4c8ce78021..c176f59fea28 100644 --- a/drivers/watchdog/ebc-c384_wdt.c +++ b/drivers/watchdog/ebc-c384_wdt.c | |||
@@ -117,10 +117,7 @@ static int ebc_c384_wdt_probe(struct device *dev, unsigned int id) | |||
117 | wdd->max_timeout = WATCHDOG_MAX_TIMEOUT; | 117 | wdd->max_timeout = WATCHDOG_MAX_TIMEOUT; |
118 | 118 | ||
119 | watchdog_set_nowayout(wdd, nowayout); | 119 | watchdog_set_nowayout(wdd, nowayout); |
120 | 120 | watchdog_init_timeout(wdd, timeout, dev); | |
121 | if (watchdog_init_timeout(wdd, timeout, dev)) | ||
122 | dev_warn(dev, "Invalid timeout (%u seconds), using default (%u seconds)\n", | ||
123 | timeout, WATCHDOG_TIMEOUT); | ||
124 | 121 | ||
125 | return devm_watchdog_register_device(dev, wdd); | 122 | return devm_watchdog_register_device(dev, wdd); |
126 | } | 123 | } |
diff --git a/drivers/watchdog/ep93xx_wdt.c b/drivers/watchdog/ep93xx_wdt.c index f9b14e6efd9a..38e26f160b9a 100644 --- a/drivers/watchdog/ep93xx_wdt.c +++ b/drivers/watchdog/ep93xx_wdt.c | |||
@@ -89,18 +89,17 @@ static const struct watchdog_ops ep93xx_wdt_ops = { | |||
89 | 89 | ||
90 | static int ep93xx_wdt_probe(struct platform_device *pdev) | 90 | static int ep93xx_wdt_probe(struct platform_device *pdev) |
91 | { | 91 | { |
92 | struct device *dev = &pdev->dev; | ||
92 | struct ep93xx_wdt_priv *priv; | 93 | struct ep93xx_wdt_priv *priv; |
93 | struct watchdog_device *wdd; | 94 | struct watchdog_device *wdd; |
94 | struct resource *res; | ||
95 | unsigned long val; | 95 | unsigned long val; |
96 | int ret; | 96 | int ret; |
97 | 97 | ||
98 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); | 98 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
99 | if (!priv) | 99 | if (!priv) |
100 | return -ENOMEM; | 100 | return -ENOMEM; |
101 | 101 | ||
102 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 102 | priv->mmio = devm_platform_ioremap_resource(pdev, 0); |
103 | priv->mmio = devm_ioremap_resource(&pdev->dev, res); | ||
104 | if (IS_ERR(priv->mmio)) | 103 | if (IS_ERR(priv->mmio)) |
105 | return PTR_ERR(priv->mmio); | 104 | return PTR_ERR(priv->mmio); |
106 | 105 | ||
@@ -112,21 +111,21 @@ static int ep93xx_wdt_probe(struct platform_device *pdev) | |||
112 | wdd->ops = &ep93xx_wdt_ops; | 111 | wdd->ops = &ep93xx_wdt_ops; |
113 | wdd->min_timeout = 1; | 112 | wdd->min_timeout = 1; |
114 | wdd->max_hw_heartbeat_ms = 200; | 113 | wdd->max_hw_heartbeat_ms = 200; |
115 | wdd->parent = &pdev->dev; | 114 | wdd->parent = dev; |
116 | 115 | ||
117 | watchdog_set_nowayout(wdd, nowayout); | 116 | watchdog_set_nowayout(wdd, nowayout); |
118 | 117 | ||
119 | wdd->timeout = WDT_TIMEOUT; | 118 | wdd->timeout = WDT_TIMEOUT; |
120 | watchdog_init_timeout(wdd, timeout, &pdev->dev); | 119 | watchdog_init_timeout(wdd, timeout, dev); |
121 | 120 | ||
122 | watchdog_set_drvdata(wdd, priv); | 121 | watchdog_set_drvdata(wdd, priv); |
123 | 122 | ||
124 | ret = devm_watchdog_register_device(&pdev->dev, wdd); | 123 | ret = devm_watchdog_register_device(dev, wdd); |
125 | if (ret) | 124 | if (ret) |
126 | return ret; | 125 | return ret; |
127 | 126 | ||
128 | dev_info(&pdev->dev, "EP93XX watchdog driver %s\n", | 127 | dev_info(dev, "EP93XX watchdog driver %s\n", |
129 | (val & 0x08) ? " (nCS1 disable detected)" : ""); | 128 | (val & 0x08) ? " (nCS1 disable detected)" : ""); |
130 | 129 | ||
131 | return 0; | 130 | return 0; |
132 | } | 131 | } |
diff --git a/drivers/watchdog/f71808e_wdt.c b/drivers/watchdog/f71808e_wdt.c index 021c6ace9462..041172e6c469 100644 --- a/drivers/watchdog/f71808e_wdt.c +++ b/drivers/watchdog/f71808e_wdt.c | |||
@@ -338,8 +338,11 @@ static int f71862fg_pin_configure(unsigned short ioaddr) | |||
338 | 338 | ||
339 | static int watchdog_start(void) | 339 | static int watchdog_start(void) |
340 | { | 340 | { |
341 | int err; | ||
342 | u8 tmp; | ||
343 | |||
341 | /* Make sure we don't die as soon as the watchdog is enabled below */ | 344 | /* Make sure we don't die as soon as the watchdog is enabled below */ |
342 | int err = watchdog_keepalive(); | 345 | err = watchdog_keepalive(); |
343 | if (err) | 346 | if (err) |
344 | return err; | 347 | return err; |
345 | 348 | ||
@@ -386,19 +389,18 @@ static int watchdog_start(void) | |||
386 | break; | 389 | break; |
387 | 390 | ||
388 | case f81866: | 391 | case f81866: |
389 | /* Set pin 70 to WDTRST# */ | ||
390 | superio_clear_bit(watchdog.sioaddr, SIO_F81866_REG_PORT_SEL, | ||
391 | BIT(3) | BIT(0)); | ||
392 | superio_set_bit(watchdog.sioaddr, SIO_F81866_REG_PORT_SEL, | ||
393 | BIT(2)); | ||
394 | /* | 392 | /* |
395 | * GPIO1 Control Register when 27h BIT3:2 = 01 & BIT0 = 0. | 393 | * GPIO1 Control Register when 27h BIT3:2 = 01 & BIT0 = 0. |
396 | * The PIN 70(GPIO15/WDTRST) is controlled by 2Ch: | 394 | * The PIN 70(GPIO15/WDTRST) is controlled by 2Ch: |
397 | * BIT5: 0 -> WDTRST# | 395 | * BIT5: 0 -> WDTRST# |
398 | * 1 -> GPIO15 | 396 | * 1 -> GPIO15 |
399 | */ | 397 | */ |
400 | superio_clear_bit(watchdog.sioaddr, SIO_F81866_REG_GPIO1, | 398 | tmp = superio_inb(watchdog.sioaddr, SIO_F81866_REG_PORT_SEL); |
401 | BIT(5)); | 399 | tmp &= ~(BIT(3) | BIT(0)); |
400 | tmp |= BIT(2); | ||
401 | superio_outb(watchdog.sioaddr, SIO_F81866_REG_PORT_SEL, tmp); | ||
402 | |||
403 | superio_clear_bit(watchdog.sioaddr, SIO_F81866_REG_GPIO1, 5); | ||
402 | break; | 404 | break; |
403 | 405 | ||
404 | default: | 406 | default: |
diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c index a9c2912ee280..9ea0e56fa7ee 100644 --- a/drivers/watchdog/ftwdt010_wdt.c +++ b/drivers/watchdog/ftwdt010_wdt.c | |||
@@ -124,7 +124,6 @@ static const struct watchdog_info ftwdt010_wdt_info = { | |||
124 | static int ftwdt010_wdt_probe(struct platform_device *pdev) | 124 | static int ftwdt010_wdt_probe(struct platform_device *pdev) |
125 | { | 125 | { |
126 | struct device *dev = &pdev->dev; | 126 | struct device *dev = &pdev->dev; |
127 | struct resource *res; | ||
128 | struct ftwdt010_wdt *gwdt; | 127 | struct ftwdt010_wdt *gwdt; |
129 | unsigned int reg; | 128 | unsigned int reg; |
130 | int irq; | 129 | int irq; |
@@ -134,8 +133,7 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) | |||
134 | if (!gwdt) | 133 | if (!gwdt) |
135 | return -ENOMEM; | 134 | return -ENOMEM; |
136 | 135 | ||
137 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 136 | gwdt->base = devm_platform_ioremap_resource(pdev, 0); |
138 | gwdt->base = devm_ioremap_resource(dev, res); | ||
139 | if (IS_ERR(gwdt->base)) | 137 | if (IS_ERR(gwdt->base)) |
140 | return PTR_ERR(gwdt->base); | 138 | return PTR_ERR(gwdt->base); |
141 | 139 | ||
@@ -171,7 +169,7 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) | |||
171 | 169 | ||
172 | ret = devm_watchdog_register_device(dev, &gwdt->wdd); | 170 | ret = devm_watchdog_register_device(dev, &gwdt->wdd); |
173 | if (ret) { | 171 | if (ret) { |
174 | dev_err(&pdev->dev, "failed to register watchdog\n"); | 172 | dev_err(dev, "failed to register watchdog\n"); |
175 | return ret; | 173 | return ret; |
176 | } | 174 | } |
177 | 175 | ||
diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c index ea77cae03c9d..bc24674b4d9e 100644 --- a/drivers/watchdog/gpio_wdt.c +++ b/drivers/watchdog/gpio_wdt.c | |||
@@ -154,25 +154,14 @@ static int gpio_wdt_probe(struct platform_device *pdev) | |||
154 | priv->wdd.parent = dev; | 154 | priv->wdd.parent = dev; |
155 | priv->wdd.timeout = SOFT_TIMEOUT_DEF; | 155 | priv->wdd.timeout = SOFT_TIMEOUT_DEF; |
156 | 156 | ||
157 | watchdog_init_timeout(&priv->wdd, 0, &pdev->dev); | 157 | watchdog_init_timeout(&priv->wdd, 0, dev); |
158 | 158 | ||
159 | watchdog_stop_on_reboot(&priv->wdd); | 159 | watchdog_stop_on_reboot(&priv->wdd); |
160 | 160 | ||
161 | if (priv->always_running) | 161 | if (priv->always_running) |
162 | gpio_wdt_start(&priv->wdd); | 162 | gpio_wdt_start(&priv->wdd); |
163 | 163 | ||
164 | ret = watchdog_register_device(&priv->wdd); | 164 | return devm_watchdog_register_device(dev, &priv->wdd); |
165 | |||
166 | return ret; | ||
167 | } | ||
168 | |||
169 | static int gpio_wdt_remove(struct platform_device *pdev) | ||
170 | { | ||
171 | struct gpio_wdt_priv *priv = platform_get_drvdata(pdev); | ||
172 | |||
173 | watchdog_unregister_device(&priv->wdd); | ||
174 | |||
175 | return 0; | ||
176 | } | 165 | } |
177 | 166 | ||
178 | static const struct of_device_id gpio_wdt_dt_ids[] = { | 167 | static const struct of_device_id gpio_wdt_dt_ids[] = { |
@@ -187,7 +176,6 @@ static struct platform_driver gpio_wdt_driver = { | |||
187 | .of_match_table = gpio_wdt_dt_ids, | 176 | .of_match_table = gpio_wdt_dt_ids, |
188 | }, | 177 | }, |
189 | .probe = gpio_wdt_probe, | 178 | .probe = gpio_wdt_probe, |
190 | .remove = gpio_wdt_remove, | ||
191 | }; | 179 | }; |
192 | 180 | ||
193 | #ifdef CONFIG_GPIO_WATCHDOG_ARCH_INITCALL | 181 | #ifdef CONFIG_GPIO_WATCHDOG_ARCH_INITCALL |
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c index ef30c7e9728d..db1bf6f546ae 100644 --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c | |||
@@ -311,8 +311,7 @@ static int hpwdt_init_one(struct pci_dev *dev, | |||
311 | goto error_init_nmi_decoding; | 311 | goto error_init_nmi_decoding; |
312 | 312 | ||
313 | watchdog_set_nowayout(&hpwdt_dev, nowayout); | 313 | watchdog_set_nowayout(&hpwdt_dev, nowayout); |
314 | if (watchdog_init_timeout(&hpwdt_dev, soft_margin, NULL)) | 314 | watchdog_init_timeout(&hpwdt_dev, soft_margin, NULL); |
315 | dev_warn(&dev->dev, "Invalid soft_margin: %d.\n", soft_margin); | ||
316 | 315 | ||
317 | if (pretimeout && hpwdt_dev.timeout <= PRETIMEOUT_SEC) { | 316 | if (pretimeout && hpwdt_dev.timeout <= PRETIMEOUT_SEC) { |
318 | dev_warn(&dev->dev, "timeout <= pretimeout. Setting pretimeout to zero\n"); | 317 | dev_warn(&dev->dev, "timeout <= pretimeout. Setting pretimeout to zero\n"); |
diff --git a/drivers/watchdog/i6300esb.c b/drivers/watchdog/i6300esb.c index 950c71a8bb22..17941c03996b 100644 --- a/drivers/watchdog/i6300esb.c +++ b/drivers/watchdog/i6300esb.c | |||
@@ -311,10 +311,7 @@ static int esb_probe(struct pci_dev *pdev, | |||
311 | edev->wdd.min_timeout = ESB_HEARTBEAT_MIN; | 311 | edev->wdd.min_timeout = ESB_HEARTBEAT_MIN; |
312 | edev->wdd.max_timeout = ESB_HEARTBEAT_MAX; | 312 | edev->wdd.max_timeout = ESB_HEARTBEAT_MAX; |
313 | edev->wdd.timeout = ESB_HEARTBEAT_DEFAULT; | 313 | edev->wdd.timeout = ESB_HEARTBEAT_DEFAULT; |
314 | if (watchdog_init_timeout(&edev->wdd, heartbeat, NULL)) | 314 | watchdog_init_timeout(&edev->wdd, heartbeat, NULL); |
315 | dev_info(&pdev->dev, | ||
316 | "heartbeat value must be " ESB_HEARTBEAT_RANGE | ||
317 | ", using %u\n", edev->wdd.timeout); | ||
318 | watchdog_set_nowayout(&edev->wdd, nowayout); | 315 | watchdog_set_nowayout(&edev->wdd, nowayout); |
319 | watchdog_stop_on_reboot(&edev->wdd); | 316 | watchdog_stop_on_reboot(&edev->wdd); |
320 | watchdog_stop_on_unregister(&edev->wdd); | 317 | watchdog_stop_on_unregister(&edev->wdd); |
@@ -328,8 +325,8 @@ static int esb_probe(struct pci_dev *pdev, | |||
328 | goto err_unmap; | 325 | goto err_unmap; |
329 | } | 326 | } |
330 | dev_info(&pdev->dev, | 327 | dev_info(&pdev->dev, |
331 | "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", | 328 | "initialized. heartbeat=%d sec (nowayout=%d)\n", |
332 | edev->base, edev->wdd.timeout, nowayout); | 329 | edev->wdd.timeout, nowayout); |
333 | return 0; | 330 | return 0; |
334 | 331 | ||
335 | err_unmap: | 332 | err_unmap: |
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c index 0a5318b7865e..89cea6ce9a08 100644 --- a/drivers/watchdog/iTCO_wdt.c +++ b/drivers/watchdog/iTCO_wdt.c | |||
@@ -545,6 +545,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev) | |||
545 | } | 545 | } |
546 | 546 | ||
547 | watchdog_stop_on_reboot(&p->wddev); | 547 | watchdog_stop_on_reboot(&p->wddev); |
548 | watchdog_stop_on_unregister(&p->wddev); | ||
548 | ret = devm_watchdog_register_device(dev, &p->wddev); | 549 | ret = devm_watchdog_register_device(dev, &p->wddev); |
549 | if (ret != 0) { | 550 | if (ret != 0) { |
550 | pr_err("cannot register watchdog device (err=%d)\n", ret); | 551 | pr_err("cannot register watchdog device (err=%d)\n", ret); |
@@ -557,17 +558,6 @@ static int iTCO_wdt_probe(struct platform_device *pdev) | |||
557 | return 0; | 558 | return 0; |
558 | } | 559 | } |
559 | 560 | ||
560 | static int iTCO_wdt_remove(struct platform_device *pdev) | ||
561 | { | ||
562 | struct iTCO_wdt_private *p = platform_get_drvdata(pdev); | ||
563 | |||
564 | /* Stop the timer before we leave */ | ||
565 | if (!nowayout) | ||
566 | iTCO_wdt_stop(&p->wddev); | ||
567 | |||
568 | return 0; | ||
569 | } | ||
570 | |||
571 | #ifdef CONFIG_PM_SLEEP | 561 | #ifdef CONFIG_PM_SLEEP |
572 | /* | 562 | /* |
573 | * Suspend-to-idle requires this, because it stops the ticks and timekeeping, so | 563 | * Suspend-to-idle requires this, because it stops the ticks and timekeeping, so |
@@ -620,7 +610,6 @@ static const struct dev_pm_ops iTCO_wdt_pm = { | |||
620 | 610 | ||
621 | static struct platform_driver iTCO_wdt_driver = { | 611 | static struct platform_driver iTCO_wdt_driver = { |
622 | .probe = iTCO_wdt_probe, | 612 | .probe = iTCO_wdt_probe, |
623 | .remove = iTCO_wdt_remove, | ||
624 | .driver = { | 613 | .driver = { |
625 | .name = DRV_NAME, | 614 | .name = DRV_NAME, |
626 | .pm = ITCO_WDT_PM_OPS, | 615 | .pm = ITCO_WDT_PM_OPS, |
diff --git a/drivers/watchdog/imgpdc_wdt.c b/drivers/watchdog/imgpdc_wdt.c index a3134ffa59f8..0fc31aadeee3 100644 --- a/drivers/watchdog/imgpdc_wdt.c +++ b/drivers/watchdog/imgpdc_wdt.c | |||
@@ -178,59 +178,69 @@ static const struct watchdog_ops pdc_wdt_ops = { | |||
178 | .restart = pdc_wdt_restart, | 178 | .restart = pdc_wdt_restart, |
179 | }; | 179 | }; |
180 | 180 | ||
181 | static void pdc_clk_disable_unprepare(void *data) | ||
182 | { | ||
183 | clk_disable_unprepare(data); | ||
184 | } | ||
185 | |||
181 | static int pdc_wdt_probe(struct platform_device *pdev) | 186 | static int pdc_wdt_probe(struct platform_device *pdev) |
182 | { | 187 | { |
188 | struct device *dev = &pdev->dev; | ||
183 | u64 div; | 189 | u64 div; |
184 | int ret, val; | 190 | int ret, val; |
185 | unsigned long clk_rate; | 191 | unsigned long clk_rate; |
186 | struct resource *res; | ||
187 | struct pdc_wdt_dev *pdc_wdt; | 192 | struct pdc_wdt_dev *pdc_wdt; |
188 | 193 | ||
189 | pdc_wdt = devm_kzalloc(&pdev->dev, sizeof(*pdc_wdt), GFP_KERNEL); | 194 | pdc_wdt = devm_kzalloc(dev, sizeof(*pdc_wdt), GFP_KERNEL); |
190 | if (!pdc_wdt) | 195 | if (!pdc_wdt) |
191 | return -ENOMEM; | 196 | return -ENOMEM; |
192 | 197 | ||
193 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 198 | pdc_wdt->base = devm_platform_ioremap_resource(pdev, 0); |
194 | pdc_wdt->base = devm_ioremap_resource(&pdev->dev, res); | ||
195 | if (IS_ERR(pdc_wdt->base)) | 199 | if (IS_ERR(pdc_wdt->base)) |
196 | return PTR_ERR(pdc_wdt->base); | 200 | return PTR_ERR(pdc_wdt->base); |
197 | 201 | ||
198 | pdc_wdt->sys_clk = devm_clk_get(&pdev->dev, "sys"); | 202 | pdc_wdt->sys_clk = devm_clk_get(dev, "sys"); |
199 | if (IS_ERR(pdc_wdt->sys_clk)) { | 203 | if (IS_ERR(pdc_wdt->sys_clk)) { |
200 | dev_err(&pdev->dev, "failed to get the sys clock\n"); | 204 | dev_err(dev, "failed to get the sys clock\n"); |
201 | return PTR_ERR(pdc_wdt->sys_clk); | 205 | return PTR_ERR(pdc_wdt->sys_clk); |
202 | } | 206 | } |
203 | 207 | ||
204 | pdc_wdt->wdt_clk = devm_clk_get(&pdev->dev, "wdt"); | 208 | pdc_wdt->wdt_clk = devm_clk_get(dev, "wdt"); |
205 | if (IS_ERR(pdc_wdt->wdt_clk)) { | 209 | if (IS_ERR(pdc_wdt->wdt_clk)) { |
206 | dev_err(&pdev->dev, "failed to get the wdt clock\n"); | 210 | dev_err(dev, "failed to get the wdt clock\n"); |
207 | return PTR_ERR(pdc_wdt->wdt_clk); | 211 | return PTR_ERR(pdc_wdt->wdt_clk); |
208 | } | 212 | } |
209 | 213 | ||
210 | ret = clk_prepare_enable(pdc_wdt->sys_clk); | 214 | ret = clk_prepare_enable(pdc_wdt->sys_clk); |
211 | if (ret) { | 215 | if (ret) { |
212 | dev_err(&pdev->dev, "could not prepare or enable sys clock\n"); | 216 | dev_err(dev, "could not prepare or enable sys clock\n"); |
213 | return ret; | 217 | return ret; |
214 | } | 218 | } |
219 | ret = devm_add_action_or_reset(dev, pdc_clk_disable_unprepare, | ||
220 | pdc_wdt->sys_clk); | ||
221 | if (ret) | ||
222 | return ret; | ||
215 | 223 | ||
216 | ret = clk_prepare_enable(pdc_wdt->wdt_clk); | 224 | ret = clk_prepare_enable(pdc_wdt->wdt_clk); |
217 | if (ret) { | 225 | if (ret) { |
218 | dev_err(&pdev->dev, "could not prepare or enable wdt clock\n"); | 226 | dev_err(dev, "could not prepare or enable wdt clock\n"); |
219 | goto disable_sys_clk; | 227 | return ret; |
220 | } | 228 | } |
229 | ret = devm_add_action_or_reset(dev, pdc_clk_disable_unprepare, | ||
230 | pdc_wdt->wdt_clk); | ||
231 | if (ret) | ||
232 | return ret; | ||
221 | 233 | ||
222 | /* We use the clock rate to calculate the max timeout */ | 234 | /* We use the clock rate to calculate the max timeout */ |
223 | clk_rate = clk_get_rate(pdc_wdt->wdt_clk); | 235 | clk_rate = clk_get_rate(pdc_wdt->wdt_clk); |
224 | if (clk_rate == 0) { | 236 | if (clk_rate == 0) { |
225 | dev_err(&pdev->dev, "failed to get clock rate\n"); | 237 | dev_err(dev, "failed to get clock rate\n"); |
226 | ret = -EINVAL; | 238 | return -EINVAL; |
227 | goto disable_wdt_clk; | ||
228 | } | 239 | } |
229 | 240 | ||
230 | if (order_base_2(clk_rate) > PDC_WDT_CONFIG_DELAY_MASK + 1) { | 241 | if (order_base_2(clk_rate) > PDC_WDT_CONFIG_DELAY_MASK + 1) { |
231 | dev_err(&pdev->dev, "invalid clock rate\n"); | 242 | dev_err(dev, "invalid clock rate\n"); |
232 | ret = -EINVAL; | 243 | return -EINVAL; |
233 | goto disable_wdt_clk; | ||
234 | } | 244 | } |
235 | 245 | ||
236 | if (order_base_2(clk_rate) == 0) | 246 | if (order_base_2(clk_rate) == 0) |
@@ -245,10 +255,10 @@ static int pdc_wdt_probe(struct platform_device *pdev) | |||
245 | do_div(div, clk_rate); | 255 | do_div(div, clk_rate); |
246 | pdc_wdt->wdt_dev.max_timeout = div; | 256 | pdc_wdt->wdt_dev.max_timeout = div; |
247 | pdc_wdt->wdt_dev.timeout = PDC_WDT_DEF_TIMEOUT; | 257 | pdc_wdt->wdt_dev.timeout = PDC_WDT_DEF_TIMEOUT; |
248 | pdc_wdt->wdt_dev.parent = &pdev->dev; | 258 | pdc_wdt->wdt_dev.parent = dev; |
249 | watchdog_set_drvdata(&pdc_wdt->wdt_dev, pdc_wdt); | 259 | watchdog_set_drvdata(&pdc_wdt->wdt_dev, pdc_wdt); |
250 | 260 | ||
251 | watchdog_init_timeout(&pdc_wdt->wdt_dev, heartbeat, &pdev->dev); | 261 | watchdog_init_timeout(&pdc_wdt->wdt_dev, heartbeat, dev); |
252 | 262 | ||
253 | pdc_wdt_stop(&pdc_wdt->wdt_dev); | 263 | pdc_wdt_stop(&pdc_wdt->wdt_dev); |
254 | 264 | ||
@@ -259,24 +269,22 @@ static int pdc_wdt_probe(struct platform_device *pdev) | |||
259 | case PDC_WDT_TICKLE_STATUS_TICKLE: | 269 | case PDC_WDT_TICKLE_STATUS_TICKLE: |
260 | case PDC_WDT_TICKLE_STATUS_TIMEOUT: | 270 | case PDC_WDT_TICKLE_STATUS_TIMEOUT: |
261 | pdc_wdt->wdt_dev.bootstatus |= WDIOF_CARDRESET; | 271 | pdc_wdt->wdt_dev.bootstatus |= WDIOF_CARDRESET; |
262 | dev_info(&pdev->dev, | 272 | dev_info(dev, "watchdog module last reset due to timeout\n"); |
263 | "watchdog module last reset due to timeout\n"); | ||
264 | break; | 273 | break; |
265 | case PDC_WDT_TICKLE_STATUS_HRESET: | 274 | case PDC_WDT_TICKLE_STATUS_HRESET: |
266 | dev_info(&pdev->dev, | 275 | dev_info(dev, |
267 | "watchdog module last reset due to hard reset\n"); | 276 | "watchdog module last reset due to hard reset\n"); |
268 | break; | 277 | break; |
269 | case PDC_WDT_TICKLE_STATUS_SRESET: | 278 | case PDC_WDT_TICKLE_STATUS_SRESET: |
270 | dev_info(&pdev->dev, | 279 | dev_info(dev, |
271 | "watchdog module last reset due to soft reset\n"); | 280 | "watchdog module last reset due to soft reset\n"); |
272 | break; | 281 | break; |
273 | case PDC_WDT_TICKLE_STATUS_USER: | 282 | case PDC_WDT_TICKLE_STATUS_USER: |
274 | dev_info(&pdev->dev, | 283 | dev_info(dev, |
275 | "watchdog module last reset due to user reset\n"); | 284 | "watchdog module last reset due to user reset\n"); |
276 | break; | 285 | break; |
277 | default: | 286 | default: |
278 | dev_info(&pdev->dev, | 287 | dev_info(dev, "contains an illegal status code (%08x)\n", val); |
279 | "contains an illegal status code (%08x)\n", val); | ||
280 | break; | 288 | break; |
281 | } | 289 | } |
282 | 290 | ||
@@ -285,36 +293,9 @@ static int pdc_wdt_probe(struct platform_device *pdev) | |||
285 | 293 | ||
286 | platform_set_drvdata(pdev, pdc_wdt); | 294 | platform_set_drvdata(pdev, pdc_wdt); |
287 | 295 | ||
288 | ret = watchdog_register_device(&pdc_wdt->wdt_dev); | 296 | watchdog_stop_on_reboot(&pdc_wdt->wdt_dev); |
289 | if (ret) | 297 | watchdog_stop_on_unregister(&pdc_wdt->wdt_dev); |
290 | goto disable_wdt_clk; | 298 | return devm_watchdog_register_device(dev, &pdc_wdt->wdt_dev); |
291 | |||
292 | return 0; | ||
293 | |||
294 | disable_wdt_clk: | ||
295 | clk_disable_unprepare(pdc_wdt->wdt_clk); | ||
296 | disable_sys_clk: | ||
297 | clk_disable_unprepare(pdc_wdt->sys_clk); | ||
298 | return ret; | ||
299 | } | ||
300 | |||
301 | static void pdc_wdt_shutdown(struct platform_device *pdev) | ||
302 | { | ||
303 | struct pdc_wdt_dev *pdc_wdt = platform_get_drvdata(pdev); | ||
304 | |||
305 | pdc_wdt_stop(&pdc_wdt->wdt_dev); | ||
306 | } | ||
307 | |||
308 | static int pdc_wdt_remove(struct platform_device *pdev) | ||
309 | { | ||
310 | struct pdc_wdt_dev *pdc_wdt = platform_get_drvdata(pdev); | ||
311 | |||
312 | pdc_wdt_stop(&pdc_wdt->wdt_dev); | ||
313 | watchdog_unregister_device(&pdc_wdt->wdt_dev); | ||
314 | clk_disable_unprepare(pdc_wdt->wdt_clk); | ||
315 | clk_disable_unprepare(pdc_wdt->sys_clk); | ||
316 | |||
317 | return 0; | ||
318 | } | 299 | } |
319 | 300 | ||
320 | static const struct of_device_id pdc_wdt_match[] = { | 301 | static const struct of_device_id pdc_wdt_match[] = { |
@@ -329,8 +310,6 @@ static struct platform_driver pdc_wdt_driver = { | |||
329 | .of_match_table = pdc_wdt_match, | 310 | .of_match_table = pdc_wdt_match, |
330 | }, | 311 | }, |
331 | .probe = pdc_wdt_probe, | 312 | .probe = pdc_wdt_probe, |
332 | .remove = pdc_wdt_remove, | ||
333 | .shutdown = pdc_wdt_shutdown, | ||
334 | }; | 313 | }; |
335 | module_platform_driver(pdc_wdt_driver); | 314 | module_platform_driver(pdc_wdt_driver); |
336 | 315 | ||
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index 2b52514eaa86..a606005dd65f 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c | |||
@@ -178,8 +178,10 @@ static void __imx2_wdt_set_timeout(struct watchdog_device *wdog, | |||
178 | static int imx2_wdt_set_timeout(struct watchdog_device *wdog, | 178 | static int imx2_wdt_set_timeout(struct watchdog_device *wdog, |
179 | unsigned int new_timeout) | 179 | unsigned int new_timeout) |
180 | { | 180 | { |
181 | __imx2_wdt_set_timeout(wdog, new_timeout); | 181 | unsigned int actual; |
182 | 182 | ||
183 | actual = min(new_timeout, wdog->max_hw_heartbeat_ms * 1000); | ||
184 | __imx2_wdt_set_timeout(wdog, actual); | ||
183 | wdog->timeout = new_timeout; | 185 | wdog->timeout = new_timeout; |
184 | return 0; | 186 | return 0; |
185 | } | 187 | } |
@@ -247,7 +249,6 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) | |||
247 | { | 249 | { |
248 | struct imx2_wdt_device *wdev; | 250 | struct imx2_wdt_device *wdev; |
249 | struct watchdog_device *wdog; | 251 | struct watchdog_device *wdog; |
250 | struct resource *res; | ||
251 | void __iomem *base; | 252 | void __iomem *base; |
252 | int ret; | 253 | int ret; |
253 | u32 val; | 254 | u32 val; |
@@ -256,8 +257,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) | |||
256 | if (!wdev) | 257 | if (!wdev) |
257 | return -ENOMEM; | 258 | return -ENOMEM; |
258 | 259 | ||
259 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 260 | base = devm_platform_ioremap_resource(pdev, 0); |
260 | base = devm_ioremap_resource(&pdev->dev, res); | ||
261 | if (IS_ERR(base)) | 261 | if (IS_ERR(base)) |
262 | return PTR_ERR(base); | 262 | return PTR_ERR(base); |
263 | 263 | ||
diff --git a/drivers/watchdog/imx_sc_wdt.c b/drivers/watchdog/imx_sc_wdt.c new file mode 100644 index 000000000000..49848b66186c --- /dev/null +++ b/drivers/watchdog/imx_sc_wdt.c | |||
@@ -0,0 +1,175 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | /* | ||
3 | * Copyright 2018-2019 NXP. | ||
4 | */ | ||
5 | |||
6 | #include <linux/arm-smccc.h> | ||
7 | #include <linux/io.h> | ||
8 | #include <linux/init.h> | ||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/moduleparam.h> | ||
12 | #include <linux/of.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/reboot.h> | ||
15 | #include <linux/watchdog.h> | ||
16 | |||
17 | #define DEFAULT_TIMEOUT 60 | ||
18 | /* | ||
19 | * Software timer tick implemented in scfw side, support 10ms to 0xffffffff ms | ||
20 | * in theory, but for normal case, 1s~128s is enough, you can change this max | ||
21 | * value in case it's not enough. | ||
22 | */ | ||
23 | #define MAX_TIMEOUT 128 | ||
24 | |||
25 | #define IMX_SIP_TIMER 0xC2000002 | ||
26 | #define IMX_SIP_TIMER_START_WDOG 0x01 | ||
27 | #define IMX_SIP_TIMER_STOP_WDOG 0x02 | ||
28 | #define IMX_SIP_TIMER_SET_WDOG_ACT 0x03 | ||
29 | #define IMX_SIP_TIMER_PING_WDOG 0x04 | ||
30 | #define IMX_SIP_TIMER_SET_TIMEOUT_WDOG 0x05 | ||
31 | #define IMX_SIP_TIMER_GET_WDOG_STAT 0x06 | ||
32 | #define IMX_SIP_TIMER_SET_PRETIME_WDOG 0x07 | ||
33 | |||
34 | #define SC_TIMER_WDOG_ACTION_PARTITION 0 | ||
35 | |||
36 | static bool nowayout = WATCHDOG_NOWAYOUT; | ||
37 | module_param(nowayout, bool, 0000); | ||
38 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | ||
39 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
40 | |||
41 | static int imx_sc_wdt_ping(struct watchdog_device *wdog) | ||
42 | { | ||
43 | struct arm_smccc_res res; | ||
44 | |||
45 | arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_PING_WDOG, | ||
46 | 0, 0, 0, 0, 0, 0, &res); | ||
47 | |||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | static int imx_sc_wdt_start(struct watchdog_device *wdog) | ||
52 | { | ||
53 | struct arm_smccc_res res; | ||
54 | |||
55 | arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_START_WDOG, | ||
56 | 0, 0, 0, 0, 0, 0, &res); | ||
57 | if (res.a0) | ||
58 | return -EACCES; | ||
59 | |||
60 | arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_SET_WDOG_ACT, | ||
61 | SC_TIMER_WDOG_ACTION_PARTITION, | ||
62 | 0, 0, 0, 0, 0, &res); | ||
63 | return res.a0 ? -EACCES : 0; | ||
64 | } | ||
65 | |||
66 | static int imx_sc_wdt_stop(struct watchdog_device *wdog) | ||
67 | { | ||
68 | struct arm_smccc_res res; | ||
69 | |||
70 | arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_STOP_WDOG, | ||
71 | 0, 0, 0, 0, 0, 0, &res); | ||
72 | |||
73 | return res.a0 ? -EACCES : 0; | ||
74 | } | ||
75 | |||
76 | static int imx_sc_wdt_set_timeout(struct watchdog_device *wdog, | ||
77 | unsigned int timeout) | ||
78 | { | ||
79 | struct arm_smccc_res res; | ||
80 | |||
81 | wdog->timeout = timeout; | ||
82 | arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_SET_TIMEOUT_WDOG, | ||
83 | timeout * 1000, 0, 0, 0, 0, 0, &res); | ||
84 | |||
85 | return res.a0 ? -EACCES : 0; | ||
86 | } | ||
87 | |||
88 | static const struct watchdog_ops imx_sc_wdt_ops = { | ||
89 | .owner = THIS_MODULE, | ||
90 | .start = imx_sc_wdt_start, | ||
91 | .stop = imx_sc_wdt_stop, | ||
92 | .ping = imx_sc_wdt_ping, | ||
93 | .set_timeout = imx_sc_wdt_set_timeout, | ||
94 | }; | ||
95 | |||
96 | static const struct watchdog_info imx_sc_wdt_info = { | ||
97 | .identity = "i.MX SC watchdog timer", | ||
98 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | | ||
99 | WDIOF_MAGICCLOSE | WDIOF_PRETIMEOUT, | ||
100 | }; | ||
101 | |||
102 | static int imx_sc_wdt_probe(struct platform_device *pdev) | ||
103 | { | ||
104 | struct device *dev = &pdev->dev; | ||
105 | struct watchdog_device *imx_sc_wdd; | ||
106 | int ret; | ||
107 | |||
108 | imx_sc_wdd = devm_kzalloc(dev, sizeof(*imx_sc_wdd), GFP_KERNEL); | ||
109 | if (!imx_sc_wdd) | ||
110 | return -ENOMEM; | ||
111 | |||
112 | platform_set_drvdata(pdev, imx_sc_wdd); | ||
113 | |||
114 | imx_sc_wdd->info = &imx_sc_wdt_info; | ||
115 | imx_sc_wdd->ops = &imx_sc_wdt_ops; | ||
116 | imx_sc_wdd->min_timeout = 1; | ||
117 | imx_sc_wdd->max_timeout = MAX_TIMEOUT; | ||
118 | imx_sc_wdd->parent = dev; | ||
119 | imx_sc_wdd->timeout = DEFAULT_TIMEOUT; | ||
120 | |||
121 | watchdog_init_timeout(imx_sc_wdd, 0, dev); | ||
122 | watchdog_stop_on_reboot(imx_sc_wdd); | ||
123 | watchdog_stop_on_unregister(imx_sc_wdd); | ||
124 | |||
125 | ret = devm_watchdog_register_device(dev, imx_sc_wdd); | ||
126 | if (ret) { | ||
127 | dev_err(dev, "Failed to register watchdog device\n"); | ||
128 | return ret; | ||
129 | } | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static int __maybe_unused imx_sc_wdt_suspend(struct device *dev) | ||
135 | { | ||
136 | struct watchdog_device *imx_sc_wdd = dev_get_drvdata(dev); | ||
137 | |||
138 | if (watchdog_active(imx_sc_wdd)) | ||
139 | imx_sc_wdt_stop(imx_sc_wdd); | ||
140 | |||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static int __maybe_unused imx_sc_wdt_resume(struct device *dev) | ||
145 | { | ||
146 | struct watchdog_device *imx_sc_wdd = dev_get_drvdata(dev); | ||
147 | |||
148 | if (watchdog_active(imx_sc_wdd)) | ||
149 | imx_sc_wdt_start(imx_sc_wdd); | ||
150 | |||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | static SIMPLE_DEV_PM_OPS(imx_sc_wdt_pm_ops, | ||
155 | imx_sc_wdt_suspend, imx_sc_wdt_resume); | ||
156 | |||
157 | static const struct of_device_id imx_sc_wdt_dt_ids[] = { | ||
158 | { .compatible = "fsl,imx-sc-wdt", }, | ||
159 | { /* sentinel */ } | ||
160 | }; | ||
161 | MODULE_DEVICE_TABLE(of, imx_sc_wdt_dt_ids); | ||
162 | |||
163 | static struct platform_driver imx_sc_wdt_driver = { | ||
164 | .probe = imx_sc_wdt_probe, | ||
165 | .driver = { | ||
166 | .name = "imx-sc-wdt", | ||
167 | .of_match_table = imx_sc_wdt_dt_ids, | ||
168 | .pm = &imx_sc_wdt_pm_ops, | ||
169 | }, | ||
170 | }; | ||
171 | module_platform_driver(imx_sc_wdt_driver); | ||
172 | |||
173 | MODULE_AUTHOR("Robin Gong <yibin.gong@nxp.com>"); | ||
174 | MODULE_DESCRIPTION("NXP i.MX system controller watchdog driver"); | ||
175 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/watchdog/intel-mid_wdt.c b/drivers/watchdog/intel-mid_wdt.c index 72c108a12c19..6cf7cc1ff615 100644 --- a/drivers/watchdog/intel-mid_wdt.c +++ b/drivers/watchdog/intel-mid_wdt.c | |||
@@ -110,12 +110,13 @@ static const struct watchdog_ops mid_wdt_ops = { | |||
110 | 110 | ||
111 | static int mid_wdt_probe(struct platform_device *pdev) | 111 | static int mid_wdt_probe(struct platform_device *pdev) |
112 | { | 112 | { |
113 | struct device *dev = &pdev->dev; | ||
113 | struct watchdog_device *wdt_dev; | 114 | struct watchdog_device *wdt_dev; |
114 | struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data; | 115 | struct intel_mid_wdt_pdata *pdata = dev->platform_data; |
115 | int ret; | 116 | int ret; |
116 | 117 | ||
117 | if (!pdata) { | 118 | if (!pdata) { |
118 | dev_err(&pdev->dev, "missing platform data\n"); | 119 | dev_err(dev, "missing platform data\n"); |
119 | return -EINVAL; | 120 | return -EINVAL; |
120 | } | 121 | } |
121 | 122 | ||
@@ -125,7 +126,7 @@ static int mid_wdt_probe(struct platform_device *pdev) | |||
125 | return ret; | 126 | return ret; |
126 | } | 127 | } |
127 | 128 | ||
128 | wdt_dev = devm_kzalloc(&pdev->dev, sizeof(*wdt_dev), GFP_KERNEL); | 129 | wdt_dev = devm_kzalloc(dev, sizeof(*wdt_dev), GFP_KERNEL); |
129 | if (!wdt_dev) | 130 | if (!wdt_dev) |
130 | return -ENOMEM; | 131 | return -ENOMEM; |
131 | 132 | ||
@@ -134,16 +135,15 @@ static int mid_wdt_probe(struct platform_device *pdev) | |||
134 | wdt_dev->min_timeout = MID_WDT_TIMEOUT_MIN; | 135 | wdt_dev->min_timeout = MID_WDT_TIMEOUT_MIN; |
135 | wdt_dev->max_timeout = MID_WDT_TIMEOUT_MAX; | 136 | wdt_dev->max_timeout = MID_WDT_TIMEOUT_MAX; |
136 | wdt_dev->timeout = MID_WDT_DEFAULT_TIMEOUT; | 137 | wdt_dev->timeout = MID_WDT_DEFAULT_TIMEOUT; |
137 | wdt_dev->parent = &pdev->dev; | 138 | wdt_dev->parent = dev; |
138 | 139 | ||
139 | watchdog_set_drvdata(wdt_dev, &pdev->dev); | 140 | watchdog_set_drvdata(wdt_dev, dev); |
140 | 141 | ||
141 | ret = devm_request_irq(&pdev->dev, pdata->irq, mid_wdt_irq, | 142 | ret = devm_request_irq(dev, pdata->irq, mid_wdt_irq, |
142 | IRQF_SHARED | IRQF_NO_SUSPEND, "watchdog", | 143 | IRQF_SHARED | IRQF_NO_SUSPEND, "watchdog", |
143 | wdt_dev); | 144 | wdt_dev); |
144 | if (ret) { | 145 | if (ret) { |
145 | dev_err(&pdev->dev, "error requesting warning irq %d\n", | 146 | dev_err(dev, "error requesting warning irq %d\n", pdata->irq); |
146 | pdata->irq); | ||
147 | return ret; | 147 | return ret; |
148 | } | 148 | } |
149 | 149 | ||
@@ -163,13 +163,13 @@ static int mid_wdt_probe(struct platform_device *pdev) | |||
163 | /* Make sure the watchdog is serviced */ | 163 | /* Make sure the watchdog is serviced */ |
164 | set_bit(WDOG_HW_RUNNING, &wdt_dev->status); | 164 | set_bit(WDOG_HW_RUNNING, &wdt_dev->status); |
165 | 165 | ||
166 | ret = devm_watchdog_register_device(&pdev->dev, wdt_dev); | 166 | ret = devm_watchdog_register_device(dev, wdt_dev); |
167 | if (ret) { | 167 | if (ret) { |
168 | dev_err(&pdev->dev, "error registering watchdog device\n"); | 168 | dev_err(dev, "error registering watchdog device\n"); |
169 | return ret; | 169 | return ret; |
170 | } | 170 | } |
171 | 171 | ||
172 | dev_info(&pdev->dev, "Intel MID watchdog device probed\n"); | 172 | dev_info(dev, "Intel MID watchdog device probed\n"); |
173 | 173 | ||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
diff --git a/drivers/watchdog/intel_scu_watchdog.c b/drivers/watchdog/intel_scu_watchdog.c index 3181a72c7ddf..f7baf75d38c0 100644 --- a/drivers/watchdog/intel_scu_watchdog.c +++ b/drivers/watchdog/intel_scu_watchdog.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 25 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
26 | 26 | ||
27 | #include <linux/compiler.h> | 27 | #include <linux/compiler.h> |
28 | #include <linux/module.h> | ||
29 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
30 | #include <linux/moduleparam.h> | 29 | #include <linux/moduleparam.h> |
31 | #include <linux/types.h> | 30 | #include <linux/types.h> |
@@ -224,7 +223,7 @@ static int intel_scu_set_heartbeat(u32 t) | |||
224 | watchdog_device.timer_tbl_ptr->freq_hz); | 223 | watchdog_device.timer_tbl_ptr->freq_hz); |
225 | pr_debug("set_heartbeat: timer_set is %x (hex)\n", | 224 | pr_debug("set_heartbeat: timer_set is %x (hex)\n", |
226 | watchdog_device.timer_set); | 225 | watchdog_device.timer_set); |
227 | pr_debug("set_hearbeat: timer_margin is %x (hex)\n", timer_margin); | 226 | pr_debug("set_heartbeat: timer_margin is %x (hex)\n", timer_margin); |
228 | pr_debug("set_heartbeat: threshold is %x (hex)\n", | 227 | pr_debug("set_heartbeat: threshold is %x (hex)\n", |
229 | watchdog_device.threshold); | 228 | watchdog_device.threshold); |
230 | pr_debug("set_heartbeat: soft_threshold is %x (hex)\n", | 229 | pr_debug("set_heartbeat: soft_threshold is %x (hex)\n", |
@@ -545,21 +544,4 @@ register_reboot_error: | |||
545 | iounmap(watchdog_device.timer_load_count_addr); | 544 | iounmap(watchdog_device.timer_load_count_addr); |
546 | return ret; | 545 | return ret; |
547 | } | 546 | } |
548 | |||
549 | static void __exit intel_scu_watchdog_exit(void) | ||
550 | { | ||
551 | |||
552 | misc_deregister(&watchdog_device.miscdev); | ||
553 | unregister_reboot_notifier(&watchdog_device.intel_scu_notifier); | ||
554 | /* disable the timer */ | ||
555 | iowrite32(0x00000002, watchdog_device.timer_control_addr); | ||
556 | iounmap(watchdog_device.timer_load_count_addr); | ||
557 | } | ||
558 | |||
559 | late_initcall(intel_scu_watchdog_init); | 547 | late_initcall(intel_scu_watchdog_init); |
560 | module_exit(intel_scu_watchdog_exit); | ||
561 | |||
562 | MODULE_AUTHOR("Intel Corporation"); | ||
563 | MODULE_DESCRIPTION("Intel SCU Watchdog Device Driver"); | ||
564 | MODULE_LICENSE("GPL"); | ||
565 | MODULE_VERSION(WDT_VER); | ||
diff --git a/drivers/watchdog/jz4740_wdt.c b/drivers/watchdog/jz4740_wdt.c index ec4d99a830ba..d1bc7cbd4f2b 100644 --- a/drivers/watchdog/jz4740_wdt.c +++ b/drivers/watchdog/jz4740_wdt.c | |||
@@ -163,12 +163,12 @@ MODULE_DEVICE_TABLE(of, jz4740_wdt_of_matches); | |||
163 | 163 | ||
164 | static int jz4740_wdt_probe(struct platform_device *pdev) | 164 | static int jz4740_wdt_probe(struct platform_device *pdev) |
165 | { | 165 | { |
166 | struct device *dev = &pdev->dev; | ||
166 | struct jz4740_wdt_drvdata *drvdata; | 167 | struct jz4740_wdt_drvdata *drvdata; |
167 | struct watchdog_device *jz4740_wdt; | 168 | struct watchdog_device *jz4740_wdt; |
168 | struct resource *res; | ||
169 | int ret; | 169 | int ret; |
170 | 170 | ||
171 | drvdata = devm_kzalloc(&pdev->dev, sizeof(struct jz4740_wdt_drvdata), | 171 | drvdata = devm_kzalloc(dev, sizeof(struct jz4740_wdt_drvdata), |
172 | GFP_KERNEL); | 172 | GFP_KERNEL); |
173 | if (!drvdata) | 173 | if (!drvdata) |
174 | return -ENOMEM; | 174 | return -ENOMEM; |
@@ -182,27 +182,24 @@ static int jz4740_wdt_probe(struct platform_device *pdev) | |||
182 | jz4740_wdt->timeout = heartbeat; | 182 | jz4740_wdt->timeout = heartbeat; |
183 | jz4740_wdt->min_timeout = 1; | 183 | jz4740_wdt->min_timeout = 1; |
184 | jz4740_wdt->max_timeout = MAX_HEARTBEAT; | 184 | jz4740_wdt->max_timeout = MAX_HEARTBEAT; |
185 | jz4740_wdt->parent = &pdev->dev; | 185 | jz4740_wdt->parent = dev; |
186 | watchdog_set_nowayout(jz4740_wdt, nowayout); | 186 | watchdog_set_nowayout(jz4740_wdt, nowayout); |
187 | watchdog_set_drvdata(jz4740_wdt, drvdata); | 187 | watchdog_set_drvdata(jz4740_wdt, drvdata); |
188 | 188 | ||
189 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 189 | drvdata->base = devm_platform_ioremap_resource(pdev, 0); |
190 | drvdata->base = devm_ioremap_resource(&pdev->dev, res); | ||
191 | if (IS_ERR(drvdata->base)) | 190 | if (IS_ERR(drvdata->base)) |
192 | return PTR_ERR(drvdata->base); | 191 | return PTR_ERR(drvdata->base); |
193 | 192 | ||
194 | drvdata->rtc_clk = devm_clk_get(&pdev->dev, "rtc"); | 193 | drvdata->rtc_clk = devm_clk_get(dev, "rtc"); |
195 | if (IS_ERR(drvdata->rtc_clk)) { | 194 | if (IS_ERR(drvdata->rtc_clk)) { |
196 | dev_err(&pdev->dev, "cannot find RTC clock\n"); | 195 | dev_err(dev, "cannot find RTC clock\n"); |
197 | return PTR_ERR(drvdata->rtc_clk); | 196 | return PTR_ERR(drvdata->rtc_clk); |
198 | } | 197 | } |
199 | 198 | ||
200 | ret = devm_watchdog_register_device(&pdev->dev, &drvdata->wdt); | 199 | ret = devm_watchdog_register_device(dev, &drvdata->wdt); |
201 | if (ret < 0) | 200 | if (ret < 0) |
202 | return ret; | 201 | return ret; |
203 | 202 | ||
204 | platform_set_drvdata(pdev, drvdata); | ||
205 | |||
206 | return 0; | 203 | return 0; |
207 | } | 204 | } |
208 | 205 | ||
diff --git a/drivers/watchdog/kempld_wdt.c b/drivers/watchdog/kempld_wdt.c index e268add43010..543eb0f27a42 100644 --- a/drivers/watchdog/kempld_wdt.c +++ b/drivers/watchdog/kempld_wdt.c | |||
@@ -467,7 +467,7 @@ static int kempld_wdt_probe(struct platform_device *pdev) | |||
467 | KEMPLD_WDT_CFG_GLOBAL_LOCK)) { | 467 | KEMPLD_WDT_CFG_GLOBAL_LOCK)) { |
468 | if (!nowayout) | 468 | if (!nowayout) |
469 | dev_warn(dev, | 469 | dev_warn(dev, |
470 | "Forcing nowayout - watchdog lock enabled!\n"); | 470 | "Forcing nowayout - watchdog lock enabled!\n"); |
471 | nowayout = true; | 471 | nowayout = true; |
472 | } | 472 | } |
473 | 473 | ||
@@ -492,7 +492,9 @@ static int kempld_wdt_probe(struct platform_device *pdev) | |||
492 | } | 492 | } |
493 | 493 | ||
494 | platform_set_drvdata(pdev, wdt_data); | 494 | platform_set_drvdata(pdev, wdt_data); |
495 | ret = watchdog_register_device(wdd); | 495 | watchdog_stop_on_reboot(wdd); |
496 | watchdog_stop_on_unregister(wdd); | ||
497 | ret = devm_watchdog_register_device(dev, wdd); | ||
496 | if (ret) | 498 | if (ret) |
497 | return ret; | 499 | return ret; |
498 | 500 | ||
@@ -501,26 +503,6 @@ static int kempld_wdt_probe(struct platform_device *pdev) | |||
501 | return 0; | 503 | return 0; |
502 | } | 504 | } |
503 | 505 | ||
504 | static void kempld_wdt_shutdown(struct platform_device *pdev) | ||
505 | { | ||
506 | struct kempld_wdt_data *wdt_data = platform_get_drvdata(pdev); | ||
507 | |||
508 | kempld_wdt_stop(&wdt_data->wdd); | ||
509 | } | ||
510 | |||
511 | static int kempld_wdt_remove(struct platform_device *pdev) | ||
512 | { | ||
513 | struct kempld_wdt_data *wdt_data = platform_get_drvdata(pdev); | ||
514 | struct watchdog_device *wdd = &wdt_data->wdd; | ||
515 | int ret = 0; | ||
516 | |||
517 | if (!nowayout) | ||
518 | ret = kempld_wdt_stop(wdd); | ||
519 | watchdog_unregister_device(wdd); | ||
520 | |||
521 | return ret; | ||
522 | } | ||
523 | |||
524 | #ifdef CONFIG_PM | 506 | #ifdef CONFIG_PM |
525 | /* Disable watchdog if it is active during suspend */ | 507 | /* Disable watchdog if it is active during suspend */ |
526 | static int kempld_wdt_suspend(struct platform_device *pdev, | 508 | static int kempld_wdt_suspend(struct platform_device *pdev, |
@@ -567,8 +549,6 @@ static struct platform_driver kempld_wdt_driver = { | |||
567 | .name = "kempld-wdt", | 549 | .name = "kempld-wdt", |
568 | }, | 550 | }, |
569 | .probe = kempld_wdt_probe, | 551 | .probe = kempld_wdt_probe, |
570 | .remove = kempld_wdt_remove, | ||
571 | .shutdown = kempld_wdt_shutdown, | ||
572 | .suspend = kempld_wdt_suspend, | 552 | .suspend = kempld_wdt_suspend, |
573 | .resume = kempld_wdt_resume, | 553 | .resume = kempld_wdt_resume, |
574 | }; | 554 | }; |
diff --git a/drivers/watchdog/lantiq_wdt.c b/drivers/watchdog/lantiq_wdt.c index 83da84d6074b..4caf02ba5d49 100644 --- a/drivers/watchdog/lantiq_wdt.c +++ b/drivers/watchdog/lantiq_wdt.c | |||
@@ -203,7 +203,6 @@ static int ltq_wdt_probe(struct platform_device *pdev) | |||
203 | struct device *dev = &pdev->dev; | 203 | struct device *dev = &pdev->dev; |
204 | struct ltq_wdt_priv *priv; | 204 | struct ltq_wdt_priv *priv; |
205 | struct watchdog_device *wdt; | 205 | struct watchdog_device *wdt; |
206 | struct resource *res; | ||
207 | struct clk *clk; | 206 | struct clk *clk; |
208 | const struct ltq_wdt_hw *ltq_wdt_hw; | 207 | const struct ltq_wdt_hw *ltq_wdt_hw; |
209 | int ret; | 208 | int ret; |
@@ -213,8 +212,7 @@ static int ltq_wdt_probe(struct platform_device *pdev) | |||
213 | if (!priv) | 212 | if (!priv) |
214 | return -ENOMEM; | 213 | return -ENOMEM; |
215 | 214 | ||
216 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 215 | priv->membase = devm_platform_ioremap_resource(pdev, 0); |
217 | priv->membase = devm_ioremap_resource(dev, res); | ||
218 | if (IS_ERR(priv->membase)) | 216 | if (IS_ERR(priv->membase)) |
219 | return PTR_ERR(priv->membase); | 217 | return PTR_ERR(priv->membase); |
220 | 218 | ||
diff --git a/drivers/watchdog/loongson1_wdt.c b/drivers/watchdog/loongson1_wdt.c index 3aee50c64a36..d8075e2affa7 100644 --- a/drivers/watchdog/loongson1_wdt.c +++ b/drivers/watchdog/loongson1_wdt.c | |||
@@ -83,38 +83,44 @@ static const struct watchdog_ops ls1x_wdt_ops = { | |||
83 | .set_timeout = ls1x_wdt_set_timeout, | 83 | .set_timeout = ls1x_wdt_set_timeout, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | static void ls1x_clk_disable_unprepare(void *data) | ||
87 | { | ||
88 | clk_disable_unprepare(data); | ||
89 | } | ||
90 | |||
86 | static int ls1x_wdt_probe(struct platform_device *pdev) | 91 | static int ls1x_wdt_probe(struct platform_device *pdev) |
87 | { | 92 | { |
93 | struct device *dev = &pdev->dev; | ||
88 | struct ls1x_wdt_drvdata *drvdata; | 94 | struct ls1x_wdt_drvdata *drvdata; |
89 | struct watchdog_device *ls1x_wdt; | 95 | struct watchdog_device *ls1x_wdt; |
90 | unsigned long clk_rate; | 96 | unsigned long clk_rate; |
91 | struct resource *res; | ||
92 | int err; | 97 | int err; |
93 | 98 | ||
94 | drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); | 99 | drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); |
95 | if (!drvdata) | 100 | if (!drvdata) |
96 | return -ENOMEM; | 101 | return -ENOMEM; |
97 | 102 | ||
98 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 103 | drvdata->base = devm_platform_ioremap_resource(pdev, 0); |
99 | drvdata->base = devm_ioremap_resource(&pdev->dev, res); | ||
100 | if (IS_ERR(drvdata->base)) | 104 | if (IS_ERR(drvdata->base)) |
101 | return PTR_ERR(drvdata->base); | 105 | return PTR_ERR(drvdata->base); |
102 | 106 | ||
103 | drvdata->clk = devm_clk_get(&pdev->dev, pdev->name); | 107 | drvdata->clk = devm_clk_get(dev, pdev->name); |
104 | if (IS_ERR(drvdata->clk)) | 108 | if (IS_ERR(drvdata->clk)) |
105 | return PTR_ERR(drvdata->clk); | 109 | return PTR_ERR(drvdata->clk); |
106 | 110 | ||
107 | err = clk_prepare_enable(drvdata->clk); | 111 | err = clk_prepare_enable(drvdata->clk); |
108 | if (err) { | 112 | if (err) { |
109 | dev_err(&pdev->dev, "clk enable failed\n"); | 113 | dev_err(dev, "clk enable failed\n"); |
110 | return err; | 114 | return err; |
111 | } | 115 | } |
116 | err = devm_add_action_or_reset(dev, ls1x_clk_disable_unprepare, | ||
117 | drvdata->clk); | ||
118 | if (err) | ||
119 | return err; | ||
112 | 120 | ||
113 | clk_rate = clk_get_rate(drvdata->clk); | 121 | clk_rate = clk_get_rate(drvdata->clk); |
114 | if (!clk_rate) { | 122 | if (!clk_rate) |
115 | err = -EINVAL; | 123 | return -EINVAL; |
116 | goto err0; | ||
117 | } | ||
118 | drvdata->clk_rate = clk_rate; | 124 | drvdata->clk_rate = clk_rate; |
119 | 125 | ||
120 | ls1x_wdt = &drvdata->wdt; | 126 | ls1x_wdt = &drvdata->wdt; |
@@ -123,41 +129,27 @@ static int ls1x_wdt_probe(struct platform_device *pdev) | |||
123 | ls1x_wdt->timeout = DEFAULT_HEARTBEAT; | 129 | ls1x_wdt->timeout = DEFAULT_HEARTBEAT; |
124 | ls1x_wdt->min_timeout = 1; | 130 | ls1x_wdt->min_timeout = 1; |
125 | ls1x_wdt->max_hw_heartbeat_ms = U32_MAX / clk_rate * 1000; | 131 | ls1x_wdt->max_hw_heartbeat_ms = U32_MAX / clk_rate * 1000; |
126 | ls1x_wdt->parent = &pdev->dev; | 132 | ls1x_wdt->parent = dev; |
127 | 133 | ||
128 | watchdog_init_timeout(ls1x_wdt, heartbeat, &pdev->dev); | 134 | watchdog_init_timeout(ls1x_wdt, heartbeat, dev); |
129 | watchdog_set_nowayout(ls1x_wdt, nowayout); | 135 | watchdog_set_nowayout(ls1x_wdt, nowayout); |
130 | watchdog_set_drvdata(ls1x_wdt, drvdata); | 136 | watchdog_set_drvdata(ls1x_wdt, drvdata); |
131 | 137 | ||
132 | err = watchdog_register_device(&drvdata->wdt); | 138 | err = devm_watchdog_register_device(dev, &drvdata->wdt); |
133 | if (err) { | 139 | if (err) { |
134 | dev_err(&pdev->dev, "failed to register watchdog device\n"); | 140 | dev_err(dev, "failed to register watchdog device\n"); |
135 | goto err0; | 141 | return err; |
136 | } | 142 | } |
137 | 143 | ||
138 | platform_set_drvdata(pdev, drvdata); | 144 | platform_set_drvdata(pdev, drvdata); |
139 | 145 | ||
140 | dev_info(&pdev->dev, "Loongson1 Watchdog driver registered\n"); | 146 | dev_info(dev, "Loongson1 Watchdog driver registered\n"); |
141 | |||
142 | return 0; | ||
143 | err0: | ||
144 | clk_disable_unprepare(drvdata->clk); | ||
145 | return err; | ||
146 | } | ||
147 | |||
148 | static int ls1x_wdt_remove(struct platform_device *pdev) | ||
149 | { | ||
150 | struct ls1x_wdt_drvdata *drvdata = platform_get_drvdata(pdev); | ||
151 | |||
152 | watchdog_unregister_device(&drvdata->wdt); | ||
153 | clk_disable_unprepare(drvdata->clk); | ||
154 | 147 | ||
155 | return 0; | 148 | return 0; |
156 | } | 149 | } |
157 | 150 | ||
158 | static struct platform_driver ls1x_wdt_driver = { | 151 | static struct platform_driver ls1x_wdt_driver = { |
159 | .probe = ls1x_wdt_probe, | 152 | .probe = ls1x_wdt_probe, |
160 | .remove = ls1x_wdt_remove, | ||
161 | .driver = { | 153 | .driver = { |
162 | .name = "ls1x-wdt", | 154 | .name = "ls1x-wdt", |
163 | }, | 155 | }, |
diff --git a/drivers/watchdog/lpc18xx_wdt.c b/drivers/watchdog/lpc18xx_wdt.c index 331cadb459ac..0e82abd71d35 100644 --- a/drivers/watchdog/lpc18xx_wdt.c +++ b/drivers/watchdog/lpc18xx_wdt.c | |||
@@ -200,19 +200,22 @@ static const struct watchdog_ops lpc18xx_wdt_ops = { | |||
200 | .restart = lpc18xx_wdt_restart, | 200 | .restart = lpc18xx_wdt_restart, |
201 | }; | 201 | }; |
202 | 202 | ||
203 | static void lpc18xx_clk_disable_unprepare(void *data) | ||
204 | { | ||
205 | clk_disable_unprepare(data); | ||
206 | } | ||
207 | |||
203 | static int lpc18xx_wdt_probe(struct platform_device *pdev) | 208 | static int lpc18xx_wdt_probe(struct platform_device *pdev) |
204 | { | 209 | { |
205 | struct lpc18xx_wdt_dev *lpc18xx_wdt; | 210 | struct lpc18xx_wdt_dev *lpc18xx_wdt; |
206 | struct device *dev = &pdev->dev; | 211 | struct device *dev = &pdev->dev; |
207 | struct resource *res; | ||
208 | int ret; | 212 | int ret; |
209 | 213 | ||
210 | lpc18xx_wdt = devm_kzalloc(dev, sizeof(*lpc18xx_wdt), GFP_KERNEL); | 214 | lpc18xx_wdt = devm_kzalloc(dev, sizeof(*lpc18xx_wdt), GFP_KERNEL); |
211 | if (!lpc18xx_wdt) | 215 | if (!lpc18xx_wdt) |
212 | return -ENOMEM; | 216 | return -ENOMEM; |
213 | 217 | ||
214 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 218 | lpc18xx_wdt->base = devm_platform_ioremap_resource(pdev, 0); |
215 | lpc18xx_wdt->base = devm_ioremap_resource(dev, res); | ||
216 | if (IS_ERR(lpc18xx_wdt->base)) | 219 | if (IS_ERR(lpc18xx_wdt->base)) |
217 | return PTR_ERR(lpc18xx_wdt->base); | 220 | return PTR_ERR(lpc18xx_wdt->base); |
218 | 221 | ||
@@ -233,19 +236,26 @@ static int lpc18xx_wdt_probe(struct platform_device *pdev) | |||
233 | dev_err(dev, "could not prepare or enable sys clock\n"); | 236 | dev_err(dev, "could not prepare or enable sys clock\n"); |
234 | return ret; | 237 | return ret; |
235 | } | 238 | } |
239 | ret = devm_add_action_or_reset(dev, lpc18xx_clk_disable_unprepare, | ||
240 | lpc18xx_wdt->reg_clk); | ||
241 | if (ret) | ||
242 | return ret; | ||
236 | 243 | ||
237 | ret = clk_prepare_enable(lpc18xx_wdt->wdt_clk); | 244 | ret = clk_prepare_enable(lpc18xx_wdt->wdt_clk); |
238 | if (ret) { | 245 | if (ret) { |
239 | dev_err(dev, "could not prepare or enable wdt clock\n"); | 246 | dev_err(dev, "could not prepare or enable wdt clock\n"); |
240 | goto disable_reg_clk; | 247 | return ret; |
241 | } | 248 | } |
249 | ret = devm_add_action_or_reset(dev, lpc18xx_clk_disable_unprepare, | ||
250 | lpc18xx_wdt->wdt_clk); | ||
251 | if (ret) | ||
252 | return ret; | ||
242 | 253 | ||
243 | /* We use the clock rate to calculate timeouts */ | 254 | /* We use the clock rate to calculate timeouts */ |
244 | lpc18xx_wdt->clk_rate = clk_get_rate(lpc18xx_wdt->wdt_clk); | 255 | lpc18xx_wdt->clk_rate = clk_get_rate(lpc18xx_wdt->wdt_clk); |
245 | if (lpc18xx_wdt->clk_rate == 0) { | 256 | if (lpc18xx_wdt->clk_rate == 0) { |
246 | dev_err(dev, "failed to get clock rate\n"); | 257 | dev_err(dev, "failed to get clock rate\n"); |
247 | ret = -EINVAL; | 258 | return -EINVAL; |
248 | goto disable_wdt_clk; | ||
249 | } | 259 | } |
250 | 260 | ||
251 | lpc18xx_wdt->wdt_dev.info = &lpc18xx_wdt_info; | 261 | lpc18xx_wdt->wdt_dev.info = &lpc18xx_wdt_info; |
@@ -276,24 +286,8 @@ static int lpc18xx_wdt_probe(struct platform_device *pdev) | |||
276 | 286 | ||
277 | platform_set_drvdata(pdev, lpc18xx_wdt); | 287 | platform_set_drvdata(pdev, lpc18xx_wdt); |
278 | 288 | ||
279 | ret = watchdog_register_device(&lpc18xx_wdt->wdt_dev); | 289 | watchdog_stop_on_reboot(&lpc18xx_wdt->wdt_dev); |
280 | if (ret) | 290 | return devm_watchdog_register_device(dev, &lpc18xx_wdt->wdt_dev); |
281 | goto disable_wdt_clk; | ||
282 | |||
283 | return 0; | ||
284 | |||
285 | disable_wdt_clk: | ||
286 | clk_disable_unprepare(lpc18xx_wdt->wdt_clk); | ||
287 | disable_reg_clk: | ||
288 | clk_disable_unprepare(lpc18xx_wdt->reg_clk); | ||
289 | return ret; | ||
290 | } | ||
291 | |||
292 | static void lpc18xx_wdt_shutdown(struct platform_device *pdev) | ||
293 | { | ||
294 | struct lpc18xx_wdt_dev *lpc18xx_wdt = platform_get_drvdata(pdev); | ||
295 | |||
296 | lpc18xx_wdt_stop(&lpc18xx_wdt->wdt_dev); | ||
297 | } | 291 | } |
298 | 292 | ||
299 | static int lpc18xx_wdt_remove(struct platform_device *pdev) | 293 | static int lpc18xx_wdt_remove(struct platform_device *pdev) |
@@ -303,10 +297,6 @@ static int lpc18xx_wdt_remove(struct platform_device *pdev) | |||
303 | dev_warn(&pdev->dev, "I quit now, hardware will probably reboot!\n"); | 297 | dev_warn(&pdev->dev, "I quit now, hardware will probably reboot!\n"); |
304 | del_timer(&lpc18xx_wdt->timer); | 298 | del_timer(&lpc18xx_wdt->timer); |
305 | 299 | ||
306 | watchdog_unregister_device(&lpc18xx_wdt->wdt_dev); | ||
307 | clk_disable_unprepare(lpc18xx_wdt->wdt_clk); | ||
308 | clk_disable_unprepare(lpc18xx_wdt->reg_clk); | ||
309 | |||
310 | return 0; | 300 | return 0; |
311 | } | 301 | } |
312 | 302 | ||
@@ -323,7 +313,6 @@ static struct platform_driver lpc18xx_wdt_driver = { | |||
323 | }, | 313 | }, |
324 | .probe = lpc18xx_wdt_probe, | 314 | .probe = lpc18xx_wdt_probe, |
325 | .remove = lpc18xx_wdt_remove, | 315 | .remove = lpc18xx_wdt_remove, |
326 | .shutdown = lpc18xx_wdt_shutdown, | ||
327 | }; | 316 | }; |
328 | module_platform_driver(lpc18xx_wdt_driver); | 317 | module_platform_driver(lpc18xx_wdt_driver); |
329 | 318 | ||
diff --git a/drivers/watchdog/machzwd.c b/drivers/watchdog/machzwd.c index 53759415cf06..c0c9e948adbc 100644 --- a/drivers/watchdog/machzwd.c +++ b/drivers/watchdog/machzwd.c | |||
@@ -177,6 +177,7 @@ static inline void zf_set_timer(unsigned short new, unsigned char n) | |||
177 | switch (n) { | 177 | switch (n) { |
178 | case WD1: | 178 | case WD1: |
179 | zf_writew(COUNTER_1, new); | 179 | zf_writew(COUNTER_1, new); |
180 | /* fall through */ | ||
180 | case WD2: | 181 | case WD2: |
181 | zf_writeb(COUNTER_2, new > 0xff ? 0xff : new); | 182 | zf_writeb(COUNTER_2, new > 0xff ? 0xff : new); |
182 | default: | 183 | default: |
@@ -318,7 +319,7 @@ static long zf_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
318 | case WDIOC_GETBOOTSTATUS: | 319 | case WDIOC_GETBOOTSTATUS: |
319 | return put_user(0, p); | 320 | return put_user(0, p); |
320 | case WDIOC_KEEPALIVE: | 321 | case WDIOC_KEEPALIVE: |
321 | zf_ping(0); | 322 | zf_ping(NULL); |
322 | break; | 323 | break; |
323 | default: | 324 | default: |
324 | return -ENOTTY; | 325 | return -ENOTTY; |
diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c index bf6a068245ba..3a899628a834 100644 --- a/drivers/watchdog/max63xx_wdt.c +++ b/drivers/watchdog/max63xx_wdt.c | |||
@@ -187,9 +187,7 @@ static void max63xx_mmap_set(struct max63xx_wdt *wdt, u8 set) | |||
187 | 187 | ||
188 | static int max63xx_mmap_init(struct platform_device *p, struct max63xx_wdt *wdt) | 188 | static int max63xx_mmap_init(struct platform_device *p, struct max63xx_wdt *wdt) |
189 | { | 189 | { |
190 | struct resource *mem = platform_get_resource(p, IORESOURCE_MEM, 0); | 190 | wdt->base = devm_platform_ioremap_resource(p, 0); |
191 | |||
192 | wdt->base = devm_ioremap_resource(&p->dev, mem); | ||
193 | if (IS_ERR(wdt->base)) | 191 | if (IS_ERR(wdt->base)) |
194 | return PTR_ERR(wdt->base); | 192 | return PTR_ERR(wdt->base); |
195 | 193 | ||
@@ -202,11 +200,12 @@ static int max63xx_mmap_init(struct platform_device *p, struct max63xx_wdt *wdt) | |||
202 | 200 | ||
203 | static int max63xx_wdt_probe(struct platform_device *pdev) | 201 | static int max63xx_wdt_probe(struct platform_device *pdev) |
204 | { | 202 | { |
203 | struct device *dev = &pdev->dev; | ||
205 | struct max63xx_wdt *wdt; | 204 | struct max63xx_wdt *wdt; |
206 | struct max63xx_timeout *table; | 205 | struct max63xx_timeout *table; |
207 | int err; | 206 | int err; |
208 | 207 | ||
209 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 208 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
210 | if (!wdt) | 209 | if (!wdt) |
211 | return -ENOMEM; | 210 | return -ENOMEM; |
212 | 211 | ||
@@ -217,7 +216,7 @@ static int max63xx_wdt_probe(struct platform_device *pdev) | |||
217 | 216 | ||
218 | wdt->timeout = max63xx_select_timeout(table, heartbeat); | 217 | wdt->timeout = max63xx_select_timeout(table, heartbeat); |
219 | if (!wdt->timeout) { | 218 | if (!wdt->timeout) { |
220 | dev_err(&pdev->dev, "unable to satisfy %ds heartbeat request\n", | 219 | dev_err(dev, "unable to satisfy %ds heartbeat request\n", |
221 | heartbeat); | 220 | heartbeat); |
222 | return -EINVAL; | 221 | return -EINVAL; |
223 | } | 222 | } |
@@ -229,30 +228,22 @@ static int max63xx_wdt_probe(struct platform_device *pdev) | |||
229 | platform_set_drvdata(pdev, &wdt->wdd); | 228 | platform_set_drvdata(pdev, &wdt->wdd); |
230 | watchdog_set_drvdata(&wdt->wdd, wdt); | 229 | watchdog_set_drvdata(&wdt->wdd, wdt); |
231 | 230 | ||
232 | wdt->wdd.parent = &pdev->dev; | 231 | wdt->wdd.parent = dev; |
233 | wdt->wdd.timeout = wdt->timeout->twd; | 232 | wdt->wdd.timeout = wdt->timeout->twd; |
234 | wdt->wdd.info = &max63xx_wdt_info; | 233 | wdt->wdd.info = &max63xx_wdt_info; |
235 | wdt->wdd.ops = &max63xx_wdt_ops; | 234 | wdt->wdd.ops = &max63xx_wdt_ops; |
236 | 235 | ||
237 | watchdog_set_nowayout(&wdt->wdd, nowayout); | 236 | watchdog_set_nowayout(&wdt->wdd, nowayout); |
238 | 237 | ||
239 | err = watchdog_register_device(&wdt->wdd); | 238 | err = devm_watchdog_register_device(dev, &wdt->wdd); |
240 | if (err) | 239 | if (err) |
241 | return err; | 240 | return err; |
242 | 241 | ||
243 | dev_info(&pdev->dev, "using %ds heartbeat with %ds initial delay\n", | 242 | dev_info(dev, "using %ds heartbeat with %ds initial delay\n", |
244 | wdt->timeout->twd, wdt->timeout->tdelay); | 243 | wdt->timeout->twd, wdt->timeout->tdelay); |
245 | return 0; | 244 | return 0; |
246 | } | 245 | } |
247 | 246 | ||
248 | static int max63xx_wdt_remove(struct platform_device *pdev) | ||
249 | { | ||
250 | struct watchdog_device *wdd = platform_get_drvdata(pdev); | ||
251 | |||
252 | watchdog_unregister_device(wdd); | ||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | static const struct platform_device_id max63xx_id_table[] = { | 247 | static const struct platform_device_id max63xx_id_table[] = { |
257 | { "max6369_wdt", (kernel_ulong_t)max6369_table, }, | 248 | { "max6369_wdt", (kernel_ulong_t)max6369_table, }, |
258 | { "max6370_wdt", (kernel_ulong_t)max6369_table, }, | 249 | { "max6370_wdt", (kernel_ulong_t)max6369_table, }, |
@@ -266,7 +257,6 @@ MODULE_DEVICE_TABLE(platform, max63xx_id_table); | |||
266 | 257 | ||
267 | static struct platform_driver max63xx_wdt_driver = { | 258 | static struct platform_driver max63xx_wdt_driver = { |
268 | .probe = max63xx_wdt_probe, | 259 | .probe = max63xx_wdt_probe, |
269 | .remove = max63xx_wdt_remove, | ||
270 | .id_table = max63xx_id_table, | 260 | .id_table = max63xx_id_table, |
271 | .driver = { | 261 | .driver = { |
272 | .name = "max63xx_wdt", | 262 | .name = "max63xx_wdt", |
diff --git a/drivers/watchdog/max77620_wdt.c b/drivers/watchdog/max77620_wdt.c index 70c9cd3ba938..3ca6b9337932 100644 --- a/drivers/watchdog/max77620_wdt.c +++ b/drivers/watchdog/max77620_wdt.c | |||
@@ -112,17 +112,18 @@ static const struct watchdog_ops max77620_wdt_ops = { | |||
112 | 112 | ||
113 | static int max77620_wdt_probe(struct platform_device *pdev) | 113 | static int max77620_wdt_probe(struct platform_device *pdev) |
114 | { | 114 | { |
115 | struct device *dev = &pdev->dev; | ||
115 | struct max77620_wdt *wdt; | 116 | struct max77620_wdt *wdt; |
116 | struct watchdog_device *wdt_dev; | 117 | struct watchdog_device *wdt_dev; |
117 | unsigned int regval; | 118 | unsigned int regval; |
118 | int ret; | 119 | int ret; |
119 | 120 | ||
120 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 121 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
121 | if (!wdt) | 122 | if (!wdt) |
122 | return -ENOMEM; | 123 | return -ENOMEM; |
123 | 124 | ||
124 | wdt->dev = &pdev->dev; | 125 | wdt->dev = dev; |
125 | wdt->rmap = dev_get_regmap(pdev->dev.parent, NULL); | 126 | wdt->rmap = dev_get_regmap(dev->parent, NULL); |
126 | if (!wdt->rmap) { | 127 | if (!wdt->rmap) { |
127 | dev_err(wdt->dev, "Failed to get parent regmap\n"); | 128 | dev_err(wdt->dev, "Failed to get parent regmap\n"); |
128 | return -ENODEV; | 129 | return -ENODEV; |
@@ -183,25 +184,16 @@ static int max77620_wdt_probe(struct platform_device *pdev) | |||
183 | watchdog_set_nowayout(wdt_dev, nowayout); | 184 | watchdog_set_nowayout(wdt_dev, nowayout); |
184 | watchdog_set_drvdata(wdt_dev, wdt); | 185 | watchdog_set_drvdata(wdt_dev, wdt); |
185 | 186 | ||
186 | ret = watchdog_register_device(wdt_dev); | 187 | watchdog_stop_on_unregister(wdt_dev); |
188 | ret = devm_watchdog_register_device(dev, wdt_dev); | ||
187 | if (ret < 0) { | 189 | if (ret < 0) { |
188 | dev_err(&pdev->dev, "watchdog registration failed: %d\n", ret); | 190 | dev_err(dev, "watchdog registration failed: %d\n", ret); |
189 | return ret; | 191 | return ret; |
190 | } | 192 | } |
191 | 193 | ||
192 | return 0; | 194 | return 0; |
193 | } | 195 | } |
194 | 196 | ||
195 | static int max77620_wdt_remove(struct platform_device *pdev) | ||
196 | { | ||
197 | struct max77620_wdt *wdt = platform_get_drvdata(pdev); | ||
198 | |||
199 | max77620_wdt_stop(&wdt->wdt_dev); | ||
200 | watchdog_unregister_device(&wdt->wdt_dev); | ||
201 | |||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static const struct platform_device_id max77620_wdt_devtype[] = { | 197 | static const struct platform_device_id max77620_wdt_devtype[] = { |
206 | { .name = "max77620-watchdog", }, | 198 | { .name = "max77620-watchdog", }, |
207 | { }, | 199 | { }, |
@@ -213,7 +205,6 @@ static struct platform_driver max77620_wdt_driver = { | |||
213 | .name = "max77620-watchdog", | 205 | .name = "max77620-watchdog", |
214 | }, | 206 | }, |
215 | .probe = max77620_wdt_probe, | 207 | .probe = max77620_wdt_probe, |
216 | .remove = max77620_wdt_remove, | ||
217 | .id_table = max77620_wdt_devtype, | 208 | .id_table = max77620_wdt_devtype, |
218 | }; | 209 | }; |
219 | 210 | ||
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c index 6db69883ece6..e9ca4e0e25dc 100644 --- a/drivers/watchdog/mena21_wdt.c +++ b/drivers/watchdog/mena21_wdt.c | |||
@@ -127,19 +127,20 @@ static struct watchdog_device a21_wdt = { | |||
127 | 127 | ||
128 | static int a21_wdt_probe(struct platform_device *pdev) | 128 | static int a21_wdt_probe(struct platform_device *pdev) |
129 | { | 129 | { |
130 | struct device *dev = &pdev->dev; | ||
130 | struct a21_wdt_drv *drv; | 131 | struct a21_wdt_drv *drv; |
131 | unsigned int reset = 0; | 132 | unsigned int reset = 0; |
132 | int num_gpios; | 133 | int num_gpios; |
133 | int ret; | 134 | int ret; |
134 | int i; | 135 | int i; |
135 | 136 | ||
136 | drv = devm_kzalloc(&pdev->dev, sizeof(struct a21_wdt_drv), GFP_KERNEL); | 137 | drv = devm_kzalloc(dev, sizeof(struct a21_wdt_drv), GFP_KERNEL); |
137 | if (!drv) | 138 | if (!drv) |
138 | return -ENOMEM; | 139 | return -ENOMEM; |
139 | 140 | ||
140 | num_gpios = gpiod_count(&pdev->dev, NULL); | 141 | num_gpios = gpiod_count(dev, NULL); |
141 | if (num_gpios != NUM_GPIOS) { | 142 | if (num_gpios != NUM_GPIOS) { |
142 | dev_err(&pdev->dev, "gpios DT property wrong, got %d want %d", | 143 | dev_err(dev, "gpios DT property wrong, got %d want %d", |
143 | num_gpios, NUM_GPIOS); | 144 | num_gpios, NUM_GPIOS); |
144 | return -ENODEV; | 145 | return -ENODEV; |
145 | } | 146 | } |
@@ -152,12 +153,9 @@ static int a21_wdt_probe(struct platform_device *pdev) | |||
152 | gflags = GPIOD_ASIS; | 153 | gflags = GPIOD_ASIS; |
153 | else | 154 | else |
154 | gflags = GPIOD_IN; | 155 | gflags = GPIOD_IN; |
155 | drv->gpios[i] = devm_gpiod_get_index(&pdev->dev, NULL, i, | 156 | drv->gpios[i] = devm_gpiod_get_index(dev, NULL, i, gflags); |
156 | gflags); | 157 | if (IS_ERR(drv->gpios[i])) |
157 | if (IS_ERR(drv->gpios[i])) { | 158 | return PTR_ERR(drv->gpios[i]); |
158 | ret = PTR_ERR(drv->gpios[i]); | ||
159 | return ret; | ||
160 | } | ||
161 | 159 | ||
162 | gpiod_set_consumer_name(drv->gpios[i], "MEN A21 Watchdog"); | 160 | gpiod_set_consumer_name(drv->gpios[i], "MEN A21 Watchdog"); |
163 | 161 | ||
@@ -173,10 +171,10 @@ static int a21_wdt_probe(struct platform_device *pdev) | |||
173 | } | 171 | } |
174 | } | 172 | } |
175 | 173 | ||
176 | watchdog_init_timeout(&a21_wdt, 30, &pdev->dev); | 174 | watchdog_init_timeout(&a21_wdt, 30, dev); |
177 | watchdog_set_nowayout(&a21_wdt, nowayout); | 175 | watchdog_set_nowayout(&a21_wdt, nowayout); |
178 | watchdog_set_drvdata(&a21_wdt, drv); | 176 | watchdog_set_drvdata(&a21_wdt, drv); |
179 | a21_wdt.parent = &pdev->dev; | 177 | a21_wdt.parent = dev; |
180 | 178 | ||
181 | reset = a21_wdt_get_bootstatus(drv); | 179 | reset = a21_wdt_get_bootstatus(drv); |
182 | if (reset == 2) | 180 | if (reset == 2) |
@@ -189,15 +187,15 @@ static int a21_wdt_probe(struct platform_device *pdev) | |||
189 | a21_wdt.bootstatus |= WDIOF_EXTERN2; | 187 | a21_wdt.bootstatus |= WDIOF_EXTERN2; |
190 | 188 | ||
191 | drv->wdt = a21_wdt; | 189 | drv->wdt = a21_wdt; |
192 | dev_set_drvdata(&pdev->dev, drv); | 190 | dev_set_drvdata(dev, drv); |
193 | 191 | ||
194 | ret = devm_watchdog_register_device(&pdev->dev, &a21_wdt); | 192 | ret = devm_watchdog_register_device(dev, &a21_wdt); |
195 | if (ret) { | 193 | if (ret) { |
196 | dev_err(&pdev->dev, "Cannot register watchdog device\n"); | 194 | dev_err(dev, "Cannot register watchdog device\n"); |
197 | return ret; | 195 | return ret; |
198 | } | 196 | } |
199 | 197 | ||
200 | dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n"); | 198 | dev_info(dev, "MEN A21 watchdog timer driver enabled\n"); |
201 | 199 | ||
202 | return 0; | 200 | return 0; |
203 | } | 201 | } |
diff --git a/drivers/watchdog/menf21bmc_wdt.c b/drivers/watchdog/menf21bmc_wdt.c index 3aefddebb386..b1dbff553cdc 100644 --- a/drivers/watchdog/menf21bmc_wdt.c +++ b/drivers/watchdog/menf21bmc_wdt.c | |||
@@ -117,12 +117,12 @@ static const struct watchdog_ops menf21bmc_wdt_ops = { | |||
117 | 117 | ||
118 | static int menf21bmc_wdt_probe(struct platform_device *pdev) | 118 | static int menf21bmc_wdt_probe(struct platform_device *pdev) |
119 | { | 119 | { |
120 | struct device *dev = &pdev->dev; | ||
120 | int ret, bmc_timeout; | 121 | int ret, bmc_timeout; |
121 | struct menf21bmc_wdt *drv_data; | 122 | struct menf21bmc_wdt *drv_data; |
122 | struct i2c_client *i2c_client = to_i2c_client(pdev->dev.parent); | 123 | struct i2c_client *i2c_client = to_i2c_client(dev->parent); |
123 | 124 | ||
124 | drv_data = devm_kzalloc(&pdev->dev, | 125 | drv_data = devm_kzalloc(dev, sizeof(struct menf21bmc_wdt), GFP_KERNEL); |
125 | sizeof(struct menf21bmc_wdt), GFP_KERNEL); | ||
126 | if (!drv_data) | 126 | if (!drv_data) |
127 | return -ENOMEM; | 127 | return -ENOMEM; |
128 | 128 | ||
@@ -130,7 +130,7 @@ static int menf21bmc_wdt_probe(struct platform_device *pdev) | |||
130 | drv_data->wdt.info = &menf21bmc_wdt_info; | 130 | drv_data->wdt.info = &menf21bmc_wdt_info; |
131 | drv_data->wdt.min_timeout = BMC_WD_TIMEOUT_MIN; | 131 | drv_data->wdt.min_timeout = BMC_WD_TIMEOUT_MIN; |
132 | drv_data->wdt.max_timeout = BMC_WD_TIMEOUT_MAX; | 132 | drv_data->wdt.max_timeout = BMC_WD_TIMEOUT_MAX; |
133 | drv_data->wdt.parent = &pdev->dev; | 133 | drv_data->wdt.parent = dev; |
134 | drv_data->i2c_client = i2c_client; | 134 | drv_data->i2c_client = i2c_client; |
135 | 135 | ||
136 | /* | 136 | /* |
@@ -140,40 +140,28 @@ static int menf21bmc_wdt_probe(struct platform_device *pdev) | |||
140 | bmc_timeout = i2c_smbus_read_word_data(drv_data->i2c_client, | 140 | bmc_timeout = i2c_smbus_read_word_data(drv_data->i2c_client, |
141 | BMC_CMD_WD_TIME); | 141 | BMC_CMD_WD_TIME); |
142 | if (bmc_timeout < 0) { | 142 | if (bmc_timeout < 0) { |
143 | dev_err(&pdev->dev, "failed to get current WDT timeout\n"); | 143 | dev_err(dev, "failed to get current WDT timeout\n"); |
144 | return bmc_timeout; | 144 | return bmc_timeout; |
145 | } | 145 | } |
146 | 146 | ||
147 | watchdog_init_timeout(&drv_data->wdt, bmc_timeout / 10, &pdev->dev); | 147 | watchdog_init_timeout(&drv_data->wdt, bmc_timeout / 10, dev); |
148 | watchdog_set_nowayout(&drv_data->wdt, nowayout); | 148 | watchdog_set_nowayout(&drv_data->wdt, nowayout); |
149 | watchdog_set_drvdata(&drv_data->wdt, drv_data); | 149 | watchdog_set_drvdata(&drv_data->wdt, drv_data); |
150 | platform_set_drvdata(pdev, drv_data); | 150 | platform_set_drvdata(pdev, drv_data); |
151 | 151 | ||
152 | ret = menf21bmc_wdt_set_bootstatus(drv_data); | 152 | ret = menf21bmc_wdt_set_bootstatus(drv_data); |
153 | if (ret < 0) { | 153 | if (ret < 0) { |
154 | dev_err(&pdev->dev, "failed to set Watchdog bootstatus\n"); | 154 | dev_err(dev, "failed to set Watchdog bootstatus\n"); |
155 | return ret; | 155 | return ret; |
156 | } | 156 | } |
157 | 157 | ||
158 | ret = watchdog_register_device(&drv_data->wdt); | 158 | ret = devm_watchdog_register_device(dev, &drv_data->wdt); |
159 | if (ret) { | 159 | if (ret) { |
160 | dev_err(&pdev->dev, "failed to register Watchdog device\n"); | 160 | dev_err(dev, "failed to register Watchdog device\n"); |
161 | return ret; | 161 | return ret; |
162 | } | 162 | } |
163 | 163 | ||
164 | dev_info(&pdev->dev, "MEN 14F021P00 BMC Watchdog device enabled\n"); | 164 | dev_info(dev, "MEN 14F021P00 BMC Watchdog device enabled\n"); |
165 | |||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | static int menf21bmc_wdt_remove(struct platform_device *pdev) | ||
170 | { | ||
171 | struct menf21bmc_wdt *drv_data = platform_get_drvdata(pdev); | ||
172 | |||
173 | dev_warn(&pdev->dev, | ||
174 | "Unregister MEN 14F021P00 BMC Watchdog device, board may reset\n"); | ||
175 | |||
176 | watchdog_unregister_device(&drv_data->wdt); | ||
177 | 165 | ||
178 | return 0; | 166 | return 0; |
179 | } | 167 | } |
@@ -191,7 +179,6 @@ static struct platform_driver menf21bmc_wdt = { | |||
191 | .name = DEVNAME, | 179 | .name = DEVNAME, |
192 | }, | 180 | }, |
193 | .probe = menf21bmc_wdt_probe, | 181 | .probe = menf21bmc_wdt_probe, |
194 | .remove = menf21bmc_wdt_remove, | ||
195 | .shutdown = menf21bmc_wdt_shutdown, | 182 | .shutdown = menf21bmc_wdt_shutdown, |
196 | }; | 183 | }; |
197 | 184 | ||
diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c index 69adeab3fde7..d17c1a6ed723 100644 --- a/drivers/watchdog/meson_gxbb_wdt.c +++ b/drivers/watchdog/meson_gxbb_wdt.c | |||
@@ -136,32 +136,40 @@ static const struct of_device_id meson_gxbb_wdt_dt_ids[] = { | |||
136 | }; | 136 | }; |
137 | MODULE_DEVICE_TABLE(of, meson_gxbb_wdt_dt_ids); | 137 | MODULE_DEVICE_TABLE(of, meson_gxbb_wdt_dt_ids); |
138 | 138 | ||
139 | static void meson_clk_disable_unprepare(void *data) | ||
140 | { | ||
141 | clk_disable_unprepare(data); | ||
142 | } | ||
143 | |||
139 | static int meson_gxbb_wdt_probe(struct platform_device *pdev) | 144 | static int meson_gxbb_wdt_probe(struct platform_device *pdev) |
140 | { | 145 | { |
146 | struct device *dev = &pdev->dev; | ||
141 | struct meson_gxbb_wdt *data; | 147 | struct meson_gxbb_wdt *data; |
142 | struct resource *res; | ||
143 | int ret; | 148 | int ret; |
144 | 149 | ||
145 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | 150 | data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); |
146 | if (!data) | 151 | if (!data) |
147 | return -ENOMEM; | 152 | return -ENOMEM; |
148 | 153 | ||
149 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 154 | data->reg_base = devm_platform_ioremap_resource(pdev, 0); |
150 | data->reg_base = devm_ioremap_resource(&pdev->dev, res); | ||
151 | if (IS_ERR(data->reg_base)) | 155 | if (IS_ERR(data->reg_base)) |
152 | return PTR_ERR(data->reg_base); | 156 | return PTR_ERR(data->reg_base); |
153 | 157 | ||
154 | data->clk = devm_clk_get(&pdev->dev, NULL); | 158 | data->clk = devm_clk_get(dev, NULL); |
155 | if (IS_ERR(data->clk)) | 159 | if (IS_ERR(data->clk)) |
156 | return PTR_ERR(data->clk); | 160 | return PTR_ERR(data->clk); |
157 | 161 | ||
158 | ret = clk_prepare_enable(data->clk); | 162 | ret = clk_prepare_enable(data->clk); |
159 | if (ret) | 163 | if (ret) |
160 | return ret; | 164 | return ret; |
165 | ret = devm_add_action_or_reset(dev, meson_clk_disable_unprepare, | ||
166 | data->clk); | ||
167 | if (ret) | ||
168 | return ret; | ||
161 | 169 | ||
162 | platform_set_drvdata(pdev, data); | 170 | platform_set_drvdata(pdev, data); |
163 | 171 | ||
164 | data->wdt_dev.parent = &pdev->dev; | 172 | data->wdt_dev.parent = dev; |
165 | data->wdt_dev.info = &meson_gxbb_wdt_info; | 173 | data->wdt_dev.info = &meson_gxbb_wdt_info; |
166 | data->wdt_dev.ops = &meson_gxbb_wdt_ops; | 174 | data->wdt_dev.ops = &meson_gxbb_wdt_ops; |
167 | data->wdt_dev.max_hw_heartbeat_ms = GXBB_WDT_TCNT_SETUP_MASK; | 175 | data->wdt_dev.max_hw_heartbeat_ms = GXBB_WDT_TCNT_SETUP_MASK; |
@@ -178,37 +186,12 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev) | |||
178 | 186 | ||
179 | meson_gxbb_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout); | 187 | meson_gxbb_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout); |
180 | 188 | ||
181 | ret = watchdog_register_device(&data->wdt_dev); | 189 | watchdog_stop_on_reboot(&data->wdt_dev); |
182 | if (ret) { | 190 | return devm_watchdog_register_device(dev, &data->wdt_dev); |
183 | clk_disable_unprepare(data->clk); | ||
184 | return ret; | ||
185 | } | ||
186 | |||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | static int meson_gxbb_wdt_remove(struct platform_device *pdev) | ||
191 | { | ||
192 | struct meson_gxbb_wdt *data = platform_get_drvdata(pdev); | ||
193 | |||
194 | watchdog_unregister_device(&data->wdt_dev); | ||
195 | |||
196 | clk_disable_unprepare(data->clk); | ||
197 | |||
198 | return 0; | ||
199 | } | ||
200 | |||
201 | static void meson_gxbb_wdt_shutdown(struct platform_device *pdev) | ||
202 | { | ||
203 | struct meson_gxbb_wdt *data = platform_get_drvdata(pdev); | ||
204 | |||
205 | meson_gxbb_wdt_stop(&data->wdt_dev); | ||
206 | } | 191 | } |
207 | 192 | ||
208 | static struct platform_driver meson_gxbb_wdt_driver = { | 193 | static struct platform_driver meson_gxbb_wdt_driver = { |
209 | .probe = meson_gxbb_wdt_probe, | 194 | .probe = meson_gxbb_wdt_probe, |
210 | .remove = meson_gxbb_wdt_remove, | ||
211 | .shutdown = meson_gxbb_wdt_shutdown, | ||
212 | .driver = { | 195 | .driver = { |
213 | .name = "meson-gxbb-wdt", | 196 | .name = "meson-gxbb-wdt", |
214 | .pm = &meson_gxbb_wdt_pm_ops, | 197 | .pm = &meson_gxbb_wdt_pm_ops, |
diff --git a/drivers/watchdog/meson_wdt.c b/drivers/watchdog/meson_wdt.c index cd0275a6cdac..01889cef81e1 100644 --- a/drivers/watchdog/meson_wdt.c +++ b/drivers/watchdog/meson_wdt.c | |||
@@ -164,28 +164,27 @@ MODULE_DEVICE_TABLE(of, meson_wdt_dt_ids); | |||
164 | 164 | ||
165 | static int meson_wdt_probe(struct platform_device *pdev) | 165 | static int meson_wdt_probe(struct platform_device *pdev) |
166 | { | 166 | { |
167 | struct resource *res; | 167 | struct device *dev = &pdev->dev; |
168 | struct meson_wdt_dev *meson_wdt; | 168 | struct meson_wdt_dev *meson_wdt; |
169 | const struct of_device_id *of_id; | 169 | const struct of_device_id *of_id; |
170 | int err; | 170 | int err; |
171 | 171 | ||
172 | meson_wdt = devm_kzalloc(&pdev->dev, sizeof(*meson_wdt), GFP_KERNEL); | 172 | meson_wdt = devm_kzalloc(dev, sizeof(*meson_wdt), GFP_KERNEL); |
173 | if (!meson_wdt) | 173 | if (!meson_wdt) |
174 | return -ENOMEM; | 174 | return -ENOMEM; |
175 | 175 | ||
176 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 176 | meson_wdt->wdt_base = devm_platform_ioremap_resource(pdev, 0); |
177 | meson_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res); | ||
178 | if (IS_ERR(meson_wdt->wdt_base)) | 177 | if (IS_ERR(meson_wdt->wdt_base)) |
179 | return PTR_ERR(meson_wdt->wdt_base); | 178 | return PTR_ERR(meson_wdt->wdt_base); |
180 | 179 | ||
181 | of_id = of_match_device(meson_wdt_dt_ids, &pdev->dev); | 180 | of_id = of_match_device(meson_wdt_dt_ids, dev); |
182 | if (!of_id) { | 181 | if (!of_id) { |
183 | dev_err(&pdev->dev, "Unable to initialize WDT data\n"); | 182 | dev_err(dev, "Unable to initialize WDT data\n"); |
184 | return -ENODEV; | 183 | return -ENODEV; |
185 | } | 184 | } |
186 | meson_wdt->data = of_id->data; | 185 | meson_wdt->data = of_id->data; |
187 | 186 | ||
188 | meson_wdt->wdt_dev.parent = &pdev->dev; | 187 | meson_wdt->wdt_dev.parent = dev; |
189 | meson_wdt->wdt_dev.info = &meson_wdt_info; | 188 | meson_wdt->wdt_dev.info = &meson_wdt_info; |
190 | meson_wdt->wdt_dev.ops = &meson_wdt_ops; | 189 | meson_wdt->wdt_dev.ops = &meson_wdt_ops; |
191 | meson_wdt->wdt_dev.max_timeout = | 190 | meson_wdt->wdt_dev.max_timeout = |
@@ -197,18 +196,18 @@ static int meson_wdt_probe(struct platform_device *pdev) | |||
197 | 196 | ||
198 | watchdog_set_drvdata(&meson_wdt->wdt_dev, meson_wdt); | 197 | watchdog_set_drvdata(&meson_wdt->wdt_dev, meson_wdt); |
199 | 198 | ||
200 | watchdog_init_timeout(&meson_wdt->wdt_dev, timeout, &pdev->dev); | 199 | watchdog_init_timeout(&meson_wdt->wdt_dev, timeout, dev); |
201 | watchdog_set_nowayout(&meson_wdt->wdt_dev, nowayout); | 200 | watchdog_set_nowayout(&meson_wdt->wdt_dev, nowayout); |
202 | watchdog_set_restart_priority(&meson_wdt->wdt_dev, 128); | 201 | watchdog_set_restart_priority(&meson_wdt->wdt_dev, 128); |
203 | 202 | ||
204 | meson_wdt_stop(&meson_wdt->wdt_dev); | 203 | meson_wdt_stop(&meson_wdt->wdt_dev); |
205 | 204 | ||
206 | watchdog_stop_on_reboot(&meson_wdt->wdt_dev); | 205 | watchdog_stop_on_reboot(&meson_wdt->wdt_dev); |
207 | err = devm_watchdog_register_device(&pdev->dev, &meson_wdt->wdt_dev); | 206 | err = devm_watchdog_register_device(dev, &meson_wdt->wdt_dev); |
208 | if (err) | 207 | if (err) |
209 | return err; | 208 | return err; |
210 | 209 | ||
211 | dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", | 210 | dev_info(dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", |
212 | meson_wdt->wdt_dev.timeout, nowayout); | 211 | meson_wdt->wdt_dev.timeout, nowayout); |
213 | 212 | ||
214 | return 0; | 213 | return 0; |
diff --git a/drivers/watchdog/mlx_wdt.c b/drivers/watchdog/mlx_wdt.c index 70c2cbf9c993..03b9ac4b99af 100644 --- a/drivers/watchdog/mlx_wdt.c +++ b/drivers/watchdog/mlx_wdt.c | |||
@@ -233,20 +233,21 @@ static int mlxreg_wdt_init_timeout(struct mlxreg_wdt *wdt, | |||
233 | 233 | ||
234 | static int mlxreg_wdt_probe(struct platform_device *pdev) | 234 | static int mlxreg_wdt_probe(struct platform_device *pdev) |
235 | { | 235 | { |
236 | struct device *dev = &pdev->dev; | ||
236 | struct mlxreg_core_platform_data *pdata; | 237 | struct mlxreg_core_platform_data *pdata; |
237 | struct mlxreg_wdt *wdt; | 238 | struct mlxreg_wdt *wdt; |
238 | int rc; | 239 | int rc; |
239 | 240 | ||
240 | pdata = dev_get_platdata(&pdev->dev); | 241 | pdata = dev_get_platdata(dev); |
241 | if (!pdata) { | 242 | if (!pdata) { |
242 | dev_err(&pdev->dev, "Failed to get platform data.\n"); | 243 | dev_err(dev, "Failed to get platform data.\n"); |
243 | return -EINVAL; | 244 | return -EINVAL; |
244 | } | 245 | } |
245 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 246 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
246 | if (!wdt) | 247 | if (!wdt) |
247 | return -ENOMEM; | 248 | return -ENOMEM; |
248 | 249 | ||
249 | wdt->wdd.parent = &pdev->dev; | 250 | wdt->wdd.parent = dev; |
250 | wdt->regmap = pdata->regmap; | 251 | wdt->regmap = pdata->regmap; |
251 | mlxreg_wdt_config(wdt, pdata); | 252 | mlxreg_wdt_config(wdt, pdata); |
252 | 253 | ||
@@ -266,12 +267,11 @@ static int mlxreg_wdt_probe(struct platform_device *pdev) | |||
266 | set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); | 267 | set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); |
267 | } | 268 | } |
268 | mlxreg_wdt_check_card_reset(wdt); | 269 | mlxreg_wdt_check_card_reset(wdt); |
269 | rc = devm_watchdog_register_device(&pdev->dev, &wdt->wdd); | 270 | rc = devm_watchdog_register_device(dev, &wdt->wdd); |
270 | 271 | ||
271 | register_error: | 272 | register_error: |
272 | if (rc) | 273 | if (rc) |
273 | dev_err(&pdev->dev, | 274 | dev_err(dev, "Cannot register watchdog device (err=%d)\n", rc); |
274 | "Cannot register watchdog device (err=%d)\n", rc); | ||
275 | return rc; | 275 | return rc; |
276 | } | 276 | } |
277 | 277 | ||
diff --git a/drivers/watchdog/moxart_wdt.c b/drivers/watchdog/moxart_wdt.c index 430c3ab84c07..6340a1f5f471 100644 --- a/drivers/watchdog/moxart_wdt.c +++ b/drivers/watchdog/moxart_wdt.c | |||
@@ -91,8 +91,6 @@ static int moxart_wdt_probe(struct platform_device *pdev) | |||
91 | { | 91 | { |
92 | struct moxart_wdt_dev *moxart_wdt; | 92 | struct moxart_wdt_dev *moxart_wdt; |
93 | struct device *dev = &pdev->dev; | 93 | struct device *dev = &pdev->dev; |
94 | struct device_node *node = dev->of_node; | ||
95 | struct resource *res; | ||
96 | struct clk *clk; | 94 | struct clk *clk; |
97 | int err; | 95 | int err; |
98 | unsigned int max_timeout; | 96 | unsigned int max_timeout; |
@@ -104,12 +102,11 @@ static int moxart_wdt_probe(struct platform_device *pdev) | |||
104 | 102 | ||
105 | platform_set_drvdata(pdev, moxart_wdt); | 103 | platform_set_drvdata(pdev, moxart_wdt); |
106 | 104 | ||
107 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 105 | moxart_wdt->base = devm_platform_ioremap_resource(pdev, 0); |
108 | moxart_wdt->base = devm_ioremap_resource(dev, res); | ||
109 | if (IS_ERR(moxart_wdt->base)) | 106 | if (IS_ERR(moxart_wdt->base)) |
110 | return PTR_ERR(moxart_wdt->base); | 107 | return PTR_ERR(moxart_wdt->base); |
111 | 108 | ||
112 | clk = of_clk_get(node, 0); | 109 | clk = devm_clk_get(dev, NULL); |
113 | if (IS_ERR(clk)) { | 110 | if (IS_ERR(clk)) { |
114 | pr_err("%s: of_clk_get failed\n", __func__); | 111 | pr_err("%s: of_clk_get failed\n", __func__); |
115 | return PTR_ERR(clk); | 112 | return PTR_ERR(clk); |
@@ -136,7 +133,8 @@ static int moxart_wdt_probe(struct platform_device *pdev) | |||
136 | 133 | ||
137 | watchdog_set_drvdata(&moxart_wdt->dev, moxart_wdt); | 134 | watchdog_set_drvdata(&moxart_wdt->dev, moxart_wdt); |
138 | 135 | ||
139 | err = watchdog_register_device(&moxart_wdt->dev); | 136 | watchdog_stop_on_unregister(&moxart_wdt->dev); |
137 | err = devm_watchdog_register_device(dev, &moxart_wdt->dev); | ||
140 | if (err) | 138 | if (err) |
141 | return err; | 139 | return err; |
142 | 140 | ||
@@ -146,15 +144,6 @@ static int moxart_wdt_probe(struct platform_device *pdev) | |||
146 | return 0; | 144 | return 0; |
147 | } | 145 | } |
148 | 146 | ||
149 | static int moxart_wdt_remove(struct platform_device *pdev) | ||
150 | { | ||
151 | struct moxart_wdt_dev *moxart_wdt = platform_get_drvdata(pdev); | ||
152 | |||
153 | moxart_wdt_stop(&moxart_wdt->dev); | ||
154 | |||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | static const struct of_device_id moxart_watchdog_match[] = { | 147 | static const struct of_device_id moxart_watchdog_match[] = { |
159 | { .compatible = "moxa,moxart-watchdog" }, | 148 | { .compatible = "moxa,moxart-watchdog" }, |
160 | { }, | 149 | { }, |
@@ -163,7 +152,6 @@ MODULE_DEVICE_TABLE(of, moxart_watchdog_match); | |||
163 | 152 | ||
164 | static struct platform_driver moxart_wdt_driver = { | 153 | static struct platform_driver moxart_wdt_driver = { |
165 | .probe = moxart_wdt_probe, | 154 | .probe = moxart_wdt_probe, |
166 | .remove = moxart_wdt_remove, | ||
167 | .driver = { | 155 | .driver = { |
168 | .name = "moxart-watchdog", | 156 | .name = "moxart-watchdog", |
169 | .of_match_table = moxart_watchdog_match, | 157 | .of_match_table = moxart_watchdog_match, |
diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c index 069072e6747d..9b6d6a5a27ad 100644 --- a/drivers/watchdog/mpc8xxx_wdt.c +++ b/drivers/watchdog/mpc8xxx_wdt.c | |||
@@ -149,8 +149,7 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev) | |||
149 | if (!ddata) | 149 | if (!ddata) |
150 | return -ENOMEM; | 150 | return -ENOMEM; |
151 | 151 | ||
152 | res = platform_get_resource(ofdev, IORESOURCE_MEM, 0); | 152 | ddata->base = devm_platform_ioremap_resource(ofdev, 0); |
153 | ddata->base = devm_ioremap_resource(dev, res); | ||
154 | if (IS_ERR(ddata->base)) | 153 | if (IS_ERR(ddata->base)) |
155 | return PTR_ERR(ddata->base); | 154 | return PTR_ERR(ddata->base); |
156 | 155 | ||
@@ -205,9 +204,10 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev) | |||
205 | if (ddata->wdd.timeout < ddata->wdd.min_timeout) | 204 | if (ddata->wdd.timeout < ddata->wdd.min_timeout) |
206 | ddata->wdd.timeout = ddata->wdd.min_timeout; | 205 | ddata->wdd.timeout = ddata->wdd.min_timeout; |
207 | 206 | ||
208 | ret = watchdog_register_device(&ddata->wdd); | 207 | ret = devm_watchdog_register_device(dev, &ddata->wdd); |
209 | if (ret) { | 208 | if (ret) { |
210 | dev_err(dev, "cannot register watchdog device (err=%d)\n", ret); | 209 | dev_err(dev, "cannot register watchdog device (err=%d)\n", |
210 | ret); | ||
211 | return ret; | 211 | return ret; |
212 | } | 212 | } |
213 | 213 | ||
@@ -219,17 +219,6 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev) | |||
219 | return 0; | 219 | return 0; |
220 | } | 220 | } |
221 | 221 | ||
222 | static int mpc8xxx_wdt_remove(struct platform_device *ofdev) | ||
223 | { | ||
224 | struct mpc8xxx_wdt_ddata *ddata = platform_get_drvdata(ofdev); | ||
225 | |||
226 | dev_crit(&ofdev->dev, "Watchdog removed, expect the %s soon!\n", | ||
227 | reset ? "reset" : "machine check exception"); | ||
228 | watchdog_unregister_device(&ddata->wdd); | ||
229 | |||
230 | return 0; | ||
231 | } | ||
232 | |||
233 | static const struct of_device_id mpc8xxx_wdt_match[] = { | 222 | static const struct of_device_id mpc8xxx_wdt_match[] = { |
234 | { | 223 | { |
235 | .compatible = "mpc83xx_wdt", | 224 | .compatible = "mpc83xx_wdt", |
@@ -260,7 +249,6 @@ MODULE_DEVICE_TABLE(of, mpc8xxx_wdt_match); | |||
260 | 249 | ||
261 | static struct platform_driver mpc8xxx_wdt_driver = { | 250 | static struct platform_driver mpc8xxx_wdt_driver = { |
262 | .probe = mpc8xxx_wdt_probe, | 251 | .probe = mpc8xxx_wdt_probe, |
263 | .remove = mpc8xxx_wdt_remove, | ||
264 | .driver = { | 252 | .driver = { |
265 | .name = "mpc8xxx_wdt", | 253 | .name = "mpc8xxx_wdt", |
266 | .of_match_table = mpc8xxx_wdt_match, | 254 | .of_match_table = mpc8xxx_wdt_match, |
diff --git a/drivers/watchdog/mt7621_wdt.c b/drivers/watchdog/mt7621_wdt.c index 81208cd3f4ec..cbb3c0dde136 100644 --- a/drivers/watchdog/mt7621_wdt.c +++ b/drivers/watchdog/mt7621_wdt.c | |||
@@ -133,21 +133,19 @@ static struct watchdog_device mt7621_wdt_dev = { | |||
133 | 133 | ||
134 | static int mt7621_wdt_probe(struct platform_device *pdev) | 134 | static int mt7621_wdt_probe(struct platform_device *pdev) |
135 | { | 135 | { |
136 | struct resource *res; | 136 | struct device *dev = &pdev->dev; |
137 | 137 | mt7621_wdt_base = devm_platform_ioremap_resource(pdev, 0); | |
138 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
139 | mt7621_wdt_base = devm_ioremap_resource(&pdev->dev, res); | ||
140 | if (IS_ERR(mt7621_wdt_base)) | 138 | if (IS_ERR(mt7621_wdt_base)) |
141 | return PTR_ERR(mt7621_wdt_base); | 139 | return PTR_ERR(mt7621_wdt_base); |
142 | 140 | ||
143 | mt7621_wdt_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); | 141 | mt7621_wdt_reset = devm_reset_control_get_exclusive(dev, NULL); |
144 | if (!IS_ERR(mt7621_wdt_reset)) | 142 | if (!IS_ERR(mt7621_wdt_reset)) |
145 | reset_control_deassert(mt7621_wdt_reset); | 143 | reset_control_deassert(mt7621_wdt_reset); |
146 | 144 | ||
147 | mt7621_wdt_dev.bootstatus = mt7621_wdt_bootcause(); | 145 | mt7621_wdt_dev.bootstatus = mt7621_wdt_bootcause(); |
148 | 146 | ||
149 | watchdog_init_timeout(&mt7621_wdt_dev, mt7621_wdt_dev.max_timeout, | 147 | watchdog_init_timeout(&mt7621_wdt_dev, mt7621_wdt_dev.max_timeout, |
150 | &pdev->dev); | 148 | dev); |
151 | watchdog_set_nowayout(&mt7621_wdt_dev, nowayout); | 149 | watchdog_set_nowayout(&mt7621_wdt_dev, nowayout); |
152 | if (mt7621_wdt_is_running(&mt7621_wdt_dev)) { | 150 | if (mt7621_wdt_is_running(&mt7621_wdt_dev)) { |
153 | /* | 151 | /* |
@@ -164,7 +162,7 @@ static int mt7621_wdt_probe(struct platform_device *pdev) | |||
164 | set_bit(WDOG_HW_RUNNING, &mt7621_wdt_dev.status); | 162 | set_bit(WDOG_HW_RUNNING, &mt7621_wdt_dev.status); |
165 | } | 163 | } |
166 | 164 | ||
167 | return devm_watchdog_register_device(&pdev->dev, &mt7621_wdt_dev); | 165 | return devm_watchdog_register_device(dev, &mt7621_wdt_dev); |
168 | } | 166 | } |
169 | 167 | ||
170 | static void mt7621_wdt_shutdown(struct platform_device *pdev) | 168 | static void mt7621_wdt_shutdown(struct platform_device *pdev) |
diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c index 4baf64f21aa1..9c3d0033260d 100644 --- a/drivers/watchdog/mtk_wdt.c +++ b/drivers/watchdog/mtk_wdt.c | |||
@@ -153,18 +153,17 @@ static const struct watchdog_ops mtk_wdt_ops = { | |||
153 | 153 | ||
154 | static int mtk_wdt_probe(struct platform_device *pdev) | 154 | static int mtk_wdt_probe(struct platform_device *pdev) |
155 | { | 155 | { |
156 | struct device *dev = &pdev->dev; | ||
156 | struct mtk_wdt_dev *mtk_wdt; | 157 | struct mtk_wdt_dev *mtk_wdt; |
157 | struct resource *res; | ||
158 | int err; | 158 | int err; |
159 | 159 | ||
160 | mtk_wdt = devm_kzalloc(&pdev->dev, sizeof(*mtk_wdt), GFP_KERNEL); | 160 | mtk_wdt = devm_kzalloc(dev, sizeof(*mtk_wdt), GFP_KERNEL); |
161 | if (!mtk_wdt) | 161 | if (!mtk_wdt) |
162 | return -ENOMEM; | 162 | return -ENOMEM; |
163 | 163 | ||
164 | platform_set_drvdata(pdev, mtk_wdt); | 164 | platform_set_drvdata(pdev, mtk_wdt); |
165 | 165 | ||
166 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 166 | mtk_wdt->wdt_base = devm_platform_ioremap_resource(pdev, 0); |
167 | mtk_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res); | ||
168 | if (IS_ERR(mtk_wdt->wdt_base)) | 167 | if (IS_ERR(mtk_wdt->wdt_base)) |
169 | return PTR_ERR(mtk_wdt->wdt_base); | 168 | return PTR_ERR(mtk_wdt->wdt_base); |
170 | 169 | ||
@@ -173,9 +172,9 @@ static int mtk_wdt_probe(struct platform_device *pdev) | |||
173 | mtk_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT; | 172 | mtk_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT; |
174 | mtk_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT; | 173 | mtk_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT; |
175 | mtk_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT; | 174 | mtk_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT; |
176 | mtk_wdt->wdt_dev.parent = &pdev->dev; | 175 | mtk_wdt->wdt_dev.parent = dev; |
177 | 176 | ||
178 | watchdog_init_timeout(&mtk_wdt->wdt_dev, timeout, &pdev->dev); | 177 | watchdog_init_timeout(&mtk_wdt->wdt_dev, timeout, dev); |
179 | watchdog_set_nowayout(&mtk_wdt->wdt_dev, nowayout); | 178 | watchdog_set_nowayout(&mtk_wdt->wdt_dev, nowayout); |
180 | watchdog_set_restart_priority(&mtk_wdt->wdt_dev, 128); | 179 | watchdog_set_restart_priority(&mtk_wdt->wdt_dev, 128); |
181 | 180 | ||
@@ -183,29 +182,13 @@ static int mtk_wdt_probe(struct platform_device *pdev) | |||
183 | 182 | ||
184 | mtk_wdt_stop(&mtk_wdt->wdt_dev); | 183 | mtk_wdt_stop(&mtk_wdt->wdt_dev); |
185 | 184 | ||
186 | err = watchdog_register_device(&mtk_wdt->wdt_dev); | 185 | watchdog_stop_on_reboot(&mtk_wdt->wdt_dev); |
186 | err = devm_watchdog_register_device(dev, &mtk_wdt->wdt_dev); | ||
187 | if (unlikely(err)) | 187 | if (unlikely(err)) |
188 | return err; | 188 | return err; |
189 | 189 | ||
190 | dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)\n", | 190 | dev_info(dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)\n", |
191 | mtk_wdt->wdt_dev.timeout, nowayout); | 191 | mtk_wdt->wdt_dev.timeout, nowayout); |
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | static void mtk_wdt_shutdown(struct platform_device *pdev) | ||
197 | { | ||
198 | struct mtk_wdt_dev *mtk_wdt = platform_get_drvdata(pdev); | ||
199 | |||
200 | if (watchdog_active(&mtk_wdt->wdt_dev)) | ||
201 | mtk_wdt_stop(&mtk_wdt->wdt_dev); | ||
202 | } | ||
203 | |||
204 | static int mtk_wdt_remove(struct platform_device *pdev) | ||
205 | { | ||
206 | struct mtk_wdt_dev *mtk_wdt = platform_get_drvdata(pdev); | ||
207 | |||
208 | watchdog_unregister_device(&mtk_wdt->wdt_dev); | ||
209 | 192 | ||
210 | return 0; | 193 | return 0; |
211 | } | 194 | } |
@@ -247,8 +230,6 @@ static const struct dev_pm_ops mtk_wdt_pm_ops = { | |||
247 | 230 | ||
248 | static struct platform_driver mtk_wdt_driver = { | 231 | static struct platform_driver mtk_wdt_driver = { |
249 | .probe = mtk_wdt_probe, | 232 | .probe = mtk_wdt_probe, |
250 | .remove = mtk_wdt_remove, | ||
251 | .shutdown = mtk_wdt_shutdown, | ||
252 | .driver = { | 233 | .driver = { |
253 | .name = DRV_NAME, | 234 | .name = DRV_NAME, |
254 | .pm = &mtk_wdt_pm_ops, | 235 | .pm = &mtk_wdt_pm_ops, |
diff --git a/drivers/watchdog/ni903x_wdt.c b/drivers/watchdog/ni903x_wdt.c index dc67742e9018..fbc1df86c6cc 100644 --- a/drivers/watchdog/ni903x_wdt.c +++ b/drivers/watchdog/ni903x_wdt.c | |||
@@ -217,9 +217,7 @@ static int ni903x_acpi_add(struct acpi_device *device) | |||
217 | wdd->parent = dev; | 217 | wdd->parent = dev; |
218 | watchdog_set_drvdata(wdd, wdt); | 218 | watchdog_set_drvdata(wdd, wdt); |
219 | watchdog_set_nowayout(wdd, nowayout); | 219 | watchdog_set_nowayout(wdd, nowayout); |
220 | ret = watchdog_init_timeout(wdd, timeout, dev); | 220 | watchdog_init_timeout(wdd, timeout, dev); |
221 | if (ret) | ||
222 | dev_err(dev, "unable to set timeout value, using default\n"); | ||
223 | 221 | ||
224 | ret = watchdog_register_device(wdd); | 222 | ret = watchdog_register_device(wdd); |
225 | if (ret) { | 223 | if (ret) { |
diff --git a/drivers/watchdog/nic7018_wdt.c b/drivers/watchdog/nic7018_wdt.c index dcd265685837..82843abe38f8 100644 --- a/drivers/watchdog/nic7018_wdt.c +++ b/drivers/watchdog/nic7018_wdt.c | |||
@@ -211,10 +211,7 @@ static int nic7018_probe(struct platform_device *pdev) | |||
211 | 211 | ||
212 | watchdog_set_drvdata(wdd, wdt); | 212 | watchdog_set_drvdata(wdd, wdt); |
213 | watchdog_set_nowayout(wdd, nowayout); | 213 | watchdog_set_nowayout(wdd, nowayout); |
214 | 214 | watchdog_init_timeout(wdd, timeout, dev); | |
215 | ret = watchdog_init_timeout(wdd, timeout, dev); | ||
216 | if (ret) | ||
217 | dev_warn(dev, "unable to set timeout value, using default\n"); | ||
218 | 215 | ||
219 | /* Unlock WDT register */ | 216 | /* Unlock WDT register */ |
220 | outb(UNLOCK, wdt->io_base + WDT_REG_LOCK); | 217 | outb(UNLOCK, wdt->io_base + WDT_REG_LOCK); |
diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c index 0d4213652ecc..9d6c1689b12c 100644 --- a/drivers/watchdog/npcm_wdt.c +++ b/drivers/watchdog/npcm_wdt.c | |||
@@ -181,16 +181,14 @@ static int npcm_wdt_probe(struct platform_device *pdev) | |||
181 | { | 181 | { |
182 | struct device *dev = &pdev->dev; | 182 | struct device *dev = &pdev->dev; |
183 | struct npcm_wdt *wdt; | 183 | struct npcm_wdt *wdt; |
184 | struct resource *res; | ||
185 | int irq; | 184 | int irq; |
186 | int ret; | 185 | int ret; |
187 | 186 | ||
188 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 187 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
189 | if (!wdt) | 188 | if (!wdt) |
190 | return -ENOMEM; | 189 | return -ENOMEM; |
191 | 190 | ||
192 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 191 | wdt->reg = devm_platform_ioremap_resource(pdev, 0); |
193 | wdt->reg = devm_ioremap_resource(dev, res); | ||
194 | if (IS_ERR(wdt->reg)) | 192 | if (IS_ERR(wdt->reg)) |
195 | return PTR_ERR(wdt->reg); | 193 | return PTR_ERR(wdt->reg); |
196 | 194 | ||
@@ -216,8 +214,8 @@ static int npcm_wdt_probe(struct platform_device *pdev) | |||
216 | set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); | 214 | set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); |
217 | } | 215 | } |
218 | 216 | ||
219 | ret = devm_request_irq(dev, irq, npcm_wdt_interrupt, 0, | 217 | ret = devm_request_irq(dev, irq, npcm_wdt_interrupt, 0, "watchdog", |
220 | "watchdog", wdt); | 218 | wdt); |
221 | if (ret) | 219 | if (ret) |
222 | return ret; | 220 | return ret; |
223 | 221 | ||
diff --git a/drivers/watchdog/nuc900_wdt.c b/drivers/watchdog/nuc900_wdt.c index 8a36350bab7b..f36eae34e848 100644 --- a/drivers/watchdog/nuc900_wdt.c +++ b/drivers/watchdog/nuc900_wdt.c | |||
@@ -242,7 +242,6 @@ static struct miscdevice nuc900wdt_miscdev = { | |||
242 | 242 | ||
243 | static int nuc900wdt_probe(struct platform_device *pdev) | 243 | static int nuc900wdt_probe(struct platform_device *pdev) |
244 | { | 244 | { |
245 | struct resource *res; | ||
246 | int ret = 0; | 245 | int ret = 0; |
247 | 246 | ||
248 | nuc900_wdt = devm_kzalloc(&pdev->dev, sizeof(*nuc900_wdt), | 247 | nuc900_wdt = devm_kzalloc(&pdev->dev, sizeof(*nuc900_wdt), |
@@ -254,8 +253,7 @@ static int nuc900wdt_probe(struct platform_device *pdev) | |||
254 | 253 | ||
255 | spin_lock_init(&nuc900_wdt->wdt_lock); | 254 | spin_lock_init(&nuc900_wdt->wdt_lock); |
256 | 255 | ||
257 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 256 | nuc900_wdt->wdt_base = devm_platform_ioremap_resource(pdev, 0); |
258 | nuc900_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res); | ||
259 | if (IS_ERR(nuc900_wdt->wdt_base)) | 257 | if (IS_ERR(nuc900_wdt->wdt_base)) |
260 | return PTR_ERR(nuc900_wdt->wdt_base); | 258 | return PTR_ERR(nuc900_wdt->wdt_base); |
261 | 259 | ||
diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c index d3f7eb046678..03786992b701 100644 --- a/drivers/watchdog/of_xilinx_wdt.c +++ b/drivers/watchdog/of_xilinx_wdt.c | |||
@@ -151,43 +151,46 @@ static u32 xwdt_selftest(struct xwdt_device *xdev) | |||
151 | return XWT_TIMER_FAILED; | 151 | return XWT_TIMER_FAILED; |
152 | } | 152 | } |
153 | 153 | ||
154 | static void xwdt_clk_disable_unprepare(void *data) | ||
155 | { | ||
156 | clk_disable_unprepare(data); | ||
157 | } | ||
158 | |||
154 | static int xwdt_probe(struct platform_device *pdev) | 159 | static int xwdt_probe(struct platform_device *pdev) |
155 | { | 160 | { |
161 | struct device *dev = &pdev->dev; | ||
156 | int rc; | 162 | int rc; |
157 | u32 pfreq = 0, enable_once = 0; | 163 | u32 pfreq = 0, enable_once = 0; |
158 | struct resource *res; | ||
159 | struct xwdt_device *xdev; | 164 | struct xwdt_device *xdev; |
160 | struct watchdog_device *xilinx_wdt_wdd; | 165 | struct watchdog_device *xilinx_wdt_wdd; |
161 | 166 | ||
162 | xdev = devm_kzalloc(&pdev->dev, sizeof(*xdev), GFP_KERNEL); | 167 | xdev = devm_kzalloc(dev, sizeof(*xdev), GFP_KERNEL); |
163 | if (!xdev) | 168 | if (!xdev) |
164 | return -ENOMEM; | 169 | return -ENOMEM; |
165 | 170 | ||
166 | xilinx_wdt_wdd = &xdev->xilinx_wdt_wdd; | 171 | xilinx_wdt_wdd = &xdev->xilinx_wdt_wdd; |
167 | xilinx_wdt_wdd->info = &xilinx_wdt_ident; | 172 | xilinx_wdt_wdd->info = &xilinx_wdt_ident; |
168 | xilinx_wdt_wdd->ops = &xilinx_wdt_ops; | 173 | xilinx_wdt_wdd->ops = &xilinx_wdt_ops; |
169 | xilinx_wdt_wdd->parent = &pdev->dev; | 174 | xilinx_wdt_wdd->parent = dev; |
170 | 175 | ||
171 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 176 | xdev->base = devm_platform_ioremap_resource(pdev, 0); |
172 | xdev->base = devm_ioremap_resource(&pdev->dev, res); | ||
173 | if (IS_ERR(xdev->base)) | 177 | if (IS_ERR(xdev->base)) |
174 | return PTR_ERR(xdev->base); | 178 | return PTR_ERR(xdev->base); |
175 | 179 | ||
176 | rc = of_property_read_u32(pdev->dev.of_node, "xlnx,wdt-interval", | 180 | rc = of_property_read_u32(dev->of_node, "xlnx,wdt-interval", |
177 | &xdev->wdt_interval); | 181 | &xdev->wdt_interval); |
178 | if (rc) | 182 | if (rc) |
179 | dev_warn(&pdev->dev, | 183 | dev_warn(dev, "Parameter \"xlnx,wdt-interval\" not found\n"); |
180 | "Parameter \"xlnx,wdt-interval\" not found\n"); | ||
181 | 184 | ||
182 | rc = of_property_read_u32(pdev->dev.of_node, "xlnx,wdt-enable-once", | 185 | rc = of_property_read_u32(dev->of_node, "xlnx,wdt-enable-once", |
183 | &enable_once); | 186 | &enable_once); |
184 | if (rc) | 187 | if (rc) |
185 | dev_warn(&pdev->dev, | 188 | dev_warn(dev, |
186 | "Parameter \"xlnx,wdt-enable-once\" not found\n"); | 189 | "Parameter \"xlnx,wdt-enable-once\" not found\n"); |
187 | 190 | ||
188 | watchdog_set_nowayout(xilinx_wdt_wdd, enable_once); | 191 | watchdog_set_nowayout(xilinx_wdt_wdd, enable_once); |
189 | 192 | ||
190 | xdev->clk = devm_clk_get(&pdev->dev, NULL); | 193 | xdev->clk = devm_clk_get(dev, NULL); |
191 | if (IS_ERR(xdev->clk)) { | 194 | if (IS_ERR(xdev->clk)) { |
192 | if (PTR_ERR(xdev->clk) != -ENOENT) | 195 | if (PTR_ERR(xdev->clk) != -ENOENT) |
193 | return PTR_ERR(xdev->clk); | 196 | return PTR_ERR(xdev->clk); |
@@ -198,10 +201,10 @@ static int xwdt_probe(struct platform_device *pdev) | |||
198 | */ | 201 | */ |
199 | xdev->clk = NULL; | 202 | xdev->clk = NULL; |
200 | 203 | ||
201 | rc = of_property_read_u32(pdev->dev.of_node, "clock-frequency", | 204 | rc = of_property_read_u32(dev->of_node, "clock-frequency", |
202 | &pfreq); | 205 | &pfreq); |
203 | if (rc) | 206 | if (rc) |
204 | dev_warn(&pdev->dev, | 207 | dev_warn(dev, |
205 | "The watchdog clock freq cannot be obtained\n"); | 208 | "The watchdog clock freq cannot be obtained\n"); |
206 | } else { | 209 | } else { |
207 | pfreq = clk_get_rate(xdev->clk); | 210 | pfreq = clk_get_rate(xdev->clk); |
@@ -220,44 +223,34 @@ static int xwdt_probe(struct platform_device *pdev) | |||
220 | 223 | ||
221 | rc = clk_prepare_enable(xdev->clk); | 224 | rc = clk_prepare_enable(xdev->clk); |
222 | if (rc) { | 225 | if (rc) { |
223 | dev_err(&pdev->dev, "unable to enable clock\n"); | 226 | dev_err(dev, "unable to enable clock\n"); |
224 | return rc; | 227 | return rc; |
225 | } | 228 | } |
229 | rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare, | ||
230 | xdev->clk); | ||
231 | if (rc) | ||
232 | return rc; | ||
226 | 233 | ||
227 | rc = xwdt_selftest(xdev); | 234 | rc = xwdt_selftest(xdev); |
228 | if (rc == XWT_TIMER_FAILED) { | 235 | if (rc == XWT_TIMER_FAILED) { |
229 | dev_err(&pdev->dev, "SelfTest routine error\n"); | 236 | dev_err(dev, "SelfTest routine error\n"); |
230 | goto err_clk_disable; | 237 | return rc; |
231 | } | 238 | } |
232 | 239 | ||
233 | rc = watchdog_register_device(xilinx_wdt_wdd); | 240 | rc = devm_watchdog_register_device(dev, xilinx_wdt_wdd); |
234 | if (rc) { | 241 | if (rc) { |
235 | dev_err(&pdev->dev, "Cannot register watchdog (err=%d)\n", rc); | 242 | dev_err(dev, "Cannot register watchdog (err=%d)\n", rc); |
236 | goto err_clk_disable; | 243 | return rc; |
237 | } | 244 | } |
238 | 245 | ||
239 | clk_disable(xdev->clk); | 246 | clk_disable(xdev->clk); |
240 | 247 | ||
241 | dev_info(&pdev->dev, "Xilinx Watchdog Timer at %p with timeout %ds\n", | 248 | dev_info(dev, "Xilinx Watchdog Timer at %p with timeout %ds\n", |
242 | xdev->base, xilinx_wdt_wdd->timeout); | 249 | xdev->base, xilinx_wdt_wdd->timeout); |
243 | 250 | ||
244 | platform_set_drvdata(pdev, xdev); | 251 | platform_set_drvdata(pdev, xdev); |
245 | 252 | ||
246 | return 0; | 253 | return 0; |
247 | err_clk_disable: | ||
248 | clk_disable_unprepare(xdev->clk); | ||
249 | |||
250 | return rc; | ||
251 | } | ||
252 | |||
253 | static int xwdt_remove(struct platform_device *pdev) | ||
254 | { | ||
255 | struct xwdt_device *xdev = platform_get_drvdata(pdev); | ||
256 | |||
257 | watchdog_unregister_device(&xdev->xilinx_wdt_wdd); | ||
258 | clk_disable_unprepare(xdev->clk); | ||
259 | |||
260 | return 0; | ||
261 | } | 254 | } |
262 | 255 | ||
263 | /** | 256 | /** |
@@ -305,7 +298,6 @@ MODULE_DEVICE_TABLE(of, xwdt_of_match); | |||
305 | 298 | ||
306 | static struct platform_driver xwdt_driver = { | 299 | static struct platform_driver xwdt_driver = { |
307 | .probe = xwdt_probe, | 300 | .probe = xwdt_probe, |
308 | .remove = xwdt_remove, | ||
309 | .driver = { | 301 | .driver = { |
310 | .name = WATCHDOG_NAME, | 302 | .name = WATCHDOG_NAME, |
311 | .of_match_table = xwdt_of_match, | 303 | .of_match_table = xwdt_of_match, |
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index cbd752f9ac56..d49688d93f6a 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c | |||
@@ -231,7 +231,6 @@ static const struct watchdog_ops omap_wdt_ops = { | |||
231 | static int omap_wdt_probe(struct platform_device *pdev) | 231 | static int omap_wdt_probe(struct platform_device *pdev) |
232 | { | 232 | { |
233 | struct omap_wd_timer_platform_data *pdata = dev_get_platdata(&pdev->dev); | 233 | struct omap_wd_timer_platform_data *pdata = dev_get_platdata(&pdev->dev); |
234 | struct resource *res; | ||
235 | struct omap_wdt_dev *wdev; | 234 | struct omap_wdt_dev *wdev; |
236 | int ret; | 235 | int ret; |
237 | 236 | ||
@@ -245,8 +244,7 @@ static int omap_wdt_probe(struct platform_device *pdev) | |||
245 | mutex_init(&wdev->lock); | 244 | mutex_init(&wdev->lock); |
246 | 245 | ||
247 | /* reserve static register mappings */ | 246 | /* reserve static register mappings */ |
248 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 247 | wdev->base = devm_platform_ioremap_resource(pdev, 0); |
249 | wdev->base = devm_ioremap_resource(&pdev->dev, res); | ||
250 | if (IS_ERR(wdev->base)) | 248 | if (IS_ERR(wdev->base)) |
251 | return PTR_ERR(wdev->base); | 249 | return PTR_ERR(wdev->base); |
252 | 250 | ||
diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index 9db3b09f7568..cdb0d174c5e2 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c | |||
@@ -349,13 +349,6 @@ static unsigned int orion_wdt_get_timeleft(struct watchdog_device *wdt_dev) | |||
349 | return readl(dev->reg + dev->data->wdt_counter_offset) / dev->clk_rate; | 349 | return readl(dev->reg + dev->data->wdt_counter_offset) / dev->clk_rate; |
350 | } | 350 | } |
351 | 351 | ||
352 | static int orion_wdt_set_timeout(struct watchdog_device *wdt_dev, | ||
353 | unsigned int timeout) | ||
354 | { | ||
355 | wdt_dev->timeout = timeout; | ||
356 | return 0; | ||
357 | } | ||
358 | |||
359 | static const struct watchdog_info orion_wdt_info = { | 352 | static const struct watchdog_info orion_wdt_info = { |
360 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, | 353 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, |
361 | .identity = "Orion Watchdog", | 354 | .identity = "Orion Watchdog", |
@@ -366,7 +359,6 @@ static const struct watchdog_ops orion_wdt_ops = { | |||
366 | .start = orion_wdt_start, | 359 | .start = orion_wdt_start, |
367 | .stop = orion_wdt_stop, | 360 | .stop = orion_wdt_stop, |
368 | .ping = orion_wdt_ping, | 361 | .ping = orion_wdt_ping, |
369 | .set_timeout = orion_wdt_set_timeout, | ||
370 | .get_timeleft = orion_wdt_get_timeleft, | 362 | .get_timeleft = orion_wdt_get_timeleft, |
371 | }; | 363 | }; |
372 | 364 | ||
@@ -502,8 +494,7 @@ static int orion_wdt_get_regs(struct platform_device *pdev, | |||
502 | of_device_is_compatible(node, "marvell,armada-xp-wdt")) { | 494 | of_device_is_compatible(node, "marvell,armada-xp-wdt")) { |
503 | 495 | ||
504 | /* Dedicated RSTOUT register, can be requested. */ | 496 | /* Dedicated RSTOUT register, can be requested. */ |
505 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 497 | dev->rstout = devm_platform_ioremap_resource(pdev, 1); |
506 | dev->rstout = devm_ioremap_resource(&pdev->dev, res); | ||
507 | if (IS_ERR(dev->rstout)) | 498 | if (IS_ERR(dev->rstout)) |
508 | return PTR_ERR(dev->rstout); | 499 | return PTR_ERR(dev->rstout); |
509 | 500 | ||
@@ -511,8 +502,7 @@ static int orion_wdt_get_regs(struct platform_device *pdev, | |||
511 | of_device_is_compatible(node, "marvell,armada-380-wdt")) { | 502 | of_device_is_compatible(node, "marvell,armada-380-wdt")) { |
512 | 503 | ||
513 | /* Dedicated RSTOUT register, can be requested. */ | 504 | /* Dedicated RSTOUT register, can be requested. */ |
514 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 505 | dev->rstout = devm_platform_ioremap_resource(pdev, 1); |
515 | dev->rstout = devm_ioremap_resource(&pdev->dev, res); | ||
516 | if (IS_ERR(dev->rstout)) | 506 | if (IS_ERR(dev->rstout)) |
517 | return PTR_ERR(dev->rstout); | 507 | return PTR_ERR(dev->rstout); |
518 | 508 | ||
diff --git a/drivers/watchdog/pic32-dmt.c b/drivers/watchdog/pic32-dmt.c index c797305f8338..9a3c53e03c60 100644 --- a/drivers/watchdog/pic32-dmt.c +++ b/drivers/watchdog/pic32-dmt.c | |||
@@ -168,70 +168,61 @@ static struct watchdog_device pic32_dmt_wdd = { | |||
168 | .ops = &pic32_dmt_fops, | 168 | .ops = &pic32_dmt_fops, |
169 | }; | 169 | }; |
170 | 170 | ||
171 | static void pic32_clk_disable_unprepare(void *data) | ||
172 | { | ||
173 | clk_disable_unprepare(data); | ||
174 | } | ||
175 | |||
171 | static int pic32_dmt_probe(struct platform_device *pdev) | 176 | static int pic32_dmt_probe(struct platform_device *pdev) |
172 | { | 177 | { |
178 | struct device *dev = &pdev->dev; | ||
173 | int ret; | 179 | int ret; |
174 | struct pic32_dmt *dmt; | 180 | struct pic32_dmt *dmt; |
175 | struct resource *mem; | ||
176 | struct watchdog_device *wdd = &pic32_dmt_wdd; | 181 | struct watchdog_device *wdd = &pic32_dmt_wdd; |
177 | 182 | ||
178 | dmt = devm_kzalloc(&pdev->dev, sizeof(*dmt), GFP_KERNEL); | 183 | dmt = devm_kzalloc(dev, sizeof(*dmt), GFP_KERNEL); |
179 | if (!dmt) | 184 | if (!dmt) |
180 | return -ENOMEM; | 185 | return -ENOMEM; |
181 | 186 | ||
182 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 187 | dmt->regs = devm_platform_ioremap_resource(pdev, 0); |
183 | dmt->regs = devm_ioremap_resource(&pdev->dev, mem); | ||
184 | if (IS_ERR(dmt->regs)) | 188 | if (IS_ERR(dmt->regs)) |
185 | return PTR_ERR(dmt->regs); | 189 | return PTR_ERR(dmt->regs); |
186 | 190 | ||
187 | dmt->clk = devm_clk_get(&pdev->dev, NULL); | 191 | dmt->clk = devm_clk_get(dev, NULL); |
188 | if (IS_ERR(dmt->clk)) { | 192 | if (IS_ERR(dmt->clk)) { |
189 | dev_err(&pdev->dev, "clk not found\n"); | 193 | dev_err(dev, "clk not found\n"); |
190 | return PTR_ERR(dmt->clk); | 194 | return PTR_ERR(dmt->clk); |
191 | } | 195 | } |
192 | 196 | ||
193 | ret = clk_prepare_enable(dmt->clk); | 197 | ret = clk_prepare_enable(dmt->clk); |
194 | if (ret) | 198 | if (ret) |
195 | return ret; | 199 | return ret; |
200 | ret = devm_add_action_or_reset(dev, pic32_clk_disable_unprepare, | ||
201 | dmt->clk); | ||
202 | if (ret) | ||
203 | return ret; | ||
196 | 204 | ||
197 | wdd->timeout = pic32_dmt_get_timeout_secs(dmt); | 205 | wdd->timeout = pic32_dmt_get_timeout_secs(dmt); |
198 | if (!wdd->timeout) { | 206 | if (!wdd->timeout) { |
199 | dev_err(&pdev->dev, | 207 | dev_err(dev, "failed to read watchdog register timeout\n"); |
200 | "failed to read watchdog register timeout\n"); | 208 | return -EINVAL; |
201 | ret = -EINVAL; | ||
202 | goto out_disable_clk; | ||
203 | } | 209 | } |
204 | 210 | ||
205 | dev_info(&pdev->dev, "timeout %d\n", wdd->timeout); | 211 | dev_info(dev, "timeout %d\n", wdd->timeout); |
206 | 212 | ||
207 | wdd->bootstatus = pic32_dmt_bootstatus(dmt) ? WDIOF_CARDRESET : 0; | 213 | wdd->bootstatus = pic32_dmt_bootstatus(dmt) ? WDIOF_CARDRESET : 0; |
208 | 214 | ||
209 | watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT); | 215 | watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT); |
210 | watchdog_set_drvdata(wdd, dmt); | 216 | watchdog_set_drvdata(wdd, dmt); |
211 | 217 | ||
212 | ret = watchdog_register_device(wdd); | 218 | ret = devm_watchdog_register_device(dev, wdd); |
213 | if (ret) { | 219 | if (ret) { |
214 | dev_err(&pdev->dev, "watchdog register failed, err %d\n", ret); | 220 | dev_err(dev, "watchdog register failed, err %d\n", ret); |
215 | goto out_disable_clk; | 221 | return ret; |
216 | } | 222 | } |
217 | 223 | ||
218 | platform_set_drvdata(pdev, wdd); | 224 | platform_set_drvdata(pdev, wdd); |
219 | return 0; | 225 | return 0; |
220 | |||
221 | out_disable_clk: | ||
222 | clk_disable_unprepare(dmt->clk); | ||
223 | return ret; | ||
224 | } | ||
225 | |||
226 | static int pic32_dmt_remove(struct platform_device *pdev) | ||
227 | { | ||
228 | struct watchdog_device *wdd = platform_get_drvdata(pdev); | ||
229 | struct pic32_dmt *dmt = watchdog_get_drvdata(wdd); | ||
230 | |||
231 | watchdog_unregister_device(wdd); | ||
232 | clk_disable_unprepare(dmt->clk); | ||
233 | |||
234 | return 0; | ||
235 | } | 226 | } |
236 | 227 | ||
237 | static const struct of_device_id pic32_dmt_of_ids[] = { | 228 | static const struct of_device_id pic32_dmt_of_ids[] = { |
@@ -242,7 +233,6 @@ MODULE_DEVICE_TABLE(of, pic32_dmt_of_ids); | |||
242 | 233 | ||
243 | static struct platform_driver pic32_dmt_driver = { | 234 | static struct platform_driver pic32_dmt_driver = { |
244 | .probe = pic32_dmt_probe, | 235 | .probe = pic32_dmt_probe, |
245 | .remove = pic32_dmt_remove, | ||
246 | .driver = { | 236 | .driver = { |
247 | .name = "pic32-dmt", | 237 | .name = "pic32-dmt", |
248 | .of_match_table = of_match_ptr(pic32_dmt_of_ids), | 238 | .of_match_table = of_match_ptr(pic32_dmt_of_ids), |
diff --git a/drivers/watchdog/pic32-wdt.c b/drivers/watchdog/pic32-wdt.c index e2761068dc6f..540500940cc0 100644 --- a/drivers/watchdog/pic32-wdt.c +++ b/drivers/watchdog/pic32-wdt.c | |||
@@ -166,89 +166,77 @@ static const struct of_device_id pic32_wdt_dt_ids[] = { | |||
166 | }; | 166 | }; |
167 | MODULE_DEVICE_TABLE(of, pic32_wdt_dt_ids); | 167 | MODULE_DEVICE_TABLE(of, pic32_wdt_dt_ids); |
168 | 168 | ||
169 | static void pic32_clk_disable_unprepare(void *data) | ||
170 | { | ||
171 | clk_disable_unprepare(data); | ||
172 | } | ||
173 | |||
169 | static int pic32_wdt_drv_probe(struct platform_device *pdev) | 174 | static int pic32_wdt_drv_probe(struct platform_device *pdev) |
170 | { | 175 | { |
176 | struct device *dev = &pdev->dev; | ||
171 | int ret; | 177 | int ret; |
172 | struct watchdog_device *wdd = &pic32_wdd; | 178 | struct watchdog_device *wdd = &pic32_wdd; |
173 | struct pic32_wdt *wdt; | 179 | struct pic32_wdt *wdt; |
174 | struct resource *mem; | ||
175 | 180 | ||
176 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 181 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
177 | if (!wdt) | 182 | if (!wdt) |
178 | return -ENOMEM; | 183 | return -ENOMEM; |
179 | 184 | ||
180 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 185 | wdt->regs = devm_platform_ioremap_resource(pdev, 0); |
181 | wdt->regs = devm_ioremap_resource(&pdev->dev, mem); | ||
182 | if (IS_ERR(wdt->regs)) | 186 | if (IS_ERR(wdt->regs)) |
183 | return PTR_ERR(wdt->regs); | 187 | return PTR_ERR(wdt->regs); |
184 | 188 | ||
185 | wdt->rst_base = devm_ioremap(&pdev->dev, PIC32_BASE_RESET, 0x10); | 189 | wdt->rst_base = devm_ioremap(dev, PIC32_BASE_RESET, 0x10); |
186 | if (!wdt->rst_base) | 190 | if (!wdt->rst_base) |
187 | return -ENOMEM; | 191 | return -ENOMEM; |
188 | 192 | ||
189 | wdt->clk = devm_clk_get(&pdev->dev, NULL); | 193 | wdt->clk = devm_clk_get(dev, NULL); |
190 | if (IS_ERR(wdt->clk)) { | 194 | if (IS_ERR(wdt->clk)) { |
191 | dev_err(&pdev->dev, "clk not found\n"); | 195 | dev_err(dev, "clk not found\n"); |
192 | return PTR_ERR(wdt->clk); | 196 | return PTR_ERR(wdt->clk); |
193 | } | 197 | } |
194 | 198 | ||
195 | ret = clk_prepare_enable(wdt->clk); | 199 | ret = clk_prepare_enable(wdt->clk); |
196 | if (ret) { | 200 | if (ret) { |
197 | dev_err(&pdev->dev, "clk enable failed\n"); | 201 | dev_err(dev, "clk enable failed\n"); |
198 | return ret; | 202 | return ret; |
199 | } | 203 | } |
204 | ret = devm_add_action_or_reset(dev, pic32_clk_disable_unprepare, | ||
205 | wdt->clk); | ||
206 | if (ret) | ||
207 | return ret; | ||
200 | 208 | ||
201 | if (pic32_wdt_is_win_enabled(wdt)) { | 209 | if (pic32_wdt_is_win_enabled(wdt)) { |
202 | dev_err(&pdev->dev, "windowed-clear mode is not supported.\n"); | 210 | dev_err(dev, "windowed-clear mode is not supported.\n"); |
203 | ret = -ENODEV; | 211 | return -ENODEV; |
204 | goto out_disable_clk; | ||
205 | } | 212 | } |
206 | 213 | ||
207 | wdd->timeout = pic32_wdt_get_timeout_secs(wdt, &pdev->dev); | 214 | wdd->timeout = pic32_wdt_get_timeout_secs(wdt, dev); |
208 | if (!wdd->timeout) { | 215 | if (!wdd->timeout) { |
209 | dev_err(&pdev->dev, | 216 | dev_err(dev, "failed to read watchdog register timeout\n"); |
210 | "failed to read watchdog register timeout\n"); | 217 | return -EINVAL; |
211 | ret = -EINVAL; | ||
212 | goto out_disable_clk; | ||
213 | } | 218 | } |
214 | 219 | ||
215 | dev_info(&pdev->dev, "timeout %d\n", wdd->timeout); | 220 | dev_info(dev, "timeout %d\n", wdd->timeout); |
216 | 221 | ||
217 | wdd->bootstatus = pic32_wdt_bootstatus(wdt) ? WDIOF_CARDRESET : 0; | 222 | wdd->bootstatus = pic32_wdt_bootstatus(wdt) ? WDIOF_CARDRESET : 0; |
218 | 223 | ||
219 | watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT); | 224 | watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT); |
220 | watchdog_set_drvdata(wdd, wdt); | 225 | watchdog_set_drvdata(wdd, wdt); |
221 | 226 | ||
222 | ret = watchdog_register_device(wdd); | 227 | ret = devm_watchdog_register_device(dev, wdd); |
223 | if (ret) { | 228 | if (ret) { |
224 | dev_err(&pdev->dev, "watchdog register failed, err %d\n", ret); | 229 | dev_err(dev, "watchdog register failed, err %d\n", ret); |
225 | goto out_disable_clk; | 230 | return ret; |
226 | } | 231 | } |
227 | 232 | ||
228 | platform_set_drvdata(pdev, wdd); | 233 | platform_set_drvdata(pdev, wdd); |
229 | 234 | ||
230 | return 0; | 235 | return 0; |
231 | |||
232 | out_disable_clk: | ||
233 | clk_disable_unprepare(wdt->clk); | ||
234 | |||
235 | return ret; | ||
236 | } | ||
237 | |||
238 | static int pic32_wdt_drv_remove(struct platform_device *pdev) | ||
239 | { | ||
240 | struct watchdog_device *wdd = platform_get_drvdata(pdev); | ||
241 | struct pic32_wdt *wdt = watchdog_get_drvdata(wdd); | ||
242 | |||
243 | watchdog_unregister_device(wdd); | ||
244 | clk_disable_unprepare(wdt->clk); | ||
245 | |||
246 | return 0; | ||
247 | } | 236 | } |
248 | 237 | ||
249 | static struct platform_driver pic32_wdt_driver = { | 238 | static struct platform_driver pic32_wdt_driver = { |
250 | .probe = pic32_wdt_drv_probe, | 239 | .probe = pic32_wdt_drv_probe, |
251 | .remove = pic32_wdt_drv_remove, | ||
252 | .driver = { | 240 | .driver = { |
253 | .name = "pic32-wdt", | 241 | .name = "pic32-wdt", |
254 | .of_match_table = of_match_ptr(pic32_wdt_dt_ids), | 242 | .of_match_table = of_match_ptr(pic32_wdt_dt_ids), |
diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c index 7f10041fcf5b..2d3652004e39 100644 --- a/drivers/watchdog/pm8916_wdt.c +++ b/drivers/watchdog/pm8916_wdt.c | |||
@@ -132,15 +132,16 @@ static const struct watchdog_ops pm8916_wdt_ops = { | |||
132 | 132 | ||
133 | static int pm8916_wdt_probe(struct platform_device *pdev) | 133 | static int pm8916_wdt_probe(struct platform_device *pdev) |
134 | { | 134 | { |
135 | struct device *dev = &pdev->dev; | ||
135 | struct pm8916_wdt *wdt; | 136 | struct pm8916_wdt *wdt; |
136 | struct device *parent; | 137 | struct device *parent; |
137 | int err, irq; | 138 | int err, irq; |
138 | 139 | ||
139 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 140 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
140 | if (!wdt) | 141 | if (!wdt) |
141 | return -ENOMEM; | 142 | return -ENOMEM; |
142 | 143 | ||
143 | parent = pdev->dev.parent; | 144 | parent = dev->parent; |
144 | 145 | ||
145 | /* | 146 | /* |
146 | * The pm8916-pon-wdt is a child of the pon device, which is a child | 147 | * The pm8916-pon-wdt is a child of the pon device, which is a child |
@@ -150,20 +151,20 @@ static int pm8916_wdt_probe(struct platform_device *pdev) | |||
150 | */ | 151 | */ |
151 | wdt->regmap = dev_get_regmap(parent->parent, NULL); | 152 | wdt->regmap = dev_get_regmap(parent->parent, NULL); |
152 | if (!wdt->regmap) { | 153 | if (!wdt->regmap) { |
153 | dev_err(&pdev->dev, "failed to locate regmap\n"); | 154 | dev_err(dev, "failed to locate regmap\n"); |
154 | return -ENODEV; | 155 | return -ENODEV; |
155 | } | 156 | } |
156 | 157 | ||
157 | err = device_property_read_u32(parent, "reg", &wdt->baseaddr); | 158 | err = device_property_read_u32(parent, "reg", &wdt->baseaddr); |
158 | if (err) { | 159 | if (err) { |
159 | dev_err(&pdev->dev, "failed to get pm8916-pon address\n"); | 160 | dev_err(dev, "failed to get pm8916-pon address\n"); |
160 | return err; | 161 | return err; |
161 | } | 162 | } |
162 | 163 | ||
163 | irq = platform_get_irq(pdev, 0); | 164 | irq = platform_get_irq(pdev, 0); |
164 | if (irq > 0) { | 165 | if (irq > 0) { |
165 | if (devm_request_irq(&pdev->dev, irq, pm8916_wdt_isr, 0, | 166 | if (devm_request_irq(dev, irq, pm8916_wdt_isr, 0, "pm8916_wdt", |
166 | "pm8916_wdt", wdt)) | 167 | wdt)) |
167 | irq = 0; | 168 | irq = 0; |
168 | } | 169 | } |
169 | 170 | ||
@@ -172,23 +173,23 @@ static int pm8916_wdt_probe(struct platform_device *pdev) | |||
172 | wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL, | 173 | wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL, |
173 | RESET_TYPE_HARD); | 174 | RESET_TYPE_HARD); |
174 | if (err) { | 175 | if (err) { |
175 | dev_err(&pdev->dev, "failed configure watchdog\n"); | 176 | dev_err(dev, "failed configure watchdog\n"); |
176 | return err; | 177 | return err; |
177 | } | 178 | } |
178 | 179 | ||
179 | wdt->wdev.info = (irq > 0) ? &pm8916_wdt_pt_ident : &pm8916_wdt_ident, | 180 | wdt->wdev.info = (irq > 0) ? &pm8916_wdt_pt_ident : &pm8916_wdt_ident, |
180 | wdt->wdev.ops = &pm8916_wdt_ops, | 181 | wdt->wdev.ops = &pm8916_wdt_ops, |
181 | wdt->wdev.parent = &pdev->dev; | 182 | wdt->wdev.parent = dev; |
182 | wdt->wdev.min_timeout = PM8916_WDT_MIN_TIMEOUT; | 183 | wdt->wdev.min_timeout = PM8916_WDT_MIN_TIMEOUT; |
183 | wdt->wdev.max_timeout = PM8916_WDT_MAX_TIMEOUT; | 184 | wdt->wdev.max_timeout = PM8916_WDT_MAX_TIMEOUT; |
184 | wdt->wdev.timeout = PM8916_WDT_DEFAULT_TIMEOUT; | 185 | wdt->wdev.timeout = PM8916_WDT_DEFAULT_TIMEOUT; |
185 | wdt->wdev.pretimeout = 0; | 186 | wdt->wdev.pretimeout = 0; |
186 | watchdog_set_drvdata(&wdt->wdev, wdt); | 187 | watchdog_set_drvdata(&wdt->wdev, wdt); |
187 | 188 | ||
188 | watchdog_init_timeout(&wdt->wdev, 0, &pdev->dev); | 189 | watchdog_init_timeout(&wdt->wdev, 0, dev); |
189 | pm8916_wdt_configure_timers(&wdt->wdev); | 190 | pm8916_wdt_configure_timers(&wdt->wdev); |
190 | 191 | ||
191 | return devm_watchdog_register_device(&pdev->dev, &wdt->wdev); | 192 | return devm_watchdog_register_device(dev, &wdt->wdev); |
192 | } | 193 | } |
193 | 194 | ||
194 | static const struct of_device_id pm8916_wdt_id_table[] = { | 195 | static const struct of_device_id pm8916_wdt_id_table[] = { |
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c index 8e261799c84e..d9e03544aeae 100644 --- a/drivers/watchdog/pnx4008_wdt.c +++ b/drivers/watchdog/pnx4008_wdt.c | |||
@@ -183,54 +183,50 @@ static struct watchdog_device pnx4008_wdd = { | |||
183 | .max_timeout = MAX_HEARTBEAT, | 183 | .max_timeout = MAX_HEARTBEAT, |
184 | }; | 184 | }; |
185 | 185 | ||
186 | static void pnx4008_clk_disable_unprepare(void *data) | ||
187 | { | ||
188 | clk_disable_unprepare(data); | ||
189 | } | ||
190 | |||
186 | static int pnx4008_wdt_probe(struct platform_device *pdev) | 191 | static int pnx4008_wdt_probe(struct platform_device *pdev) |
187 | { | 192 | { |
188 | struct resource *r; | 193 | struct device *dev = &pdev->dev; |
189 | int ret = 0; | 194 | int ret = 0; |
190 | 195 | ||
191 | watchdog_init_timeout(&pnx4008_wdd, heartbeat, &pdev->dev); | 196 | watchdog_init_timeout(&pnx4008_wdd, heartbeat, dev); |
192 | 197 | ||
193 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 198 | wdt_base = devm_platform_ioremap_resource(pdev, 0); |
194 | wdt_base = devm_ioremap_resource(&pdev->dev, r); | ||
195 | if (IS_ERR(wdt_base)) | 199 | if (IS_ERR(wdt_base)) |
196 | return PTR_ERR(wdt_base); | 200 | return PTR_ERR(wdt_base); |
197 | 201 | ||
198 | wdt_clk = devm_clk_get(&pdev->dev, NULL); | 202 | wdt_clk = devm_clk_get(dev, NULL); |
199 | if (IS_ERR(wdt_clk)) | 203 | if (IS_ERR(wdt_clk)) |
200 | return PTR_ERR(wdt_clk); | 204 | return PTR_ERR(wdt_clk); |
201 | 205 | ||
202 | ret = clk_prepare_enable(wdt_clk); | 206 | ret = clk_prepare_enable(wdt_clk); |
203 | if (ret) | 207 | if (ret) |
204 | return ret; | 208 | return ret; |
209 | ret = devm_add_action_or_reset(dev, pnx4008_clk_disable_unprepare, | ||
210 | wdt_clk); | ||
211 | if (ret) | ||
212 | return ret; | ||
205 | 213 | ||
206 | pnx4008_wdd.bootstatus = (readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ? | 214 | pnx4008_wdd.bootstatus = (readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ? |
207 | WDIOF_CARDRESET : 0; | 215 | WDIOF_CARDRESET : 0; |
208 | pnx4008_wdd.parent = &pdev->dev; | 216 | pnx4008_wdd.parent = dev; |
209 | watchdog_set_nowayout(&pnx4008_wdd, nowayout); | 217 | watchdog_set_nowayout(&pnx4008_wdd, nowayout); |
210 | watchdog_set_restart_priority(&pnx4008_wdd, 128); | 218 | watchdog_set_restart_priority(&pnx4008_wdd, 128); |
211 | 219 | ||
212 | pnx4008_wdt_stop(&pnx4008_wdd); /* disable for now */ | 220 | if (readl(WDTIM_CTRL(wdt_base)) & COUNT_ENAB) |
221 | set_bit(WDOG_HW_RUNNING, &pnx4008_wdd.status); | ||
213 | 222 | ||
214 | ret = watchdog_register_device(&pnx4008_wdd); | 223 | ret = devm_watchdog_register_device(dev, &pnx4008_wdd); |
215 | if (ret < 0) { | 224 | if (ret < 0) { |
216 | dev_err(&pdev->dev, "cannot register watchdog device\n"); | 225 | dev_err(dev, "cannot register watchdog device\n"); |
217 | goto disable_clk; | 226 | return ret; |
218 | } | 227 | } |
219 | 228 | ||
220 | dev_info(&pdev->dev, "heartbeat %d sec\n", pnx4008_wdd.timeout); | 229 | dev_info(dev, "heartbeat %d sec\n", pnx4008_wdd.timeout); |
221 | |||
222 | return 0; | ||
223 | |||
224 | disable_clk: | ||
225 | clk_disable_unprepare(wdt_clk); | ||
226 | return ret; | ||
227 | } | ||
228 | |||
229 | static int pnx4008_wdt_remove(struct platform_device *pdev) | ||
230 | { | ||
231 | watchdog_unregister_device(&pnx4008_wdd); | ||
232 | |||
233 | clk_disable_unprepare(wdt_clk); | ||
234 | 230 | ||
235 | return 0; | 231 | return 0; |
236 | } | 232 | } |
@@ -249,7 +245,6 @@ static struct platform_driver platform_wdt_driver = { | |||
249 | .of_match_table = of_match_ptr(pnx4008_wdt_match), | 245 | .of_match_table = of_match_ptr(pnx4008_wdt_match), |
250 | }, | 246 | }, |
251 | .probe = pnx4008_wdt_probe, | 247 | .probe = pnx4008_wdt_probe, |
252 | .remove = pnx4008_wdt_remove, | ||
253 | }; | 248 | }; |
254 | 249 | ||
255 | module_platform_driver(platform_wdt_driver); | 250 | module_platform_driver(platform_wdt_driver); |
diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c index 5dfd604477a4..6d29c33b1316 100644 --- a/drivers/watchdog/qcom-wdt.c +++ b/drivers/watchdog/qcom-wdt.c | |||
@@ -142,22 +142,28 @@ static const struct watchdog_info qcom_wdt_info = { | |||
142 | .identity = KBUILD_MODNAME, | 142 | .identity = KBUILD_MODNAME, |
143 | }; | 143 | }; |
144 | 144 | ||
145 | static void qcom_clk_disable_unprepare(void *data) | ||
146 | { | ||
147 | clk_disable_unprepare(data); | ||
148 | } | ||
149 | |||
145 | static int qcom_wdt_probe(struct platform_device *pdev) | 150 | static int qcom_wdt_probe(struct platform_device *pdev) |
146 | { | 151 | { |
152 | struct device *dev = &pdev->dev; | ||
147 | struct qcom_wdt *wdt; | 153 | struct qcom_wdt *wdt; |
148 | struct resource *res; | 154 | struct resource *res; |
149 | struct device_node *np = pdev->dev.of_node; | 155 | struct device_node *np = dev->of_node; |
150 | const u32 *regs; | 156 | const u32 *regs; |
151 | u32 percpu_offset; | 157 | u32 percpu_offset; |
152 | int ret; | 158 | int ret; |
153 | 159 | ||
154 | regs = of_device_get_match_data(&pdev->dev); | 160 | regs = of_device_get_match_data(dev); |
155 | if (!regs) { | 161 | if (!regs) { |
156 | dev_err(&pdev->dev, "Unsupported QCOM WDT module\n"); | 162 | dev_err(dev, "Unsupported QCOM WDT module\n"); |
157 | return -ENODEV; | 163 | return -ENODEV; |
158 | } | 164 | } |
159 | 165 | ||
160 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 166 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
161 | if (!wdt) | 167 | if (!wdt) |
162 | return -ENOMEM; | 168 | return -ENOMEM; |
163 | 169 | ||
@@ -172,21 +178,25 @@ static int qcom_wdt_probe(struct platform_device *pdev) | |||
172 | res->start += percpu_offset; | 178 | res->start += percpu_offset; |
173 | res->end += percpu_offset; | 179 | res->end += percpu_offset; |
174 | 180 | ||
175 | wdt->base = devm_ioremap_resource(&pdev->dev, res); | 181 | wdt->base = devm_ioremap_resource(dev, res); |
176 | if (IS_ERR(wdt->base)) | 182 | if (IS_ERR(wdt->base)) |
177 | return PTR_ERR(wdt->base); | 183 | return PTR_ERR(wdt->base); |
178 | 184 | ||
179 | wdt->clk = devm_clk_get(&pdev->dev, NULL); | 185 | wdt->clk = devm_clk_get(dev, NULL); |
180 | if (IS_ERR(wdt->clk)) { | 186 | if (IS_ERR(wdt->clk)) { |
181 | dev_err(&pdev->dev, "failed to get input clock\n"); | 187 | dev_err(dev, "failed to get input clock\n"); |
182 | return PTR_ERR(wdt->clk); | 188 | return PTR_ERR(wdt->clk); |
183 | } | 189 | } |
184 | 190 | ||
185 | ret = clk_prepare_enable(wdt->clk); | 191 | ret = clk_prepare_enable(wdt->clk); |
186 | if (ret) { | 192 | if (ret) { |
187 | dev_err(&pdev->dev, "failed to setup clock\n"); | 193 | dev_err(dev, "failed to setup clock\n"); |
188 | return ret; | 194 | return ret; |
189 | } | 195 | } |
196 | ret = devm_add_action_or_reset(dev, qcom_clk_disable_unprepare, | ||
197 | wdt->clk); | ||
198 | if (ret) | ||
199 | return ret; | ||
190 | 200 | ||
191 | /* | 201 | /* |
192 | * We use the clock rate to calculate the max timeout, so ensure it's | 202 | * We use the clock rate to calculate the max timeout, so ensure it's |
@@ -199,16 +209,15 @@ static int qcom_wdt_probe(struct platform_device *pdev) | |||
199 | wdt->rate = clk_get_rate(wdt->clk); | 209 | wdt->rate = clk_get_rate(wdt->clk); |
200 | if (wdt->rate == 0 || | 210 | if (wdt->rate == 0 || |
201 | wdt->rate > 0x10000000U) { | 211 | wdt->rate > 0x10000000U) { |
202 | dev_err(&pdev->dev, "invalid clock rate\n"); | 212 | dev_err(dev, "invalid clock rate\n"); |
203 | ret = -EINVAL; | 213 | return -EINVAL; |
204 | goto err_clk_unprepare; | ||
205 | } | 214 | } |
206 | 215 | ||
207 | wdt->wdd.info = &qcom_wdt_info; | 216 | wdt->wdd.info = &qcom_wdt_info; |
208 | wdt->wdd.ops = &qcom_wdt_ops; | 217 | wdt->wdd.ops = &qcom_wdt_ops; |
209 | wdt->wdd.min_timeout = 1; | 218 | wdt->wdd.min_timeout = 1; |
210 | wdt->wdd.max_timeout = 0x10000000U / wdt->rate; | 219 | wdt->wdd.max_timeout = 0x10000000U / wdt->rate; |
211 | wdt->wdd.parent = &pdev->dev; | 220 | wdt->wdd.parent = dev; |
212 | wdt->layout = regs; | 221 | wdt->layout = regs; |
213 | 222 | ||
214 | if (readl(wdt_addr(wdt, WDT_STS)) & 1) | 223 | if (readl(wdt_addr(wdt, WDT_STS)) & 1) |
@@ -220,29 +229,16 @@ static int qcom_wdt_probe(struct platform_device *pdev) | |||
220 | * the max instead. | 229 | * the max instead. |
221 | */ | 230 | */ |
222 | wdt->wdd.timeout = min(wdt->wdd.max_timeout, 30U); | 231 | wdt->wdd.timeout = min(wdt->wdd.max_timeout, 30U); |
223 | watchdog_init_timeout(&wdt->wdd, 0, &pdev->dev); | 232 | watchdog_init_timeout(&wdt->wdd, 0, dev); |
224 | 233 | ||
225 | ret = watchdog_register_device(&wdt->wdd); | 234 | ret = devm_watchdog_register_device(dev, &wdt->wdd); |
226 | if (ret) { | 235 | if (ret) { |
227 | dev_err(&pdev->dev, "failed to register watchdog\n"); | 236 | dev_err(dev, "failed to register watchdog\n"); |
228 | goto err_clk_unprepare; | 237 | return ret; |
229 | } | 238 | } |
230 | 239 | ||
231 | platform_set_drvdata(pdev, wdt); | 240 | platform_set_drvdata(pdev, wdt); |
232 | return 0; | 241 | return 0; |
233 | |||
234 | err_clk_unprepare: | ||
235 | clk_disable_unprepare(wdt->clk); | ||
236 | return ret; | ||
237 | } | ||
238 | |||
239 | static int qcom_wdt_remove(struct platform_device *pdev) | ||
240 | { | ||
241 | struct qcom_wdt *wdt = platform_get_drvdata(pdev); | ||
242 | |||
243 | watchdog_unregister_device(&wdt->wdd); | ||
244 | clk_disable_unprepare(wdt->clk); | ||
245 | return 0; | ||
246 | } | 242 | } |
247 | 243 | ||
248 | static int __maybe_unused qcom_wdt_suspend(struct device *dev) | 244 | static int __maybe_unused qcom_wdt_suspend(struct device *dev) |
@@ -277,7 +273,6 @@ MODULE_DEVICE_TABLE(of, qcom_wdt_of_table); | |||
277 | 273 | ||
278 | static struct platform_driver qcom_watchdog_driver = { | 274 | static struct platform_driver qcom_watchdog_driver = { |
279 | .probe = qcom_wdt_probe, | 275 | .probe = qcom_wdt_probe, |
280 | .remove = qcom_wdt_remove, | ||
281 | .driver = { | 276 | .driver = { |
282 | .name = KBUILD_MODNAME, | 277 | .name = KBUILD_MODNAME, |
283 | .of_match_table = qcom_wdt_of_table, | 278 | .of_match_table = qcom_wdt_of_table, |
diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c index 622ede529912..565dbc1ec638 100644 --- a/drivers/watchdog/renesas_wdt.c +++ b/drivers/watchdog/renesas_wdt.c | |||
@@ -151,7 +151,6 @@ static const struct soc_device_attribute rwdt_quirks_match[] = { | |||
151 | .data = (void *)1, /* needs single CPU */ | 151 | .data = (void *)1, /* needs single CPU */ |
152 | }, { | 152 | }, { |
153 | .soc_id = "r8a7792", | 153 | .soc_id = "r8a7792", |
154 | .revision = "*", | ||
155 | .data = (void *)0, /* needs SMP disabled */ | 154 | .data = (void *)0, /* needs SMP disabled */ |
156 | }, | 155 | }, |
157 | { /* sentinel */ } | 156 | { /* sentinel */ } |
@@ -177,7 +176,6 @@ static inline bool rwdt_blacklisted(struct device *dev) { return false; } | |||
177 | static int rwdt_probe(struct platform_device *pdev) | 176 | static int rwdt_probe(struct platform_device *pdev) |
178 | { | 177 | { |
179 | struct rwdt_priv *priv; | 178 | struct rwdt_priv *priv; |
180 | struct resource *res; | ||
181 | struct clk *clk; | 179 | struct clk *clk; |
182 | unsigned long clks_per_sec; | 180 | unsigned long clks_per_sec; |
183 | int ret, i; | 181 | int ret, i; |
@@ -189,8 +187,7 @@ static int rwdt_probe(struct platform_device *pdev) | |||
189 | if (!priv) | 187 | if (!priv) |
190 | return -ENOMEM; | 188 | return -ENOMEM; |
191 | 189 | ||
192 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 190 | priv->base = devm_platform_ioremap_resource(pdev, 0); |
193 | priv->base = devm_ioremap_resource(&pdev->dev, res); | ||
194 | if (IS_ERR(priv->base)) | 191 | if (IS_ERR(priv->base)) |
195 | return PTR_ERR(priv->base); | 192 | return PTR_ERR(priv->base); |
196 | 193 | ||
@@ -238,9 +235,7 @@ static int rwdt_probe(struct platform_device *pdev) | |||
238 | watchdog_stop_on_unregister(&priv->wdev); | 235 | watchdog_stop_on_unregister(&priv->wdev); |
239 | 236 | ||
240 | /* This overrides the default timeout only if DT configuration was found */ | 237 | /* This overrides the default timeout only if DT configuration was found */ |
241 | ret = watchdog_init_timeout(&priv->wdev, 0, &pdev->dev); | 238 | watchdog_init_timeout(&priv->wdev, 0, &pdev->dev); |
242 | if (ret) | ||
243 | dev_warn(&pdev->dev, "Specified timeout value invalid, using default\n"); | ||
244 | 239 | ||
245 | ret = watchdog_register_device(&priv->wdev); | 240 | ret = watchdog_register_device(&priv->wdev); |
246 | if (ret < 0) | 241 | if (ret < 0) |
diff --git a/drivers/watchdog/rn5t618_wdt.c b/drivers/watchdog/rn5t618_wdt.c index e60f55702ab7..21fcb36f9074 100644 --- a/drivers/watchdog/rn5t618_wdt.c +++ b/drivers/watchdog/rn5t618_wdt.c | |||
@@ -146,11 +146,12 @@ static const struct watchdog_ops rn5t618_wdt_ops = { | |||
146 | 146 | ||
147 | static int rn5t618_wdt_probe(struct platform_device *pdev) | 147 | static int rn5t618_wdt_probe(struct platform_device *pdev) |
148 | { | 148 | { |
149 | struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); | 149 | struct device *dev = &pdev->dev; |
150 | struct rn5t618 *rn5t618 = dev_get_drvdata(dev->parent); | ||
150 | struct rn5t618_wdt *wdt; | 151 | struct rn5t618_wdt *wdt; |
151 | int min_timeout, max_timeout; | 152 | int min_timeout, max_timeout; |
152 | 153 | ||
153 | wdt = devm_kzalloc(&pdev->dev, sizeof(struct rn5t618_wdt), GFP_KERNEL); | 154 | wdt = devm_kzalloc(dev, sizeof(struct rn5t618_wdt), GFP_KERNEL); |
154 | if (!wdt) | 155 | if (!wdt) |
155 | return -ENOMEM; | 156 | return -ENOMEM; |
156 | 157 | ||
@@ -163,10 +164,10 @@ static int rn5t618_wdt_probe(struct platform_device *pdev) | |||
163 | wdt->wdt_dev.min_timeout = min_timeout; | 164 | wdt->wdt_dev.min_timeout = min_timeout; |
164 | wdt->wdt_dev.max_timeout = max_timeout; | 165 | wdt->wdt_dev.max_timeout = max_timeout; |
165 | wdt->wdt_dev.timeout = max_timeout; | 166 | wdt->wdt_dev.timeout = max_timeout; |
166 | wdt->wdt_dev.parent = &pdev->dev; | 167 | wdt->wdt_dev.parent = dev; |
167 | 168 | ||
168 | watchdog_set_drvdata(&wdt->wdt_dev, wdt); | 169 | watchdog_set_drvdata(&wdt->wdt_dev, wdt); |
169 | watchdog_init_timeout(&wdt->wdt_dev, timeout, &pdev->dev); | 170 | watchdog_init_timeout(&wdt->wdt_dev, timeout, dev); |
170 | watchdog_set_nowayout(&wdt->wdt_dev, nowayout); | 171 | watchdog_set_nowayout(&wdt->wdt_dev, nowayout); |
171 | 172 | ||
172 | platform_set_drvdata(pdev, wdt); | 173 | platform_set_drvdata(pdev, wdt); |
diff --git a/drivers/watchdog/rt2880_wdt.c b/drivers/watchdog/rt2880_wdt.c index db7c57d82cfd..905e60f45eec 100644 --- a/drivers/watchdog/rt2880_wdt.c +++ b/drivers/watchdog/rt2880_wdt.c | |||
@@ -141,19 +141,18 @@ static struct watchdog_device rt288x_wdt_dev = { | |||
141 | 141 | ||
142 | static int rt288x_wdt_probe(struct platform_device *pdev) | 142 | static int rt288x_wdt_probe(struct platform_device *pdev) |
143 | { | 143 | { |
144 | struct resource *res; | 144 | struct device *dev = &pdev->dev; |
145 | int ret; | 145 | int ret; |
146 | 146 | ||
147 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 147 | rt288x_wdt_base = devm_platform_ioremap_resource(pdev, 0); |
148 | rt288x_wdt_base = devm_ioremap_resource(&pdev->dev, res); | ||
149 | if (IS_ERR(rt288x_wdt_base)) | 148 | if (IS_ERR(rt288x_wdt_base)) |
150 | return PTR_ERR(rt288x_wdt_base); | 149 | return PTR_ERR(rt288x_wdt_base); |
151 | 150 | ||
152 | rt288x_wdt_clk = devm_clk_get(&pdev->dev, NULL); | 151 | rt288x_wdt_clk = devm_clk_get(dev, NULL); |
153 | if (IS_ERR(rt288x_wdt_clk)) | 152 | if (IS_ERR(rt288x_wdt_clk)) |
154 | return PTR_ERR(rt288x_wdt_clk); | 153 | return PTR_ERR(rt288x_wdt_clk); |
155 | 154 | ||
156 | rt288x_wdt_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); | 155 | rt288x_wdt_reset = devm_reset_control_get_exclusive(dev, NULL); |
157 | if (!IS_ERR(rt288x_wdt_reset)) | 156 | if (!IS_ERR(rt288x_wdt_reset)) |
158 | reset_control_deassert(rt288x_wdt_reset); | 157 | reset_control_deassert(rt288x_wdt_reset); |
159 | 158 | ||
@@ -161,31 +160,20 @@ static int rt288x_wdt_probe(struct platform_device *pdev) | |||
161 | 160 | ||
162 | rt288x_wdt_dev.bootstatus = rt288x_wdt_bootcause(); | 161 | rt288x_wdt_dev.bootstatus = rt288x_wdt_bootcause(); |
163 | rt288x_wdt_dev.max_timeout = (0xfffful / rt288x_wdt_freq); | 162 | rt288x_wdt_dev.max_timeout = (0xfffful / rt288x_wdt_freq); |
164 | rt288x_wdt_dev.parent = &pdev->dev; | 163 | rt288x_wdt_dev.parent = dev; |
165 | 164 | ||
166 | watchdog_init_timeout(&rt288x_wdt_dev, rt288x_wdt_dev.max_timeout, | 165 | watchdog_init_timeout(&rt288x_wdt_dev, rt288x_wdt_dev.max_timeout, |
167 | &pdev->dev); | 166 | dev); |
168 | watchdog_set_nowayout(&rt288x_wdt_dev, nowayout); | 167 | watchdog_set_nowayout(&rt288x_wdt_dev, nowayout); |
169 | 168 | ||
170 | ret = watchdog_register_device(&rt288x_wdt_dev); | 169 | watchdog_stop_on_reboot(&rt288x_wdt_dev); |
170 | ret = devm_watchdog_register_device(dev, &rt288x_wdt_dev); | ||
171 | if (!ret) | 171 | if (!ret) |
172 | dev_info(&pdev->dev, "Initialized\n"); | 172 | dev_info(dev, "Initialized\n"); |
173 | 173 | ||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | 176 | ||
177 | static int rt288x_wdt_remove(struct platform_device *pdev) | ||
178 | { | ||
179 | watchdog_unregister_device(&rt288x_wdt_dev); | ||
180 | |||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | static void rt288x_wdt_shutdown(struct platform_device *pdev) | ||
185 | { | ||
186 | rt288x_wdt_stop(&rt288x_wdt_dev); | ||
187 | } | ||
188 | |||
189 | static const struct of_device_id rt288x_wdt_match[] = { | 177 | static const struct of_device_id rt288x_wdt_match[] = { |
190 | { .compatible = "ralink,rt2880-wdt" }, | 178 | { .compatible = "ralink,rt2880-wdt" }, |
191 | {}, | 179 | {}, |
@@ -194,8 +182,6 @@ MODULE_DEVICE_TABLE(of, rt288x_wdt_match); | |||
194 | 182 | ||
195 | static struct platform_driver rt288x_wdt_driver = { | 183 | static struct platform_driver rt288x_wdt_driver = { |
196 | .probe = rt288x_wdt_probe, | 184 | .probe = rt288x_wdt_probe, |
197 | .remove = rt288x_wdt_remove, | ||
198 | .shutdown = rt288x_wdt_shutdown, | ||
199 | .driver = { | 185 | .driver = { |
200 | .name = KBUILD_MODNAME, | 186 | .name = KBUILD_MODNAME, |
201 | .of_match_table = rt288x_wdt_match, | 187 | .of_match_table = rt288x_wdt_match, |
diff --git a/drivers/watchdog/rtd119x_wdt.c b/drivers/watchdog/rtd119x_wdt.c index d001c17ddfde..834b94ff3f90 100644 --- a/drivers/watchdog/rtd119x_wdt.c +++ b/drivers/watchdog/rtd119x_wdt.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <linux/bitops.h> | 9 | #include <linux/bitops.h> |
10 | #include <linux/clk.h> | 10 | #include <linux/clk.h> |
11 | #include <linux/io.h> | 11 | #include <linux/io.h> |
12 | #include <linux/module.h> | ||
13 | #include <linux/of.h> | 12 | #include <linux/of.h> |
14 | #include <linux/of_address.h> | 13 | #include <linux/of_address.h> |
15 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
@@ -95,37 +94,43 @@ static const struct of_device_id rtd119x_wdt_dt_ids[] = { | |||
95 | { } | 94 | { } |
96 | }; | 95 | }; |
97 | 96 | ||
97 | static void rtd119x_clk_disable_unprepare(void *data) | ||
98 | { | ||
99 | clk_disable_unprepare(data); | ||
100 | } | ||
101 | |||
98 | static int rtd119x_wdt_probe(struct platform_device *pdev) | 102 | static int rtd119x_wdt_probe(struct platform_device *pdev) |
99 | { | 103 | { |
104 | struct device *dev = &pdev->dev; | ||
100 | struct rtd119x_watchdog_device *data; | 105 | struct rtd119x_watchdog_device *data; |
101 | struct resource *res; | ||
102 | int ret; | 106 | int ret; |
103 | 107 | ||
104 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | 108 | data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); |
105 | if (!data) | 109 | if (!data) |
106 | return -ENOMEM; | 110 | return -ENOMEM; |
107 | 111 | ||
108 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 112 | data->base = devm_platform_ioremap_resource(pdev, 0); |
109 | data->base = devm_ioremap_resource(&pdev->dev, res); | ||
110 | if (IS_ERR(data->base)) | 113 | if (IS_ERR(data->base)) |
111 | return PTR_ERR(data->base); | 114 | return PTR_ERR(data->base); |
112 | 115 | ||
113 | data->clk = of_clk_get(pdev->dev.of_node, 0); | 116 | data->clk = devm_clk_get(dev, NULL); |
114 | if (IS_ERR(data->clk)) | 117 | if (IS_ERR(data->clk)) |
115 | return PTR_ERR(data->clk); | 118 | return PTR_ERR(data->clk); |
116 | 119 | ||
117 | ret = clk_prepare_enable(data->clk); | 120 | ret = clk_prepare_enable(data->clk); |
118 | if (ret) { | 121 | if (ret) |
119 | clk_put(data->clk); | 122 | return ret; |
123 | ret = devm_add_action_or_reset(dev, rtd119x_clk_disable_unprepare, | ||
124 | data->clk); | ||
125 | if (ret) | ||
120 | return ret; | 126 | return ret; |
121 | } | ||
122 | 127 | ||
123 | data->wdt_dev.info = &rtd119x_wdt_info; | 128 | data->wdt_dev.info = &rtd119x_wdt_info; |
124 | data->wdt_dev.ops = &rtd119x_wdt_ops; | 129 | data->wdt_dev.ops = &rtd119x_wdt_ops; |
125 | data->wdt_dev.timeout = 120; | 130 | data->wdt_dev.timeout = 120; |
126 | data->wdt_dev.max_timeout = 0xffffffff / clk_get_rate(data->clk); | 131 | data->wdt_dev.max_timeout = 0xffffffff / clk_get_rate(data->clk); |
127 | data->wdt_dev.min_timeout = 1; | 132 | data->wdt_dev.min_timeout = 1; |
128 | data->wdt_dev.parent = &pdev->dev; | 133 | data->wdt_dev.parent = dev; |
129 | 134 | ||
130 | watchdog_stop_on_reboot(&data->wdt_dev); | 135 | watchdog_stop_on_reboot(&data->wdt_dev); |
131 | watchdog_set_drvdata(&data->wdt_dev, data); | 136 | watchdog_set_drvdata(&data->wdt_dev, data); |
@@ -135,31 +140,11 @@ static int rtd119x_wdt_probe(struct platform_device *pdev) | |||
135 | rtd119x_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout); | 140 | rtd119x_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout); |
136 | rtd119x_wdt_stop(&data->wdt_dev); | 141 | rtd119x_wdt_stop(&data->wdt_dev); |
137 | 142 | ||
138 | ret = devm_watchdog_register_device(&pdev->dev, &data->wdt_dev); | 143 | return devm_watchdog_register_device(dev, &data->wdt_dev); |
139 | if (ret) { | ||
140 | clk_disable_unprepare(data->clk); | ||
141 | clk_put(data->clk); | ||
142 | return ret; | ||
143 | } | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | static int rtd119x_wdt_remove(struct platform_device *pdev) | ||
149 | { | ||
150 | struct rtd119x_watchdog_device *data = platform_get_drvdata(pdev); | ||
151 | |||
152 | watchdog_unregister_device(&data->wdt_dev); | ||
153 | |||
154 | clk_disable_unprepare(data->clk); | ||
155 | clk_put(data->clk); | ||
156 | |||
157 | return 0; | ||
158 | } | 144 | } |
159 | 145 | ||
160 | static struct platform_driver rtd119x_wdt_driver = { | 146 | static struct platform_driver rtd119x_wdt_driver = { |
161 | .probe = rtd119x_wdt_probe, | 147 | .probe = rtd119x_wdt_probe, |
162 | .remove = rtd119x_wdt_remove, | ||
163 | .driver = { | 148 | .driver = { |
164 | .name = "rtd1295-watchdog", | 149 | .name = "rtd1295-watchdog", |
165 | .of_match_table = rtd119x_wdt_dt_ids, | 150 | .of_match_table = rtd119x_wdt_dt_ids, |
diff --git a/drivers/watchdog/rza_wdt.c b/drivers/watchdog/rza_wdt.c index 781bb572e6af..7b6c365f7cd3 100644 --- a/drivers/watchdog/rza_wdt.c +++ b/drivers/watchdog/rza_wdt.c | |||
@@ -166,35 +166,34 @@ static const struct watchdog_ops rza_wdt_ops = { | |||
166 | 166 | ||
167 | static int rza_wdt_probe(struct platform_device *pdev) | 167 | static int rza_wdt_probe(struct platform_device *pdev) |
168 | { | 168 | { |
169 | struct device *dev = &pdev->dev; | ||
169 | struct rza_wdt *priv; | 170 | struct rza_wdt *priv; |
170 | struct resource *res; | ||
171 | unsigned long rate; | 171 | unsigned long rate; |
172 | int ret; | 172 | int ret; |
173 | 173 | ||
174 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); | 174 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
175 | if (!priv) | 175 | if (!priv) |
176 | return -ENOMEM; | 176 | return -ENOMEM; |
177 | 177 | ||
178 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 178 | priv->base = devm_platform_ioremap_resource(pdev, 0); |
179 | priv->base = devm_ioremap_resource(&pdev->dev, res); | ||
180 | if (IS_ERR(priv->base)) | 179 | if (IS_ERR(priv->base)) |
181 | return PTR_ERR(priv->base); | 180 | return PTR_ERR(priv->base); |
182 | 181 | ||
183 | priv->clk = devm_clk_get(&pdev->dev, NULL); | 182 | priv->clk = devm_clk_get(dev, NULL); |
184 | if (IS_ERR(priv->clk)) | 183 | if (IS_ERR(priv->clk)) |
185 | return PTR_ERR(priv->clk); | 184 | return PTR_ERR(priv->clk); |
186 | 185 | ||
187 | rate = clk_get_rate(priv->clk); | 186 | rate = clk_get_rate(priv->clk); |
188 | if (rate < 16384) { | 187 | if (rate < 16384) { |
189 | dev_err(&pdev->dev, "invalid clock rate (%ld)\n", rate); | 188 | dev_err(dev, "invalid clock rate (%ld)\n", rate); |
190 | return -ENOENT; | 189 | return -ENOENT; |
191 | } | 190 | } |
192 | 191 | ||
193 | priv->wdev.info = &rza_wdt_ident, | 192 | priv->wdev.info = &rza_wdt_ident, |
194 | priv->wdev.ops = &rza_wdt_ops, | 193 | priv->wdev.ops = &rza_wdt_ops, |
195 | priv->wdev.parent = &pdev->dev; | 194 | priv->wdev.parent = dev; |
196 | 195 | ||
197 | priv->cks = (u8)(uintptr_t)of_device_get_match_data(&pdev->dev); | 196 | priv->cks = (u8)(uintptr_t) of_device_get_match_data(dev); |
198 | if (priv->cks == CKS_4BIT) { | 197 | if (priv->cks == CKS_4BIT) { |
199 | /* Assume slowest clock rate possible (CKS=0xF) */ | 198 | /* Assume slowest clock rate possible (CKS=0xF) */ |
200 | priv->wdev.max_timeout = (DIVIDER_4BIT * U8_MAX) / rate; | 199 | priv->wdev.max_timeout = (DIVIDER_4BIT * U8_MAX) / rate; |
@@ -209,19 +208,19 @@ static int rza_wdt_probe(struct platform_device *pdev) | |||
209 | * max_hw_heartbeat_ms. | 208 | * max_hw_heartbeat_ms. |
210 | */ | 209 | */ |
211 | priv->wdev.max_hw_heartbeat_ms = (1000 * U8_MAX) / rate; | 210 | priv->wdev.max_hw_heartbeat_ms = (1000 * U8_MAX) / rate; |
212 | dev_dbg(&pdev->dev, "max hw timeout of %dms\n", | 211 | dev_dbg(dev, "max hw timeout of %dms\n", |
213 | priv->wdev.max_hw_heartbeat_ms); | 212 | priv->wdev.max_hw_heartbeat_ms); |
214 | } | 213 | } |
215 | 214 | ||
216 | priv->wdev.min_timeout = 1; | 215 | priv->wdev.min_timeout = 1; |
217 | priv->wdev.timeout = DEFAULT_TIMEOUT; | 216 | priv->wdev.timeout = DEFAULT_TIMEOUT; |
218 | 217 | ||
219 | watchdog_init_timeout(&priv->wdev, 0, &pdev->dev); | 218 | watchdog_init_timeout(&priv->wdev, 0, dev); |
220 | watchdog_set_drvdata(&priv->wdev, priv); | 219 | watchdog_set_drvdata(&priv->wdev, priv); |
221 | 220 | ||
222 | ret = devm_watchdog_register_device(&pdev->dev, &priv->wdev); | 221 | ret = devm_watchdog_register_device(dev, &priv->wdev); |
223 | if (ret) | 222 | if (ret) |
224 | dev_err(&pdev->dev, "Cannot register watchdog device\n"); | 223 | dev_err(dev, "Cannot register watchdog device\n"); |
225 | 224 | ||
226 | return ret; | 225 | return ret; |
227 | } | 226 | } |
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index adaa43543f0a..4267b9e8734b 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c | |||
@@ -522,7 +522,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
522 | { | 522 | { |
523 | struct device *dev = &pdev->dev; | 523 | struct device *dev = &pdev->dev; |
524 | struct s3c2410_wdt *wdt; | 524 | struct s3c2410_wdt *wdt; |
525 | struct resource *wdt_mem; | ||
526 | struct resource *wdt_irq; | 525 | struct resource *wdt_irq; |
527 | unsigned int wtcon; | 526 | unsigned int wtcon; |
528 | int started = 0; | 527 | int started = 0; |
@@ -554,8 +553,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
554 | } | 553 | } |
555 | 554 | ||
556 | /* get the memory region for the watchdog timer */ | 555 | /* get the memory region for the watchdog timer */ |
557 | wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 556 | wdt->reg_base = devm_platform_ioremap_resource(pdev, 0); |
558 | wdt->reg_base = devm_ioremap_resource(dev, wdt_mem); | ||
559 | if (IS_ERR(wdt->reg_base)) { | 557 | if (IS_ERR(wdt->reg_base)) { |
560 | ret = PTR_ERR(wdt->reg_base); | 558 | ret = PTR_ERR(wdt->reg_base); |
561 | goto err; | 559 | goto err; |
diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c index 1e93c1b0e3cf..111695223aae 100644 --- a/drivers/watchdog/sama5d4_wdt.c +++ b/drivers/watchdog/sama5d4_wdt.c | |||
@@ -199,15 +199,15 @@ static int sama5d4_wdt_init(struct sama5d4_wdt *wdt) | |||
199 | 199 | ||
200 | static int sama5d4_wdt_probe(struct platform_device *pdev) | 200 | static int sama5d4_wdt_probe(struct platform_device *pdev) |
201 | { | 201 | { |
202 | struct device *dev = &pdev->dev; | ||
202 | struct watchdog_device *wdd; | 203 | struct watchdog_device *wdd; |
203 | struct sama5d4_wdt *wdt; | 204 | struct sama5d4_wdt *wdt; |
204 | struct resource *res; | ||
205 | void __iomem *regs; | 205 | void __iomem *regs; |
206 | u32 irq = 0; | 206 | u32 irq = 0; |
207 | u32 timeout; | 207 | u32 timeout; |
208 | int ret; | 208 | int ret; |
209 | 209 | ||
210 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 210 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
211 | if (!wdt) | 211 | if (!wdt) |
212 | return -ENOMEM; | 212 | return -ENOMEM; |
213 | 213 | ||
@@ -221,33 +221,31 @@ static int sama5d4_wdt_probe(struct platform_device *pdev) | |||
221 | 221 | ||
222 | watchdog_set_drvdata(wdd, wdt); | 222 | watchdog_set_drvdata(wdd, wdt); |
223 | 223 | ||
224 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 224 | regs = devm_platform_ioremap_resource(pdev, 0); |
225 | regs = devm_ioremap_resource(&pdev->dev, res); | ||
226 | if (IS_ERR(regs)) | 225 | if (IS_ERR(regs)) |
227 | return PTR_ERR(regs); | 226 | return PTR_ERR(regs); |
228 | 227 | ||
229 | wdt->reg_base = regs; | 228 | wdt->reg_base = regs; |
230 | 229 | ||
231 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); | 230 | irq = irq_of_parse_and_map(dev->of_node, 0); |
232 | if (!irq) | 231 | if (!irq) |
233 | dev_warn(&pdev->dev, "failed to get IRQ from DT\n"); | 232 | dev_warn(dev, "failed to get IRQ from DT\n"); |
234 | 233 | ||
235 | ret = of_sama5d4_wdt_init(pdev->dev.of_node, wdt); | 234 | ret = of_sama5d4_wdt_init(dev->of_node, wdt); |
236 | if (ret) | 235 | if (ret) |
237 | return ret; | 236 | return ret; |
238 | 237 | ||
239 | if ((wdt->mr & AT91_WDT_WDFIEN) && irq) { | 238 | if ((wdt->mr & AT91_WDT_WDFIEN) && irq) { |
240 | ret = devm_request_irq(&pdev->dev, irq, sama5d4_wdt_irq_handler, | 239 | ret = devm_request_irq(dev, irq, sama5d4_wdt_irq_handler, |
241 | IRQF_SHARED | IRQF_IRQPOLL | | 240 | IRQF_SHARED | IRQF_IRQPOLL | |
242 | IRQF_NO_SUSPEND, pdev->name, pdev); | 241 | IRQF_NO_SUSPEND, pdev->name, pdev); |
243 | if (ret) { | 242 | if (ret) { |
244 | dev_err(&pdev->dev, | 243 | dev_err(dev, "cannot register interrupt handler\n"); |
245 | "cannot register interrupt handler\n"); | ||
246 | return ret; | 244 | return ret; |
247 | } | 245 | } |
248 | } | 246 | } |
249 | 247 | ||
250 | watchdog_init_timeout(wdd, wdt_timeout, &pdev->dev); | 248 | watchdog_init_timeout(wdd, wdt_timeout, dev); |
251 | 249 | ||
252 | timeout = WDT_SEC2TICKS(wdd->timeout); | 250 | timeout = WDT_SEC2TICKS(wdd->timeout); |
253 | 251 | ||
@@ -260,31 +258,21 @@ static int sama5d4_wdt_probe(struct platform_device *pdev) | |||
260 | 258 | ||
261 | watchdog_set_nowayout(wdd, nowayout); | 259 | watchdog_set_nowayout(wdd, nowayout); |
262 | 260 | ||
263 | ret = watchdog_register_device(wdd); | 261 | watchdog_stop_on_unregister(wdd); |
262 | ret = devm_watchdog_register_device(dev, wdd); | ||
264 | if (ret) { | 263 | if (ret) { |
265 | dev_err(&pdev->dev, "failed to register watchdog device\n"); | 264 | dev_err(dev, "failed to register watchdog device\n"); |
266 | return ret; | 265 | return ret; |
267 | } | 266 | } |
268 | 267 | ||
269 | platform_set_drvdata(pdev, wdt); | 268 | platform_set_drvdata(pdev, wdt); |
270 | 269 | ||
271 | dev_info(&pdev->dev, "initialized (timeout = %d sec, nowayout = %d)\n", | 270 | dev_info(dev, "initialized (timeout = %d sec, nowayout = %d)\n", |
272 | wdd->timeout, nowayout); | 271 | wdd->timeout, nowayout); |
273 | 272 | ||
274 | return 0; | 273 | return 0; |
275 | } | 274 | } |
276 | 275 | ||
277 | static int sama5d4_wdt_remove(struct platform_device *pdev) | ||
278 | { | ||
279 | struct sama5d4_wdt *wdt = platform_get_drvdata(pdev); | ||
280 | |||
281 | sama5d4_wdt_stop(&wdt->wdd); | ||
282 | |||
283 | watchdog_unregister_device(&wdt->wdd); | ||
284 | |||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | static const struct of_device_id sama5d4_wdt_of_match[] = { | 276 | static const struct of_device_id sama5d4_wdt_of_match[] = { |
289 | { .compatible = "atmel,sama5d4-wdt", }, | 277 | { .compatible = "atmel,sama5d4-wdt", }, |
290 | { } | 278 | { } |
@@ -312,7 +300,6 @@ static SIMPLE_DEV_PM_OPS(sama5d4_wdt_pm_ops, NULL, | |||
312 | 300 | ||
313 | static struct platform_driver sama5d4_wdt_driver = { | 301 | static struct platform_driver sama5d4_wdt_driver = { |
314 | .probe = sama5d4_wdt_probe, | 302 | .probe = sama5d4_wdt_probe, |
315 | .remove = sama5d4_wdt_remove, | ||
316 | .driver = { | 303 | .driver = { |
317 | .name = "sama5d4_wdt", | 304 | .name = "sama5d4_wdt", |
318 | .pm = &sama5d4_wdt_pm_ops, | 305 | .pm = &sama5d4_wdt_pm_ops, |
diff --git a/drivers/watchdog/sb_wdog.c b/drivers/watchdog/sb_wdog.c index 0692d42e5c67..5a6ced7a7e8f 100644 --- a/drivers/watchdog/sb_wdog.c +++ b/drivers/watchdog/sb_wdog.c | |||
@@ -67,7 +67,7 @@ static DEFINE_SPINLOCK(sbwd_lock); | |||
67 | * | 67 | * |
68 | * wdog is the iomem address of the cfg register | 68 | * wdog is the iomem address of the cfg register |
69 | */ | 69 | */ |
70 | void sbwdog_set(char __iomem *wdog, unsigned long t) | 70 | static void sbwdog_set(char __iomem *wdog, unsigned long t) |
71 | { | 71 | { |
72 | spin_lock(&sbwd_lock); | 72 | spin_lock(&sbwd_lock); |
73 | __raw_writeb(0, wdog); | 73 | __raw_writeb(0, wdog); |
@@ -81,7 +81,7 @@ void sbwdog_set(char __iomem *wdog, unsigned long t) | |||
81 | * | 81 | * |
82 | * wdog is the iomem address of the cfg register | 82 | * wdog is the iomem address of the cfg register |
83 | */ | 83 | */ |
84 | void sbwdog_pet(char __iomem *wdog) | 84 | static void sbwdog_pet(char __iomem *wdog) |
85 | { | 85 | { |
86 | spin_lock(&sbwd_lock); | 86 | spin_lock(&sbwd_lock); |
87 | __raw_writeb(__raw_readb(wdog) | 1, wdog); | 87 | __raw_writeb(__raw_readb(wdog) | 1, wdog); |
diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c index e221e47396ab..3219422f67a9 100644 --- a/drivers/watchdog/sbsa_gwdt.c +++ b/drivers/watchdog/sbsa_gwdt.c | |||
@@ -231,7 +231,6 @@ static int sbsa_gwdt_probe(struct platform_device *pdev) | |||
231 | struct device *dev = &pdev->dev; | 231 | struct device *dev = &pdev->dev; |
232 | struct watchdog_device *wdd; | 232 | struct watchdog_device *wdd; |
233 | struct sbsa_gwdt *gwdt; | 233 | struct sbsa_gwdt *gwdt; |
234 | struct resource *res; | ||
235 | int ret, irq; | 234 | int ret, irq; |
236 | u32 status; | 235 | u32 status; |
237 | 236 | ||
@@ -240,13 +239,11 @@ static int sbsa_gwdt_probe(struct platform_device *pdev) | |||
240 | return -ENOMEM; | 239 | return -ENOMEM; |
241 | platform_set_drvdata(pdev, gwdt); | 240 | platform_set_drvdata(pdev, gwdt); |
242 | 241 | ||
243 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 242 | cf_base = devm_platform_ioremap_resource(pdev, 0); |
244 | cf_base = devm_ioremap_resource(dev, res); | ||
245 | if (IS_ERR(cf_base)) | 243 | if (IS_ERR(cf_base)) |
246 | return PTR_ERR(cf_base); | 244 | return PTR_ERR(cf_base); |
247 | 245 | ||
248 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 246 | rf_base = devm_platform_ioremap_resource(pdev, 1); |
249 | rf_base = devm_ioremap_resource(dev, res); | ||
250 | if (IS_ERR(rf_base)) | 247 | if (IS_ERR(rf_base)) |
251 | return PTR_ERR(rf_base); | 248 | return PTR_ERR(rf_base); |
252 | 249 | ||
@@ -313,7 +310,8 @@ static int sbsa_gwdt_probe(struct platform_device *pdev) | |||
313 | */ | 310 | */ |
314 | sbsa_gwdt_set_timeout(wdd, wdd->timeout); | 311 | sbsa_gwdt_set_timeout(wdd, wdd->timeout); |
315 | 312 | ||
316 | ret = watchdog_register_device(wdd); | 313 | watchdog_stop_on_reboot(wdd); |
314 | ret = devm_watchdog_register_device(dev, wdd); | ||
317 | if (ret) | 315 | if (ret) |
318 | return ret; | 316 | return ret; |
319 | 317 | ||
@@ -324,22 +322,6 @@ static int sbsa_gwdt_probe(struct platform_device *pdev) | |||
324 | return 0; | 322 | return 0; |
325 | } | 323 | } |
326 | 324 | ||
327 | static void sbsa_gwdt_shutdown(struct platform_device *pdev) | ||
328 | { | ||
329 | struct sbsa_gwdt *gwdt = platform_get_drvdata(pdev); | ||
330 | |||
331 | sbsa_gwdt_stop(&gwdt->wdd); | ||
332 | } | ||
333 | |||
334 | static int sbsa_gwdt_remove(struct platform_device *pdev) | ||
335 | { | ||
336 | struct sbsa_gwdt *gwdt = platform_get_drvdata(pdev); | ||
337 | |||
338 | watchdog_unregister_device(&gwdt->wdd); | ||
339 | |||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | /* Disable watchdog if it is active during suspend */ | 325 | /* Disable watchdog if it is active during suspend */ |
344 | static int __maybe_unused sbsa_gwdt_suspend(struct device *dev) | 326 | static int __maybe_unused sbsa_gwdt_suspend(struct device *dev) |
345 | { | 327 | { |
@@ -385,8 +367,6 @@ static struct platform_driver sbsa_gwdt_driver = { | |||
385 | .of_match_table = sbsa_gwdt_of_match, | 367 | .of_match_table = sbsa_gwdt_of_match, |
386 | }, | 368 | }, |
387 | .probe = sbsa_gwdt_probe, | 369 | .probe = sbsa_gwdt_probe, |
388 | .remove = sbsa_gwdt_remove, | ||
389 | .shutdown = sbsa_gwdt_shutdown, | ||
390 | .id_table = sbsa_gwdt_pdev_match, | 370 | .id_table = sbsa_gwdt_pdev_match, |
391 | }; | 371 | }; |
392 | 372 | ||
diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c index a7d6425db807..e7617b7df70b 100644 --- a/drivers/watchdog/shwdt.c +++ b/drivers/watchdog/shwdt.c | |||
@@ -220,7 +220,6 @@ static struct watchdog_device sh_wdt_dev = { | |||
220 | static int sh_wdt_probe(struct platform_device *pdev) | 220 | static int sh_wdt_probe(struct platform_device *pdev) |
221 | { | 221 | { |
222 | struct sh_wdt *wdt; | 222 | struct sh_wdt *wdt; |
223 | struct resource *res; | ||
224 | int rc; | 223 | int rc; |
225 | 224 | ||
226 | /* | 225 | /* |
@@ -245,8 +244,7 @@ static int sh_wdt_probe(struct platform_device *pdev) | |||
245 | wdt->clk = NULL; | 244 | wdt->clk = NULL; |
246 | } | 245 | } |
247 | 246 | ||
248 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 247 | wdt->base = devm_platform_ioremap_resource(pdev, 0); |
249 | wdt->base = devm_ioremap_resource(wdt->dev, res); | ||
250 | if (IS_ERR(wdt->base)) | 248 | if (IS_ERR(wdt->base)) |
251 | return PTR_ERR(wdt->base); | 249 | return PTR_ERR(wdt->base); |
252 | 250 | ||
diff --git a/drivers/watchdog/sirfsoc_wdt.c b/drivers/watchdog/sirfsoc_wdt.c index ac0c9d2c4aee..e79a4097d50b 100644 --- a/drivers/watchdog/sirfsoc_wdt.c +++ b/drivers/watchdog/sirfsoc_wdt.c | |||
@@ -146,22 +146,23 @@ static struct watchdog_device sirfsoc_wdd = { | |||
146 | 146 | ||
147 | static int sirfsoc_wdt_probe(struct platform_device *pdev) | 147 | static int sirfsoc_wdt_probe(struct platform_device *pdev) |
148 | { | 148 | { |
149 | struct resource *res; | 149 | struct device *dev = &pdev->dev; |
150 | int ret; | 150 | int ret; |
151 | void __iomem *base; | 151 | void __iomem *base; |
152 | 152 | ||
153 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 153 | base = devm_platform_ioremap_resource(pdev, 0); |
154 | base = devm_ioremap_resource(&pdev->dev, res); | ||
155 | if (IS_ERR(base)) | 154 | if (IS_ERR(base)) |
156 | return PTR_ERR(base); | 155 | return PTR_ERR(base); |
157 | 156 | ||
158 | watchdog_set_drvdata(&sirfsoc_wdd, (__force void *)base); | 157 | watchdog_set_drvdata(&sirfsoc_wdd, (__force void *)base); |
159 | 158 | ||
160 | watchdog_init_timeout(&sirfsoc_wdd, timeout, &pdev->dev); | 159 | watchdog_init_timeout(&sirfsoc_wdd, timeout, dev); |
161 | watchdog_set_nowayout(&sirfsoc_wdd, nowayout); | 160 | watchdog_set_nowayout(&sirfsoc_wdd, nowayout); |
162 | sirfsoc_wdd.parent = &pdev->dev; | 161 | sirfsoc_wdd.parent = dev; |
163 | 162 | ||
164 | ret = watchdog_register_device(&sirfsoc_wdd); | 163 | watchdog_stop_on_reboot(&sirfsoc_wdd); |
164 | watchdog_stop_on_unregister(&sirfsoc_wdd); | ||
165 | ret = devm_watchdog_register_device(dev, &sirfsoc_wdd); | ||
165 | if (ret) | 166 | if (ret) |
166 | return ret; | 167 | return ret; |
167 | 168 | ||
@@ -170,19 +171,6 @@ static int sirfsoc_wdt_probe(struct platform_device *pdev) | |||
170 | return 0; | 171 | return 0; |
171 | } | 172 | } |
172 | 173 | ||
173 | static void sirfsoc_wdt_shutdown(struct platform_device *pdev) | ||
174 | { | ||
175 | struct watchdog_device *wdd = platform_get_drvdata(pdev); | ||
176 | |||
177 | sirfsoc_wdt_disable(wdd); | ||
178 | } | ||
179 | |||
180 | static int sirfsoc_wdt_remove(struct platform_device *pdev) | ||
181 | { | ||
182 | sirfsoc_wdt_shutdown(pdev); | ||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | #ifdef CONFIG_PM_SLEEP | 174 | #ifdef CONFIG_PM_SLEEP |
187 | static int sirfsoc_wdt_suspend(struct device *dev) | 175 | static int sirfsoc_wdt_suspend(struct device *dev) |
188 | { | 176 | { |
@@ -220,8 +208,6 @@ static struct platform_driver sirfsoc_wdt_driver = { | |||
220 | .of_match_table = sirfsoc_wdt_of_match, | 208 | .of_match_table = sirfsoc_wdt_of_match, |
221 | }, | 209 | }, |
222 | .probe = sirfsoc_wdt_probe, | 210 | .probe = sirfsoc_wdt_probe, |
223 | .remove = sirfsoc_wdt_remove, | ||
224 | .shutdown = sirfsoc_wdt_shutdown, | ||
225 | }; | 211 | }; |
226 | module_platform_driver(sirfsoc_wdt_driver); | 212 | module_platform_driver(sirfsoc_wdt_driver); |
227 | 213 | ||
diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c index 41aaae2d5287..553735b256e2 100644 --- a/drivers/watchdog/sp5100_tco.c +++ b/drivers/watchdog/sp5100_tco.c | |||
@@ -395,9 +395,7 @@ static int sp5100_tco_probe(struct platform_device *pdev) | |||
395 | wdd->min_timeout = 1; | 395 | wdd->min_timeout = 1; |
396 | wdd->max_timeout = 0xffff; | 396 | wdd->max_timeout = 0xffff; |
397 | 397 | ||
398 | if (watchdog_init_timeout(wdd, heartbeat, NULL)) | 398 | watchdog_init_timeout(wdd, heartbeat, NULL); |
399 | dev_info(dev, "timeout value invalid, using %d\n", | ||
400 | wdd->timeout); | ||
401 | watchdog_set_nowayout(wdd, nowayout); | 399 | watchdog_set_nowayout(wdd, nowayout); |
402 | watchdog_stop_on_reboot(wdd); | 400 | watchdog_stop_on_reboot(wdd); |
403 | watchdog_stop_on_unregister(wdd); | 401 | watchdog_stop_on_unregister(wdd); |
diff --git a/drivers/watchdog/sprd_wdt.c b/drivers/watchdog/sprd_wdt.c index ff9397d9638a..14874e9b207b 100644 --- a/drivers/watchdog/sprd_wdt.c +++ b/drivers/watchdog/sprd_wdt.c | |||
@@ -245,9 +245,7 @@ static u32 sprd_wdt_get_timeleft(struct watchdog_device *wdd) | |||
245 | u32 val; | 245 | u32 val; |
246 | 246 | ||
247 | val = sprd_wdt_get_cnt_value(wdt); | 247 | val = sprd_wdt_get_cnt_value(wdt); |
248 | val = val / SPRD_WDT_CNT_STEP; | 248 | return val / SPRD_WDT_CNT_STEP; |
249 | |||
250 | return val; | ||
251 | } | 249 | } |
252 | 250 | ||
253 | static const struct watchdog_ops sprd_wdt_ops = { | 251 | static const struct watchdog_ops sprd_wdt_ops = { |
@@ -269,70 +267,68 @@ static const struct watchdog_info sprd_wdt_info = { | |||
269 | 267 | ||
270 | static int sprd_wdt_probe(struct platform_device *pdev) | 268 | static int sprd_wdt_probe(struct platform_device *pdev) |
271 | { | 269 | { |
272 | struct resource *wdt_res; | 270 | struct device *dev = &pdev->dev; |
273 | struct sprd_wdt *wdt; | 271 | struct sprd_wdt *wdt; |
274 | int ret; | 272 | int ret; |
275 | 273 | ||
276 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 274 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
277 | if (!wdt) | 275 | if (!wdt) |
278 | return -ENOMEM; | 276 | return -ENOMEM; |
279 | 277 | ||
280 | wdt_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 278 | wdt->base = devm_platform_ioremap_resource(pdev, 0); |
281 | wdt->base = devm_ioremap_resource(&pdev->dev, wdt_res); | ||
282 | if (IS_ERR(wdt->base)) | 279 | if (IS_ERR(wdt->base)) |
283 | return PTR_ERR(wdt->base); | 280 | return PTR_ERR(wdt->base); |
284 | 281 | ||
285 | wdt->enable = devm_clk_get(&pdev->dev, "enable"); | 282 | wdt->enable = devm_clk_get(dev, "enable"); |
286 | if (IS_ERR(wdt->enable)) { | 283 | if (IS_ERR(wdt->enable)) { |
287 | dev_err(&pdev->dev, "can't get the enable clock\n"); | 284 | dev_err(dev, "can't get the enable clock\n"); |
288 | return PTR_ERR(wdt->enable); | 285 | return PTR_ERR(wdt->enable); |
289 | } | 286 | } |
290 | 287 | ||
291 | wdt->rtc_enable = devm_clk_get(&pdev->dev, "rtc_enable"); | 288 | wdt->rtc_enable = devm_clk_get(dev, "rtc_enable"); |
292 | if (IS_ERR(wdt->rtc_enable)) { | 289 | if (IS_ERR(wdt->rtc_enable)) { |
293 | dev_err(&pdev->dev, "can't get the rtc enable clock\n"); | 290 | dev_err(dev, "can't get the rtc enable clock\n"); |
294 | return PTR_ERR(wdt->rtc_enable); | 291 | return PTR_ERR(wdt->rtc_enable); |
295 | } | 292 | } |
296 | 293 | ||
297 | wdt->irq = platform_get_irq(pdev, 0); | 294 | wdt->irq = platform_get_irq(pdev, 0); |
298 | if (wdt->irq < 0) { | 295 | if (wdt->irq < 0) { |
299 | dev_err(&pdev->dev, "failed to get IRQ resource\n"); | 296 | dev_err(dev, "failed to get IRQ resource\n"); |
300 | return wdt->irq; | 297 | return wdt->irq; |
301 | } | 298 | } |
302 | 299 | ||
303 | ret = devm_request_irq(&pdev->dev, wdt->irq, sprd_wdt_isr, | 300 | ret = devm_request_irq(dev, wdt->irq, sprd_wdt_isr, IRQF_NO_SUSPEND, |
304 | IRQF_NO_SUSPEND, "sprd-wdt", (void *)wdt); | 301 | "sprd-wdt", (void *)wdt); |
305 | if (ret) { | 302 | if (ret) { |
306 | dev_err(&pdev->dev, "failed to register irq\n"); | 303 | dev_err(dev, "failed to register irq\n"); |
307 | return ret; | 304 | return ret; |
308 | } | 305 | } |
309 | 306 | ||
310 | wdt->wdd.info = &sprd_wdt_info; | 307 | wdt->wdd.info = &sprd_wdt_info; |
311 | wdt->wdd.ops = &sprd_wdt_ops; | 308 | wdt->wdd.ops = &sprd_wdt_ops; |
312 | wdt->wdd.parent = &pdev->dev; | 309 | wdt->wdd.parent = dev; |
313 | wdt->wdd.min_timeout = SPRD_WDT_MIN_TIMEOUT; | 310 | wdt->wdd.min_timeout = SPRD_WDT_MIN_TIMEOUT; |
314 | wdt->wdd.max_timeout = SPRD_WDT_MAX_TIMEOUT; | 311 | wdt->wdd.max_timeout = SPRD_WDT_MAX_TIMEOUT; |
315 | wdt->wdd.timeout = SPRD_WDT_MAX_TIMEOUT; | 312 | wdt->wdd.timeout = SPRD_WDT_MAX_TIMEOUT; |
316 | 313 | ||
317 | ret = sprd_wdt_enable(wdt); | 314 | ret = sprd_wdt_enable(wdt); |
318 | if (ret) { | 315 | if (ret) { |
319 | dev_err(&pdev->dev, "failed to enable wdt\n"); | 316 | dev_err(dev, "failed to enable wdt\n"); |
320 | return ret; | 317 | return ret; |
321 | } | 318 | } |
322 | ret = devm_add_action(&pdev->dev, sprd_wdt_disable, wdt); | 319 | ret = devm_add_action_or_reset(dev, sprd_wdt_disable, wdt); |
323 | if (ret) { | 320 | if (ret) { |
324 | sprd_wdt_disable(wdt); | 321 | dev_err(dev, "Failed to add wdt disable action\n"); |
325 | dev_err(&pdev->dev, "Failed to add wdt disable action\n"); | ||
326 | return ret; | 322 | return ret; |
327 | } | 323 | } |
328 | 324 | ||
329 | watchdog_set_nowayout(&wdt->wdd, WATCHDOG_NOWAYOUT); | 325 | watchdog_set_nowayout(&wdt->wdd, WATCHDOG_NOWAYOUT); |
330 | watchdog_init_timeout(&wdt->wdd, 0, &pdev->dev); | 326 | watchdog_init_timeout(&wdt->wdd, 0, dev); |
331 | 327 | ||
332 | ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdd); | 328 | ret = devm_watchdog_register_device(dev, &wdt->wdd); |
333 | if (ret) { | 329 | if (ret) { |
334 | sprd_wdt_disable(wdt); | 330 | sprd_wdt_disable(wdt); |
335 | dev_err(&pdev->dev, "failed to register watchdog\n"); | 331 | dev_err(dev, "failed to register watchdog\n"); |
336 | return ret; | 332 | return ret; |
337 | } | 333 | } |
338 | platform_set_drvdata(pdev, wdt); | 334 | platform_set_drvdata(pdev, wdt); |
diff --git a/drivers/watchdog/st_lpc_wdt.c b/drivers/watchdog/st_lpc_wdt.c index 177829b379da..7a90184eb950 100644 --- a/drivers/watchdog/st_lpc_wdt.c +++ b/drivers/watchdog/st_lpc_wdt.c | |||
@@ -142,13 +142,18 @@ static struct watchdog_device st_wdog_dev = { | |||
142 | .ops = &st_wdog_ops, | 142 | .ops = &st_wdog_ops, |
143 | }; | 143 | }; |
144 | 144 | ||
145 | static void st_clk_disable_unprepare(void *data) | ||
146 | { | ||
147 | clk_disable_unprepare(data); | ||
148 | } | ||
149 | |||
145 | static int st_wdog_probe(struct platform_device *pdev) | 150 | static int st_wdog_probe(struct platform_device *pdev) |
146 | { | 151 | { |
152 | struct device *dev = &pdev->dev; | ||
147 | const struct of_device_id *match; | 153 | const struct of_device_id *match; |
148 | struct device_node *np = pdev->dev.of_node; | 154 | struct device_node *np = dev->of_node; |
149 | struct st_wdog *st_wdog; | 155 | struct st_wdog *st_wdog; |
150 | struct regmap *regmap; | 156 | struct regmap *regmap; |
151 | struct resource *res; | ||
152 | struct clk *clk; | 157 | struct clk *clk; |
153 | void __iomem *base; | 158 | void __iomem *base; |
154 | uint32_t mode; | 159 | uint32_t mode; |
@@ -156,7 +161,7 @@ static int st_wdog_probe(struct platform_device *pdev) | |||
156 | 161 | ||
157 | ret = of_property_read_u32(np, "st,lpc-mode", &mode); | 162 | ret = of_property_read_u32(np, "st,lpc-mode", &mode); |
158 | if (ret) { | 163 | if (ret) { |
159 | dev_err(&pdev->dev, "An LPC mode must be provided\n"); | 164 | dev_err(dev, "An LPC mode must be provided\n"); |
160 | return -EINVAL; | 165 | return -EINVAL; |
161 | } | 166 | } |
162 | 167 | ||
@@ -164,35 +169,34 @@ static int st_wdog_probe(struct platform_device *pdev) | |||
164 | if (mode != ST_LPC_MODE_WDT) | 169 | if (mode != ST_LPC_MODE_WDT) |
165 | return -ENODEV; | 170 | return -ENODEV; |
166 | 171 | ||
167 | st_wdog = devm_kzalloc(&pdev->dev, sizeof(*st_wdog), GFP_KERNEL); | 172 | st_wdog = devm_kzalloc(dev, sizeof(*st_wdog), GFP_KERNEL); |
168 | if (!st_wdog) | 173 | if (!st_wdog) |
169 | return -ENOMEM; | 174 | return -ENOMEM; |
170 | 175 | ||
171 | match = of_match_device(st_wdog_match, &pdev->dev); | 176 | match = of_match_device(st_wdog_match, dev); |
172 | if (!match) { | 177 | if (!match) { |
173 | dev_err(&pdev->dev, "Couldn't match device\n"); | 178 | dev_err(dev, "Couldn't match device\n"); |
174 | return -ENODEV; | 179 | return -ENODEV; |
175 | } | 180 | } |
176 | st_wdog->syscfg = (struct st_wdog_syscfg *)match->data; | 181 | st_wdog->syscfg = (struct st_wdog_syscfg *)match->data; |
177 | 182 | ||
178 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 183 | base = devm_platform_ioremap_resource(pdev, 0); |
179 | base = devm_ioremap_resource(&pdev->dev, res); | ||
180 | if (IS_ERR(base)) | 184 | if (IS_ERR(base)) |
181 | return PTR_ERR(base); | 185 | return PTR_ERR(base); |
182 | 186 | ||
183 | regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); | 187 | regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); |
184 | if (IS_ERR(regmap)) { | 188 | if (IS_ERR(regmap)) { |
185 | dev_err(&pdev->dev, "No syscfg phandle specified\n"); | 189 | dev_err(dev, "No syscfg phandle specified\n"); |
186 | return PTR_ERR(regmap); | 190 | return PTR_ERR(regmap); |
187 | } | 191 | } |
188 | 192 | ||
189 | clk = devm_clk_get(&pdev->dev, NULL); | 193 | clk = devm_clk_get(dev, NULL); |
190 | if (IS_ERR(clk)) { | 194 | if (IS_ERR(clk)) { |
191 | dev_err(&pdev->dev, "Unable to request clock\n"); | 195 | dev_err(dev, "Unable to request clock\n"); |
192 | return PTR_ERR(clk); | 196 | return PTR_ERR(clk); |
193 | } | 197 | } |
194 | 198 | ||
195 | st_wdog->dev = &pdev->dev; | 199 | st_wdog->dev = dev; |
196 | st_wdog->base = base; | 200 | st_wdog->base = base; |
197 | st_wdog->clk = clk; | 201 | st_wdog->clk = clk; |
198 | st_wdog->regmap = regmap; | 202 | st_wdog->regmap = regmap; |
@@ -200,39 +204,38 @@ static int st_wdog_probe(struct platform_device *pdev) | |||
200 | st_wdog->clkrate = clk_get_rate(st_wdog->clk); | 204 | st_wdog->clkrate = clk_get_rate(st_wdog->clk); |
201 | 205 | ||
202 | if (!st_wdog->clkrate) { | 206 | if (!st_wdog->clkrate) { |
203 | dev_err(&pdev->dev, "Unable to fetch clock rate\n"); | 207 | dev_err(dev, "Unable to fetch clock rate\n"); |
204 | return -EINVAL; | 208 | return -EINVAL; |
205 | } | 209 | } |
206 | st_wdog_dev.max_timeout = 0xFFFFFFFF / st_wdog->clkrate; | 210 | st_wdog_dev.max_timeout = 0xFFFFFFFF / st_wdog->clkrate; |
207 | st_wdog_dev.parent = &pdev->dev; | 211 | st_wdog_dev.parent = dev; |
208 | 212 | ||
209 | ret = clk_prepare_enable(clk); | 213 | ret = clk_prepare_enable(clk); |
210 | if (ret) { | 214 | if (ret) { |
211 | dev_err(&pdev->dev, "Unable to enable clock\n"); | 215 | dev_err(dev, "Unable to enable clock\n"); |
212 | return ret; | 216 | return ret; |
213 | } | 217 | } |
218 | ret = devm_add_action_or_reset(dev, st_clk_disable_unprepare, clk); | ||
219 | if (ret) | ||
220 | return ret; | ||
214 | 221 | ||
215 | watchdog_set_drvdata(&st_wdog_dev, st_wdog); | 222 | watchdog_set_drvdata(&st_wdog_dev, st_wdog); |
216 | watchdog_set_nowayout(&st_wdog_dev, WATCHDOG_NOWAYOUT); | 223 | watchdog_set_nowayout(&st_wdog_dev, WATCHDOG_NOWAYOUT); |
217 | 224 | ||
218 | /* Init Watchdog timeout with value in DT */ | 225 | /* Init Watchdog timeout with value in DT */ |
219 | ret = watchdog_init_timeout(&st_wdog_dev, 0, &pdev->dev); | 226 | ret = watchdog_init_timeout(&st_wdog_dev, 0, dev); |
220 | if (ret) { | 227 | if (ret) |
221 | dev_err(&pdev->dev, "Unable to initialise watchdog timeout\n"); | ||
222 | clk_disable_unprepare(clk); | ||
223 | return ret; | 228 | return ret; |
224 | } | ||
225 | 229 | ||
226 | ret = watchdog_register_device(&st_wdog_dev); | 230 | ret = devm_watchdog_register_device(dev, &st_wdog_dev); |
227 | if (ret) { | 231 | if (ret) { |
228 | dev_err(&pdev->dev, "Unable to register watchdog\n"); | 232 | dev_err(dev, "Unable to register watchdog\n"); |
229 | clk_disable_unprepare(clk); | ||
230 | return ret; | 233 | return ret; |
231 | } | 234 | } |
232 | 235 | ||
233 | st_wdog_setup(st_wdog, true); | 236 | st_wdog_setup(st_wdog, true); |
234 | 237 | ||
235 | dev_info(&pdev->dev, "LPC Watchdog driver registered, reset type is %s", | 238 | dev_info(dev, "LPC Watchdog driver registered, reset type is %s", |
236 | st_wdog->warm_reset ? "warm" : "cold"); | 239 | st_wdog->warm_reset ? "warm" : "cold"); |
237 | 240 | ||
238 | return ret; | 241 | return ret; |
@@ -243,8 +246,6 @@ static int st_wdog_remove(struct platform_device *pdev) | |||
243 | struct st_wdog *st_wdog = watchdog_get_drvdata(&st_wdog_dev); | 246 | struct st_wdog *st_wdog = watchdog_get_drvdata(&st_wdog_dev); |
244 | 247 | ||
245 | st_wdog_setup(st_wdog, false); | 248 | st_wdog_setup(st_wdog, false); |
246 | watchdog_unregister_device(&st_wdog_dev); | ||
247 | clk_disable_unprepare(st_wdog->clk); | ||
248 | 249 | ||
249 | return 0; | 250 | return 0; |
250 | } | 251 | } |
diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c index e00e3b3526c6..d569a3634d9b 100644 --- a/drivers/watchdog/stm32_iwdg.c +++ b/drivers/watchdog/stm32_iwdg.c | |||
@@ -34,36 +34,44 @@ | |||
34 | #define KR_KEY_EWA 0x5555 /* write access enable */ | 34 | #define KR_KEY_EWA 0x5555 /* write access enable */ |
35 | #define KR_KEY_DWA 0x0000 /* write access disable */ | 35 | #define KR_KEY_DWA 0x0000 /* write access disable */ |
36 | 36 | ||
37 | /* IWDG_PR register bit values */ | 37 | /* IWDG_PR register */ |
38 | #define PR_4 0x00 /* prescaler set to 4 */ | 38 | #define PR_SHIFT 2 |
39 | #define PR_8 0x01 /* prescaler set to 8 */ | 39 | #define PR_MIN BIT(PR_SHIFT) |
40 | #define PR_16 0x02 /* prescaler set to 16 */ | ||
41 | #define PR_32 0x03 /* prescaler set to 32 */ | ||
42 | #define PR_64 0x04 /* prescaler set to 64 */ | ||
43 | #define PR_128 0x05 /* prescaler set to 128 */ | ||
44 | #define PR_256 0x06 /* prescaler set to 256 */ | ||
45 | 40 | ||
46 | /* IWDG_RLR register values */ | 41 | /* IWDG_RLR register values */ |
47 | #define RLR_MIN 0x07C /* min value supported by reload register */ | 42 | #define RLR_MIN 0x2 /* min value recommended */ |
48 | #define RLR_MAX 0xFFF /* max value supported by reload register */ | 43 | #define RLR_MAX GENMASK(11, 0) /* max value of reload register */ |
49 | 44 | ||
50 | /* IWDG_SR register bit mask */ | 45 | /* IWDG_SR register bit mask */ |
51 | #define FLAG_PVU BIT(0) /* Watchdog prescaler value update */ | 46 | #define SR_PVU BIT(0) /* Watchdog prescaler value update */ |
52 | #define FLAG_RVU BIT(1) /* Watchdog counter reload value update */ | 47 | #define SR_RVU BIT(1) /* Watchdog counter reload value update */ |
53 | 48 | ||
54 | /* set timeout to 100000 us */ | 49 | /* set timeout to 100000 us */ |
55 | #define TIMEOUT_US 100000 | 50 | #define TIMEOUT_US 100000 |
56 | #define SLEEP_US 1000 | 51 | #define SLEEP_US 1000 |
57 | 52 | ||
58 | #define HAS_PCLK true | 53 | struct stm32_iwdg_data { |
54 | bool has_pclk; | ||
55 | u32 max_prescaler; | ||
56 | }; | ||
57 | |||
58 | static const struct stm32_iwdg_data stm32_iwdg_data = { | ||
59 | .has_pclk = false, | ||
60 | .max_prescaler = 256, | ||
61 | }; | ||
62 | |||
63 | static const struct stm32_iwdg_data stm32mp1_iwdg_data = { | ||
64 | .has_pclk = true, | ||
65 | .max_prescaler = 1024, | ||
66 | }; | ||
59 | 67 | ||
60 | struct stm32_iwdg { | 68 | struct stm32_iwdg { |
61 | struct watchdog_device wdd; | 69 | struct watchdog_device wdd; |
70 | const struct stm32_iwdg_data *data; | ||
62 | void __iomem *regs; | 71 | void __iomem *regs; |
63 | struct clk *clk_lsi; | 72 | struct clk *clk_lsi; |
64 | struct clk *clk_pclk; | 73 | struct clk *clk_pclk; |
65 | unsigned int rate; | 74 | unsigned int rate; |
66 | bool has_pclk; | ||
67 | }; | 75 | }; |
68 | 76 | ||
69 | static inline u32 reg_read(void __iomem *base, u32 reg) | 77 | static inline u32 reg_read(void __iomem *base, u32 reg) |
@@ -79,31 +87,35 @@ static inline void reg_write(void __iomem *base, u32 reg, u32 val) | |||
79 | static int stm32_iwdg_start(struct watchdog_device *wdd) | 87 | static int stm32_iwdg_start(struct watchdog_device *wdd) |
80 | { | 88 | { |
81 | struct stm32_iwdg *wdt = watchdog_get_drvdata(wdd); | 89 | struct stm32_iwdg *wdt = watchdog_get_drvdata(wdd); |
82 | u32 val = FLAG_PVU | FLAG_RVU; | 90 | u32 tout, presc, iwdg_rlr, iwdg_pr, iwdg_sr; |
83 | u32 reload; | ||
84 | int ret; | 91 | int ret; |
85 | 92 | ||
86 | dev_dbg(wdd->parent, "%s\n", __func__); | 93 | dev_dbg(wdd->parent, "%s\n", __func__); |
87 | 94 | ||
88 | /* prescaler fixed to 256 */ | 95 | tout = clamp_t(unsigned int, wdd->timeout, |
89 | reload = clamp_t(unsigned int, ((wdd->timeout * wdt->rate) / 256) - 1, | 96 | wdd->min_timeout, wdd->max_hw_heartbeat_ms / 1000); |
90 | RLR_MIN, RLR_MAX); | 97 | |
98 | presc = DIV_ROUND_UP(tout * wdt->rate, RLR_MAX + 1); | ||
99 | |||
100 | /* The prescaler is align on power of 2 and start at 2 ^ PR_SHIFT. */ | ||
101 | presc = roundup_pow_of_two(presc); | ||
102 | iwdg_pr = presc <= 1 << PR_SHIFT ? 0 : ilog2(presc) - PR_SHIFT; | ||
103 | iwdg_rlr = ((tout * wdt->rate) / presc) - 1; | ||
91 | 104 | ||
92 | /* enable write access */ | 105 | /* enable write access */ |
93 | reg_write(wdt->regs, IWDG_KR, KR_KEY_EWA); | 106 | reg_write(wdt->regs, IWDG_KR, KR_KEY_EWA); |
94 | 107 | ||
95 | /* set prescaler & reload registers */ | 108 | /* set prescaler & reload registers */ |
96 | reg_write(wdt->regs, IWDG_PR, PR_256); /* prescaler fix to 256 */ | 109 | reg_write(wdt->regs, IWDG_PR, iwdg_pr); |
97 | reg_write(wdt->regs, IWDG_RLR, reload); | 110 | reg_write(wdt->regs, IWDG_RLR, iwdg_rlr); |
98 | reg_write(wdt->regs, IWDG_KR, KR_KEY_ENABLE); | 111 | reg_write(wdt->regs, IWDG_KR, KR_KEY_ENABLE); |
99 | 112 | ||
100 | /* wait for the registers to be updated (max 100ms) */ | 113 | /* wait for the registers to be updated (max 100ms) */ |
101 | ret = readl_relaxed_poll_timeout(wdt->regs + IWDG_SR, val, | 114 | ret = readl_relaxed_poll_timeout(wdt->regs + IWDG_SR, iwdg_sr, |
102 | !(val & (FLAG_PVU | FLAG_RVU)), | 115 | !(iwdg_sr & (SR_PVU | SR_RVU)), |
103 | SLEEP_US, TIMEOUT_US); | 116 | SLEEP_US, TIMEOUT_US); |
104 | if (ret) { | 117 | if (ret) { |
105 | dev_err(wdd->parent, | 118 | dev_err(wdd->parent, "Fail to set prescaler, reload regs\n"); |
106 | "Fail to set prescaler or reload registers\n"); | ||
107 | return ret; | 119 | return ret; |
108 | } | 120 | } |
109 | 121 | ||
@@ -138,38 +150,52 @@ static int stm32_iwdg_set_timeout(struct watchdog_device *wdd, | |||
138 | return 0; | 150 | return 0; |
139 | } | 151 | } |
140 | 152 | ||
153 | static void stm32_clk_disable_unprepare(void *data) | ||
154 | { | ||
155 | clk_disable_unprepare(data); | ||
156 | } | ||
157 | |||
141 | static int stm32_iwdg_clk_init(struct platform_device *pdev, | 158 | static int stm32_iwdg_clk_init(struct platform_device *pdev, |
142 | struct stm32_iwdg *wdt) | 159 | struct stm32_iwdg *wdt) |
143 | { | 160 | { |
161 | struct device *dev = &pdev->dev; | ||
144 | u32 ret; | 162 | u32 ret; |
145 | 163 | ||
146 | wdt->clk_lsi = devm_clk_get(&pdev->dev, "lsi"); | 164 | wdt->clk_lsi = devm_clk_get(dev, "lsi"); |
147 | if (IS_ERR(wdt->clk_lsi)) { | 165 | if (IS_ERR(wdt->clk_lsi)) { |
148 | dev_err(&pdev->dev, "Unable to get lsi clock\n"); | 166 | dev_err(dev, "Unable to get lsi clock\n"); |
149 | return PTR_ERR(wdt->clk_lsi); | 167 | return PTR_ERR(wdt->clk_lsi); |
150 | } | 168 | } |
151 | 169 | ||
152 | /* optional peripheral clock */ | 170 | /* optional peripheral clock */ |
153 | if (wdt->has_pclk) { | 171 | if (wdt->data->has_pclk) { |
154 | wdt->clk_pclk = devm_clk_get(&pdev->dev, "pclk"); | 172 | wdt->clk_pclk = devm_clk_get(dev, "pclk"); |
155 | if (IS_ERR(wdt->clk_pclk)) { | 173 | if (IS_ERR(wdt->clk_pclk)) { |
156 | dev_err(&pdev->dev, "Unable to get pclk clock\n"); | 174 | dev_err(dev, "Unable to get pclk clock\n"); |
157 | return PTR_ERR(wdt->clk_pclk); | 175 | return PTR_ERR(wdt->clk_pclk); |
158 | } | 176 | } |
159 | 177 | ||
160 | ret = clk_prepare_enable(wdt->clk_pclk); | 178 | ret = clk_prepare_enable(wdt->clk_pclk); |
161 | if (ret) { | 179 | if (ret) { |
162 | dev_err(&pdev->dev, "Unable to prepare pclk clock\n"); | 180 | dev_err(dev, "Unable to prepare pclk clock\n"); |
163 | return ret; | 181 | return ret; |
164 | } | 182 | } |
183 | ret = devm_add_action_or_reset(dev, | ||
184 | stm32_clk_disable_unprepare, | ||
185 | wdt->clk_pclk); | ||
186 | if (ret) | ||
187 | return ret; | ||
165 | } | 188 | } |
166 | 189 | ||
167 | ret = clk_prepare_enable(wdt->clk_lsi); | 190 | ret = clk_prepare_enable(wdt->clk_lsi); |
168 | if (ret) { | 191 | if (ret) { |
169 | dev_err(&pdev->dev, "Unable to prepare lsi clock\n"); | 192 | dev_err(dev, "Unable to prepare lsi clock\n"); |
170 | clk_disable_unprepare(wdt->clk_pclk); | ||
171 | return ret; | 193 | return ret; |
172 | } | 194 | } |
195 | ret = devm_add_action_or_reset(dev, stm32_clk_disable_unprepare, | ||
196 | wdt->clk_lsi); | ||
197 | if (ret) | ||
198 | return ret; | ||
173 | 199 | ||
174 | wdt->rate = clk_get_rate(wdt->clk_lsi); | 200 | wdt->rate = clk_get_rate(wdt->clk_lsi); |
175 | 201 | ||
@@ -191,35 +217,31 @@ static const struct watchdog_ops stm32_iwdg_ops = { | |||
191 | }; | 217 | }; |
192 | 218 | ||
193 | static const struct of_device_id stm32_iwdg_of_match[] = { | 219 | static const struct of_device_id stm32_iwdg_of_match[] = { |
194 | { .compatible = "st,stm32-iwdg", .data = (void *)!HAS_PCLK }, | 220 | { .compatible = "st,stm32-iwdg", .data = &stm32_iwdg_data }, |
195 | { .compatible = "st,stm32mp1-iwdg", .data = (void *)HAS_PCLK }, | 221 | { .compatible = "st,stm32mp1-iwdg", .data = &stm32mp1_iwdg_data }, |
196 | { /* end node */ } | 222 | { /* end node */ } |
197 | }; | 223 | }; |
198 | MODULE_DEVICE_TABLE(of, stm32_iwdg_of_match); | 224 | MODULE_DEVICE_TABLE(of, stm32_iwdg_of_match); |
199 | 225 | ||
200 | static int stm32_iwdg_probe(struct platform_device *pdev) | 226 | static int stm32_iwdg_probe(struct platform_device *pdev) |
201 | { | 227 | { |
228 | struct device *dev = &pdev->dev; | ||
202 | struct watchdog_device *wdd; | 229 | struct watchdog_device *wdd; |
203 | const struct of_device_id *match; | ||
204 | struct stm32_iwdg *wdt; | 230 | struct stm32_iwdg *wdt; |
205 | struct resource *res; | ||
206 | int ret; | 231 | int ret; |
207 | 232 | ||
208 | match = of_match_device(stm32_iwdg_of_match, &pdev->dev); | 233 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
209 | if (!match) | ||
210 | return -ENODEV; | ||
211 | |||
212 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | ||
213 | if (!wdt) | 234 | if (!wdt) |
214 | return -ENOMEM; | 235 | return -ENOMEM; |
215 | 236 | ||
216 | wdt->has_pclk = match->data; | 237 | wdt->data = of_device_get_match_data(&pdev->dev); |
238 | if (!wdt->data) | ||
239 | return -ENODEV; | ||
217 | 240 | ||
218 | /* This is the timer base. */ | 241 | /* This is the timer base. */ |
219 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 242 | wdt->regs = devm_platform_ioremap_resource(pdev, 0); |
220 | wdt->regs = devm_ioremap_resource(&pdev->dev, res); | ||
221 | if (IS_ERR(wdt->regs)) { | 243 | if (IS_ERR(wdt->regs)) { |
222 | dev_err(&pdev->dev, "Could not get resource\n"); | 244 | dev_err(dev, "Could not get resource\n"); |
223 | return PTR_ERR(wdt->regs); | 245 | return PTR_ERR(wdt->regs); |
224 | } | 246 | } |
225 | 247 | ||
@@ -229,50 +251,30 @@ static int stm32_iwdg_probe(struct platform_device *pdev) | |||
229 | 251 | ||
230 | /* Initialize struct watchdog_device. */ | 252 | /* Initialize struct watchdog_device. */ |
231 | wdd = &wdt->wdd; | 253 | wdd = &wdt->wdd; |
254 | wdd->parent = dev; | ||
232 | wdd->info = &stm32_iwdg_info; | 255 | wdd->info = &stm32_iwdg_info; |
233 | wdd->ops = &stm32_iwdg_ops; | 256 | wdd->ops = &stm32_iwdg_ops; |
234 | wdd->min_timeout = ((RLR_MIN + 1) * 256) / wdt->rate; | 257 | wdd->min_timeout = DIV_ROUND_UP((RLR_MIN + 1) * PR_MIN, wdt->rate); |
235 | wdd->max_hw_heartbeat_ms = ((RLR_MAX + 1) * 256 * 1000) / wdt->rate; | 258 | wdd->max_hw_heartbeat_ms = ((RLR_MAX + 1) * wdt->data->max_prescaler * |
236 | wdd->parent = &pdev->dev; | 259 | 1000) / wdt->rate; |
237 | 260 | ||
238 | watchdog_set_drvdata(wdd, wdt); | 261 | watchdog_set_drvdata(wdd, wdt); |
239 | watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT); | 262 | watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT); |
263 | watchdog_init_timeout(wdd, 0, dev); | ||
240 | 264 | ||
241 | ret = watchdog_init_timeout(wdd, 0, &pdev->dev); | 265 | ret = devm_watchdog_register_device(dev, wdd); |
242 | if (ret) | ||
243 | dev_warn(&pdev->dev, | ||
244 | "unable to set timeout value, using default\n"); | ||
245 | |||
246 | ret = watchdog_register_device(wdd); | ||
247 | if (ret) { | 266 | if (ret) { |
248 | dev_err(&pdev->dev, "failed to register watchdog device\n"); | 267 | dev_err(dev, "failed to register watchdog device\n"); |
249 | goto err; | 268 | return ret; |
250 | } | 269 | } |
251 | 270 | ||
252 | platform_set_drvdata(pdev, wdt); | 271 | platform_set_drvdata(pdev, wdt); |
253 | 272 | ||
254 | return 0; | 273 | return 0; |
255 | err: | ||
256 | clk_disable_unprepare(wdt->clk_lsi); | ||
257 | clk_disable_unprepare(wdt->clk_pclk); | ||
258 | |||
259 | return ret; | ||
260 | } | ||
261 | |||
262 | static int stm32_iwdg_remove(struct platform_device *pdev) | ||
263 | { | ||
264 | struct stm32_iwdg *wdt = platform_get_drvdata(pdev); | ||
265 | |||
266 | watchdog_unregister_device(&wdt->wdd); | ||
267 | clk_disable_unprepare(wdt->clk_lsi); | ||
268 | clk_disable_unprepare(wdt->clk_pclk); | ||
269 | |||
270 | return 0; | ||
271 | } | 274 | } |
272 | 275 | ||
273 | static struct platform_driver stm32_iwdg_driver = { | 276 | static struct platform_driver stm32_iwdg_driver = { |
274 | .probe = stm32_iwdg_probe, | 277 | .probe = stm32_iwdg_probe, |
275 | .remove = stm32_iwdg_remove, | ||
276 | .driver = { | 278 | .driver = { |
277 | .name = "iwdg", | 279 | .name = "iwdg", |
278 | .of_match_table = of_match_ptr(stm32_iwdg_of_match), | 280 | .of_match_table = of_match_ptr(stm32_iwdg_of_match), |
diff --git a/drivers/watchdog/stmp3xxx_rtc_wdt.c b/drivers/watchdog/stmp3xxx_rtc_wdt.c index 994c54cc68e9..671f4ba7b4ed 100644 --- a/drivers/watchdog/stmp3xxx_rtc_wdt.c +++ b/drivers/watchdog/stmp3xxx_rtc_wdt.c | |||
@@ -89,31 +89,31 @@ static struct notifier_block wdt_notifier = { | |||
89 | 89 | ||
90 | static int stmp3xxx_wdt_probe(struct platform_device *pdev) | 90 | static int stmp3xxx_wdt_probe(struct platform_device *pdev) |
91 | { | 91 | { |
92 | struct device *dev = &pdev->dev; | ||
92 | int ret; | 93 | int ret; |
93 | 94 | ||
94 | watchdog_set_drvdata(&stmp3xxx_wdd, &pdev->dev); | 95 | watchdog_set_drvdata(&stmp3xxx_wdd, dev); |
95 | 96 | ||
96 | stmp3xxx_wdd.timeout = clamp_t(unsigned, heartbeat, 1, STMP3XXX_MAX_TIMEOUT); | 97 | stmp3xxx_wdd.timeout = clamp_t(unsigned, heartbeat, 1, STMP3XXX_MAX_TIMEOUT); |
97 | stmp3xxx_wdd.parent = &pdev->dev; | 98 | stmp3xxx_wdd.parent = dev; |
98 | 99 | ||
99 | ret = watchdog_register_device(&stmp3xxx_wdd); | 100 | ret = devm_watchdog_register_device(dev, &stmp3xxx_wdd); |
100 | if (ret < 0) { | 101 | if (ret < 0) { |
101 | dev_err(&pdev->dev, "cannot register watchdog device\n"); | 102 | dev_err(dev, "cannot register watchdog device\n"); |
102 | return ret; | 103 | return ret; |
103 | } | 104 | } |
104 | 105 | ||
105 | if (register_reboot_notifier(&wdt_notifier)) | 106 | if (register_reboot_notifier(&wdt_notifier)) |
106 | dev_warn(&pdev->dev, "cannot register reboot notifier\n"); | 107 | dev_warn(dev, "cannot register reboot notifier\n"); |
107 | 108 | ||
108 | dev_info(&pdev->dev, "initialized watchdog with heartbeat %ds\n", | 109 | dev_info(dev, "initialized watchdog with heartbeat %ds\n", |
109 | stmp3xxx_wdd.timeout); | 110 | stmp3xxx_wdd.timeout); |
110 | return 0; | 111 | return 0; |
111 | } | 112 | } |
112 | 113 | ||
113 | static int stmp3xxx_wdt_remove(struct platform_device *pdev) | 114 | static int stmp3xxx_wdt_remove(struct platform_device *pdev) |
114 | { | 115 | { |
115 | unregister_reboot_notifier(&wdt_notifier); | 116 | unregister_reboot_notifier(&wdt_notifier); |
116 | watchdog_unregister_device(&stmp3xxx_wdd); | ||
117 | return 0; | 117 | return 0; |
118 | } | 118 | } |
119 | 119 | ||
diff --git a/drivers/watchdog/stpmic1_wdt.c b/drivers/watchdog/stpmic1_wdt.c index ad431d8ad95f..45d0c543466f 100644 --- a/drivers/watchdog/stpmic1_wdt.c +++ b/drivers/watchdog/stpmic1_wdt.c | |||
@@ -81,18 +81,19 @@ static const struct watchdog_ops pmic_watchdog_ops = { | |||
81 | 81 | ||
82 | static int pmic_wdt_probe(struct platform_device *pdev) | 82 | static int pmic_wdt_probe(struct platform_device *pdev) |
83 | { | 83 | { |
84 | struct device *dev = &pdev->dev; | ||
84 | int ret; | 85 | int ret; |
85 | struct stpmic1 *pmic; | 86 | struct stpmic1 *pmic; |
86 | struct stpmic1_wdt *wdt; | 87 | struct stpmic1_wdt *wdt; |
87 | 88 | ||
88 | if (!pdev->dev.parent) | 89 | if (!dev->parent) |
89 | return -EINVAL; | 90 | return -EINVAL; |
90 | 91 | ||
91 | pmic = dev_get_drvdata(pdev->dev.parent); | 92 | pmic = dev_get_drvdata(dev->parent); |
92 | if (!pmic) | 93 | if (!pmic) |
93 | return -EINVAL; | 94 | return -EINVAL; |
94 | 95 | ||
95 | wdt = devm_kzalloc(&pdev->dev, sizeof(struct stpmic1_wdt), GFP_KERNEL); | 96 | wdt = devm_kzalloc(dev, sizeof(struct stpmic1_wdt), GFP_KERNEL); |
96 | if (!wdt) | 97 | if (!wdt) |
97 | return -ENOMEM; | 98 | return -ENOMEM; |
98 | 99 | ||
@@ -102,15 +103,15 @@ static int pmic_wdt_probe(struct platform_device *pdev) | |||
102 | wdt->wdtdev.ops = &pmic_watchdog_ops; | 103 | wdt->wdtdev.ops = &pmic_watchdog_ops; |
103 | wdt->wdtdev.min_timeout = PMIC_WDT_MIN_TIMEOUT; | 104 | wdt->wdtdev.min_timeout = PMIC_WDT_MIN_TIMEOUT; |
104 | wdt->wdtdev.max_timeout = PMIC_WDT_MAX_TIMEOUT; | 105 | wdt->wdtdev.max_timeout = PMIC_WDT_MAX_TIMEOUT; |
105 | wdt->wdtdev.parent = &pdev->dev; | 106 | wdt->wdtdev.parent = dev; |
106 | 107 | ||
107 | wdt->wdtdev.timeout = PMIC_WDT_DEFAULT_TIMEOUT; | 108 | wdt->wdtdev.timeout = PMIC_WDT_DEFAULT_TIMEOUT; |
108 | watchdog_init_timeout(&wdt->wdtdev, 0, &pdev->dev); | 109 | watchdog_init_timeout(&wdt->wdtdev, 0, dev); |
109 | 110 | ||
110 | watchdog_set_nowayout(&wdt->wdtdev, nowayout); | 111 | watchdog_set_nowayout(&wdt->wdtdev, nowayout); |
111 | watchdog_set_drvdata(&wdt->wdtdev, wdt); | 112 | watchdog_set_drvdata(&wdt->wdtdev, wdt); |
112 | 113 | ||
113 | ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdtdev); | 114 | ret = devm_watchdog_register_device(dev, &wdt->wdtdev); |
114 | if (ret) | 115 | if (ret) |
115 | return ret; | 116 | return ret; |
116 | 117 | ||
diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c index c6c73656997e..9c22f7753c6b 100644 --- a/drivers/watchdog/sunxi_wdt.c +++ b/drivers/watchdog/sunxi_wdt.c | |||
@@ -233,20 +233,19 @@ MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids); | |||
233 | 233 | ||
234 | static int sunxi_wdt_probe(struct platform_device *pdev) | 234 | static int sunxi_wdt_probe(struct platform_device *pdev) |
235 | { | 235 | { |
236 | struct device *dev = &pdev->dev; | ||
236 | struct sunxi_wdt_dev *sunxi_wdt; | 237 | struct sunxi_wdt_dev *sunxi_wdt; |
237 | struct resource *res; | ||
238 | int err; | 238 | int err; |
239 | 239 | ||
240 | sunxi_wdt = devm_kzalloc(&pdev->dev, sizeof(*sunxi_wdt), GFP_KERNEL); | 240 | sunxi_wdt = devm_kzalloc(dev, sizeof(*sunxi_wdt), GFP_KERNEL); |
241 | if (!sunxi_wdt) | 241 | if (!sunxi_wdt) |
242 | return -EINVAL; | 242 | return -EINVAL; |
243 | 243 | ||
244 | sunxi_wdt->wdt_regs = of_device_get_match_data(&pdev->dev); | 244 | sunxi_wdt->wdt_regs = of_device_get_match_data(dev); |
245 | if (!sunxi_wdt->wdt_regs) | 245 | if (!sunxi_wdt->wdt_regs) |
246 | return -ENODEV; | 246 | return -ENODEV; |
247 | 247 | ||
248 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 248 | sunxi_wdt->wdt_base = devm_platform_ioremap_resource(pdev, 0); |
249 | sunxi_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res); | ||
250 | if (IS_ERR(sunxi_wdt->wdt_base)) | 249 | if (IS_ERR(sunxi_wdt->wdt_base)) |
251 | return PTR_ERR(sunxi_wdt->wdt_base); | 250 | return PTR_ERR(sunxi_wdt->wdt_base); |
252 | 251 | ||
@@ -255,9 +254,9 @@ static int sunxi_wdt_probe(struct platform_device *pdev) | |||
255 | sunxi_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT; | 254 | sunxi_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT; |
256 | sunxi_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT; | 255 | sunxi_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT; |
257 | sunxi_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT; | 256 | sunxi_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT; |
258 | sunxi_wdt->wdt_dev.parent = &pdev->dev; | 257 | sunxi_wdt->wdt_dev.parent = dev; |
259 | 258 | ||
260 | watchdog_init_timeout(&sunxi_wdt->wdt_dev, timeout, &pdev->dev); | 259 | watchdog_init_timeout(&sunxi_wdt->wdt_dev, timeout, dev); |
261 | watchdog_set_nowayout(&sunxi_wdt->wdt_dev, nowayout); | 260 | watchdog_set_nowayout(&sunxi_wdt->wdt_dev, nowayout); |
262 | watchdog_set_restart_priority(&sunxi_wdt->wdt_dev, 128); | 261 | watchdog_set_restart_priority(&sunxi_wdt->wdt_dev, 128); |
263 | 262 | ||
@@ -266,12 +265,12 @@ static int sunxi_wdt_probe(struct platform_device *pdev) | |||
266 | sunxi_wdt_stop(&sunxi_wdt->wdt_dev); | 265 | sunxi_wdt_stop(&sunxi_wdt->wdt_dev); |
267 | 266 | ||
268 | watchdog_stop_on_reboot(&sunxi_wdt->wdt_dev); | 267 | watchdog_stop_on_reboot(&sunxi_wdt->wdt_dev); |
269 | err = devm_watchdog_register_device(&pdev->dev, &sunxi_wdt->wdt_dev); | 268 | err = devm_watchdog_register_device(dev, &sunxi_wdt->wdt_dev); |
270 | if (unlikely(err)) | 269 | if (unlikely(err)) |
271 | return err; | 270 | return err; |
272 | 271 | ||
273 | dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", | 272 | dev_info(dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", |
274 | sunxi_wdt->wdt_dev.timeout, nowayout); | 273 | sunxi_wdt->wdt_dev.timeout, nowayout); |
275 | 274 | ||
276 | return 0; | 275 | return 0; |
277 | } | 276 | } |
diff --git a/drivers/watchdog/tangox_wdt.c b/drivers/watchdog/tangox_wdt.c index d0b53f3c0d17..1afb0e9d808c 100644 --- a/drivers/watchdog/tangox_wdt.c +++ b/drivers/watchdog/tangox_wdt.c | |||
@@ -108,10 +108,14 @@ static const struct watchdog_ops tangox_wdt_ops = { | |||
108 | .restart = tangox_wdt_restart, | 108 | .restart = tangox_wdt_restart, |
109 | }; | 109 | }; |
110 | 110 | ||
111 | static void tangox_clk_disable_unprepare(void *data) | ||
112 | { | ||
113 | clk_disable_unprepare(data); | ||
114 | } | ||
115 | |||
111 | static int tangox_wdt_probe(struct platform_device *pdev) | 116 | static int tangox_wdt_probe(struct platform_device *pdev) |
112 | { | 117 | { |
113 | struct tangox_wdt_device *dev; | 118 | struct tangox_wdt_device *dev; |
114 | struct resource *res; | ||
115 | u32 config; | 119 | u32 config; |
116 | int err; | 120 | int err; |
117 | 121 | ||
@@ -119,8 +123,7 @@ static int tangox_wdt_probe(struct platform_device *pdev) | |||
119 | if (!dev) | 123 | if (!dev) |
120 | return -ENOMEM; | 124 | return -ENOMEM; |
121 | 125 | ||
122 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 126 | dev->base = devm_platform_ioremap_resource(pdev, 0); |
123 | dev->base = devm_ioremap_resource(&pdev->dev, res); | ||
124 | if (IS_ERR(dev->base)) | 127 | if (IS_ERR(dev->base)) |
125 | return PTR_ERR(dev->base); | 128 | return PTR_ERR(dev->base); |
126 | 129 | ||
@@ -131,12 +134,14 @@ static int tangox_wdt_probe(struct platform_device *pdev) | |||
131 | err = clk_prepare_enable(dev->clk); | 134 | err = clk_prepare_enable(dev->clk); |
132 | if (err) | 135 | if (err) |
133 | return err; | 136 | return err; |
137 | err = devm_add_action_or_reset(&pdev->dev, | ||
138 | tangox_clk_disable_unprepare, dev->clk); | ||
139 | if (err) | ||
140 | return err; | ||
134 | 141 | ||
135 | dev->clk_rate = clk_get_rate(dev->clk); | 142 | dev->clk_rate = clk_get_rate(dev->clk); |
136 | if (!dev->clk_rate) { | 143 | if (!dev->clk_rate) |
137 | err = -EINVAL; | 144 | return -EINVAL; |
138 | goto err; | ||
139 | } | ||
140 | 145 | ||
141 | dev->wdt.parent = &pdev->dev; | 146 | dev->wdt.parent = &pdev->dev; |
142 | dev->wdt.info = &tangox_wdt_info; | 147 | dev->wdt.info = &tangox_wdt_info; |
@@ -170,31 +175,16 @@ static int tangox_wdt_probe(struct platform_device *pdev) | |||
170 | 175 | ||
171 | watchdog_set_restart_priority(&dev->wdt, 128); | 176 | watchdog_set_restart_priority(&dev->wdt, 128); |
172 | 177 | ||
173 | err = watchdog_register_device(&dev->wdt); | 178 | watchdog_stop_on_unregister(&dev->wdt); |
179 | err = devm_watchdog_register_device(&pdev->dev, &dev->wdt); | ||
174 | if (err) | 180 | if (err) |
175 | goto err; | 181 | return err; |
176 | 182 | ||
177 | platform_set_drvdata(pdev, dev); | 183 | platform_set_drvdata(pdev, dev); |
178 | 184 | ||
179 | dev_info(&pdev->dev, "SMP86xx/SMP87xx watchdog registered\n"); | 185 | dev_info(&pdev->dev, "SMP86xx/SMP87xx watchdog registered\n"); |
180 | 186 | ||
181 | return 0; | 187 | return 0; |
182 | |||
183 | err: | ||
184 | clk_disable_unprepare(dev->clk); | ||
185 | return err; | ||
186 | } | ||
187 | |||
188 | static int tangox_wdt_remove(struct platform_device *pdev) | ||
189 | { | ||
190 | struct tangox_wdt_device *dev = platform_get_drvdata(pdev); | ||
191 | |||
192 | tangox_wdt_stop(&dev->wdt); | ||
193 | clk_disable_unprepare(dev->clk); | ||
194 | |||
195 | watchdog_unregister_device(&dev->wdt); | ||
196 | |||
197 | return 0; | ||
198 | } | 188 | } |
199 | 189 | ||
200 | static const struct of_device_id tangox_wdt_dt_ids[] = { | 190 | static const struct of_device_id tangox_wdt_dt_ids[] = { |
@@ -206,7 +196,6 @@ MODULE_DEVICE_TABLE(of, tangox_wdt_dt_ids); | |||
206 | 196 | ||
207 | static struct platform_driver tangox_wdt_driver = { | 197 | static struct platform_driver tangox_wdt_driver = { |
208 | .probe = tangox_wdt_probe, | 198 | .probe = tangox_wdt_probe, |
209 | .remove = tangox_wdt_remove, | ||
210 | .driver = { | 199 | .driver = { |
211 | .name = "tangox-wdt", | 200 | .name = "tangox-wdt", |
212 | .of_match_table = tangox_wdt_dt_ids, | 201 | .of_match_table = tangox_wdt_dt_ids, |
diff --git a/drivers/watchdog/tegra_wdt.c b/drivers/watchdog/tegra_wdt.c index 877dd39bd41f..a58b000acc4f 100644 --- a/drivers/watchdog/tegra_wdt.c +++ b/drivers/watchdog/tegra_wdt.c | |||
@@ -181,15 +181,14 @@ static const struct watchdog_ops tegra_wdt_ops = { | |||
181 | 181 | ||
182 | static int tegra_wdt_probe(struct platform_device *pdev) | 182 | static int tegra_wdt_probe(struct platform_device *pdev) |
183 | { | 183 | { |
184 | struct device *dev = &pdev->dev; | ||
184 | struct watchdog_device *wdd; | 185 | struct watchdog_device *wdd; |
185 | struct tegra_wdt *wdt; | 186 | struct tegra_wdt *wdt; |
186 | struct resource *res; | ||
187 | void __iomem *regs; | 187 | void __iomem *regs; |
188 | int ret; | 188 | int ret; |
189 | 189 | ||
190 | /* This is the timer base. */ | 190 | /* This is the timer base. */ |
191 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 191 | regs = devm_platform_ioremap_resource(pdev, 0); |
192 | regs = devm_ioremap_resource(&pdev->dev, res); | ||
193 | if (IS_ERR(regs)) | 192 | if (IS_ERR(regs)) |
194 | return PTR_ERR(regs); | 193 | return PTR_ERR(regs); |
195 | 194 | ||
@@ -197,7 +196,7 @@ static int tegra_wdt_probe(struct platform_device *pdev) | |||
197 | * Allocate our watchdog driver data, which has the | 196 | * Allocate our watchdog driver data, which has the |
198 | * struct watchdog_device nested within it. | 197 | * struct watchdog_device nested within it. |
199 | */ | 198 | */ |
200 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 199 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
201 | if (!wdt) | 200 | if (!wdt) |
202 | return -ENOMEM; | 201 | return -ENOMEM; |
203 | 202 | ||
@@ -212,39 +211,27 @@ static int tegra_wdt_probe(struct platform_device *pdev) | |||
212 | wdd->ops = &tegra_wdt_ops; | 211 | wdd->ops = &tegra_wdt_ops; |
213 | wdd->min_timeout = MIN_WDT_TIMEOUT; | 212 | wdd->min_timeout = MIN_WDT_TIMEOUT; |
214 | wdd->max_timeout = MAX_WDT_TIMEOUT; | 213 | wdd->max_timeout = MAX_WDT_TIMEOUT; |
215 | wdd->parent = &pdev->dev; | 214 | wdd->parent = dev; |
216 | 215 | ||
217 | watchdog_set_drvdata(wdd, wdt); | 216 | watchdog_set_drvdata(wdd, wdt); |
218 | 217 | ||
219 | watchdog_set_nowayout(wdd, nowayout); | 218 | watchdog_set_nowayout(wdd, nowayout); |
220 | 219 | ||
221 | ret = devm_watchdog_register_device(&pdev->dev, wdd); | 220 | watchdog_stop_on_unregister(wdd); |
221 | ret = devm_watchdog_register_device(dev, wdd); | ||
222 | if (ret) { | 222 | if (ret) { |
223 | dev_err(&pdev->dev, | 223 | dev_err(dev, "failed to register watchdog device\n"); |
224 | "failed to register watchdog device\n"); | ||
225 | return ret; | 224 | return ret; |
226 | } | 225 | } |
227 | 226 | ||
228 | platform_set_drvdata(pdev, wdt); | 227 | platform_set_drvdata(pdev, wdt); |
229 | 228 | ||
230 | dev_info(&pdev->dev, | 229 | dev_info(dev, "initialized (heartbeat = %d sec, nowayout = %d)\n", |
231 | "initialized (heartbeat = %d sec, nowayout = %d)\n", | ||
232 | heartbeat, nowayout); | 230 | heartbeat, nowayout); |
233 | 231 | ||
234 | return 0; | 232 | return 0; |
235 | } | 233 | } |
236 | 234 | ||
237 | static int tegra_wdt_remove(struct platform_device *pdev) | ||
238 | { | ||
239 | struct tegra_wdt *wdt = platform_get_drvdata(pdev); | ||
240 | |||
241 | tegra_wdt_stop(&wdt->wdd); | ||
242 | |||
243 | dev_info(&pdev->dev, "removed wdt\n"); | ||
244 | |||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | #ifdef CONFIG_PM_SLEEP | 235 | #ifdef CONFIG_PM_SLEEP |
249 | static int tegra_wdt_runtime_suspend(struct device *dev) | 236 | static int tegra_wdt_runtime_suspend(struct device *dev) |
250 | { | 237 | { |
@@ -280,7 +267,6 @@ static const struct dev_pm_ops tegra_wdt_pm_ops = { | |||
280 | 267 | ||
281 | static struct platform_driver tegra_wdt_driver = { | 268 | static struct platform_driver tegra_wdt_driver = { |
282 | .probe = tegra_wdt_probe, | 269 | .probe = tegra_wdt_probe, |
283 | .remove = tegra_wdt_remove, | ||
284 | .driver = { | 270 | .driver = { |
285 | .name = "tegra-wdt", | 271 | .name = "tegra-wdt", |
286 | .pm = &tegra_wdt_pm_ops, | 272 | .pm = &tegra_wdt_pm_ops, |
diff --git a/drivers/watchdog/tqmx86_wdt.c b/drivers/watchdog/tqmx86_wdt.c index 52941207a12a..72d0b0adde38 100644 --- a/drivers/watchdog/tqmx86_wdt.c +++ b/drivers/watchdog/tqmx86_wdt.c | |||
@@ -70,11 +70,12 @@ static struct watchdog_ops tqmx86_wdt_ops = { | |||
70 | 70 | ||
71 | static int tqmx86_wdt_probe(struct platform_device *pdev) | 71 | static int tqmx86_wdt_probe(struct platform_device *pdev) |
72 | { | 72 | { |
73 | struct device *dev = &pdev->dev; | ||
73 | struct tqmx86_wdt *priv; | 74 | struct tqmx86_wdt *priv; |
74 | struct resource *res; | 75 | struct resource *res; |
75 | int err; | 76 | int err; |
76 | 77 | ||
77 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); | 78 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
78 | if (!priv) | 79 | if (!priv) |
79 | return -ENOMEM; | 80 | return -ENOMEM; |
80 | 81 | ||
@@ -82,14 +83,13 @@ static int tqmx86_wdt_probe(struct platform_device *pdev) | |||
82 | if (!res) | 83 | if (!res) |
83 | return -ENODEV; | 84 | return -ENODEV; |
84 | 85 | ||
85 | priv->io_base = devm_ioport_map(&pdev->dev, res->start, | 86 | priv->io_base = devm_ioport_map(dev, res->start, resource_size(res)); |
86 | resource_size(res)); | ||
87 | if (!priv->io_base) | 87 | if (!priv->io_base) |
88 | return -ENOMEM; | 88 | return -ENOMEM; |
89 | 89 | ||
90 | watchdog_set_drvdata(&priv->wdd, priv); | 90 | watchdog_set_drvdata(&priv->wdd, priv); |
91 | 91 | ||
92 | priv->wdd.parent = &pdev->dev; | 92 | priv->wdd.parent = dev; |
93 | priv->wdd.info = &tqmx86_wdt_info; | 93 | priv->wdd.info = &tqmx86_wdt_info; |
94 | priv->wdd.ops = &tqmx86_wdt_ops; | 94 | priv->wdd.ops = &tqmx86_wdt_ops; |
95 | priv->wdd.min_timeout = 1; | 95 | priv->wdd.min_timeout = 1; |
@@ -97,16 +97,16 @@ static int tqmx86_wdt_probe(struct platform_device *pdev) | |||
97 | priv->wdd.max_hw_heartbeat_ms = 4096*1000; | 97 | priv->wdd.max_hw_heartbeat_ms = 4096*1000; |
98 | priv->wdd.timeout = WDT_TIMEOUT; | 98 | priv->wdd.timeout = WDT_TIMEOUT; |
99 | 99 | ||
100 | watchdog_init_timeout(&priv->wdd, timeout, &pdev->dev); | 100 | watchdog_init_timeout(&priv->wdd, timeout, dev); |
101 | watchdog_set_nowayout(&priv->wdd, WATCHDOG_NOWAYOUT); | 101 | watchdog_set_nowayout(&priv->wdd, WATCHDOG_NOWAYOUT); |
102 | 102 | ||
103 | tqmx86_wdt_set_timeout(&priv->wdd, priv->wdd.timeout); | 103 | tqmx86_wdt_set_timeout(&priv->wdd, priv->wdd.timeout); |
104 | 104 | ||
105 | err = devm_watchdog_register_device(&pdev->dev, &priv->wdd); | 105 | err = devm_watchdog_register_device(dev, &priv->wdd); |
106 | if (err) | 106 | if (err) |
107 | return err; | 107 | return err; |
108 | 108 | ||
109 | dev_info(&pdev->dev, "TQMx86 watchdog\n"); | 109 | dev_info(dev, "TQMx86 watchdog\n"); |
110 | 110 | ||
111 | return 0; | 111 | return 0; |
112 | } | 112 | } |
diff --git a/drivers/watchdog/ts4800_wdt.c b/drivers/watchdog/ts4800_wdt.c index 89843b16b04a..9dc6d7f45806 100644 --- a/drivers/watchdog/ts4800_wdt.c +++ b/drivers/watchdog/ts4800_wdt.c | |||
@@ -108,7 +108,8 @@ static const struct watchdog_info ts4800_wdt_info = { | |||
108 | 108 | ||
109 | static int ts4800_wdt_probe(struct platform_device *pdev) | 109 | static int ts4800_wdt_probe(struct platform_device *pdev) |
110 | { | 110 | { |
111 | struct device_node *np = pdev->dev.of_node; | 111 | struct device *dev = &pdev->dev; |
112 | struct device_node *np = dev->of_node; | ||
112 | struct device_node *syscon_np; | 113 | struct device_node *syscon_np; |
113 | struct watchdog_device *wdd; | 114 | struct watchdog_device *wdd; |
114 | struct ts4800_wdt *wdt; | 115 | struct ts4800_wdt *wdt; |
@@ -117,18 +118,18 @@ static int ts4800_wdt_probe(struct platform_device *pdev) | |||
117 | 118 | ||
118 | syscon_np = of_parse_phandle(np, "syscon", 0); | 119 | syscon_np = of_parse_phandle(np, "syscon", 0); |
119 | if (!syscon_np) { | 120 | if (!syscon_np) { |
120 | dev_err(&pdev->dev, "no syscon property\n"); | 121 | dev_err(dev, "no syscon property\n"); |
121 | return -ENODEV; | 122 | return -ENODEV; |
122 | } | 123 | } |
123 | 124 | ||
124 | ret = of_property_read_u32_index(np, "syscon", 1, ®); | 125 | ret = of_property_read_u32_index(np, "syscon", 1, ®); |
125 | if (ret < 0) { | 126 | if (ret < 0) { |
126 | dev_err(&pdev->dev, "no offset in syscon\n"); | 127 | dev_err(dev, "no offset in syscon\n"); |
127 | return ret; | 128 | return ret; |
128 | } | 129 | } |
129 | 130 | ||
130 | /* allocate memory for watchdog struct */ | 131 | /* allocate memory for watchdog struct */ |
131 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 132 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
132 | if (!wdt) | 133 | if (!wdt) |
133 | return -ENOMEM; | 134 | return -ENOMEM; |
134 | 135 | ||
@@ -137,13 +138,13 @@ static int ts4800_wdt_probe(struct platform_device *pdev) | |||
137 | wdt->regmap = syscon_node_to_regmap(syscon_np); | 138 | wdt->regmap = syscon_node_to_regmap(syscon_np); |
138 | of_node_put(syscon_np); | 139 | of_node_put(syscon_np); |
139 | if (IS_ERR(wdt->regmap)) { | 140 | if (IS_ERR(wdt->regmap)) { |
140 | dev_err(&pdev->dev, "cannot get parent's regmap\n"); | 141 | dev_err(dev, "cannot get parent's regmap\n"); |
141 | return PTR_ERR(wdt->regmap); | 142 | return PTR_ERR(wdt->regmap); |
142 | } | 143 | } |
143 | 144 | ||
144 | /* Initialize struct watchdog_device */ | 145 | /* Initialize struct watchdog_device */ |
145 | wdd = &wdt->wdd; | 146 | wdd = &wdt->wdd; |
146 | wdd->parent = &pdev->dev; | 147 | wdd->parent = dev; |
147 | wdd->info = &ts4800_wdt_info; | 148 | wdd->info = &ts4800_wdt_info; |
148 | wdd->ops = &ts4800_wdt_ops; | 149 | wdd->ops = &ts4800_wdt_ops; |
149 | wdd->min_timeout = ts4800_wdt_map[0].timeout; | 150 | wdd->min_timeout = ts4800_wdt_map[0].timeout; |
@@ -151,7 +152,7 @@ static int ts4800_wdt_probe(struct platform_device *pdev) | |||
151 | 152 | ||
152 | watchdog_set_drvdata(wdd, wdt); | 153 | watchdog_set_drvdata(wdd, wdt); |
153 | watchdog_set_nowayout(wdd, nowayout); | 154 | watchdog_set_nowayout(wdd, nowayout); |
154 | watchdog_init_timeout(wdd, 0, &pdev->dev); | 155 | watchdog_init_timeout(wdd, 0, dev); |
155 | 156 | ||
156 | /* | 157 | /* |
157 | * As this watchdog supports only a few values, ts4800_wdt_set_timeout | 158 | * As this watchdog supports only a few values, ts4800_wdt_set_timeout |
@@ -169,31 +170,20 @@ static int ts4800_wdt_probe(struct platform_device *pdev) | |||
169 | */ | 170 | */ |
170 | ts4800_wdt_stop(wdd); | 171 | ts4800_wdt_stop(wdd); |
171 | 172 | ||
172 | ret = watchdog_register_device(wdd); | 173 | ret = devm_watchdog_register_device(dev, wdd); |
173 | if (ret) { | 174 | if (ret) { |
174 | dev_err(&pdev->dev, | 175 | dev_err(dev, "failed to register watchdog device\n"); |
175 | "failed to register watchdog device\n"); | ||
176 | return ret; | 176 | return ret; |
177 | } | 177 | } |
178 | 178 | ||
179 | platform_set_drvdata(pdev, wdt); | 179 | platform_set_drvdata(pdev, wdt); |
180 | 180 | ||
181 | dev_info(&pdev->dev, | 181 | dev_info(dev, "initialized (timeout = %d sec, nowayout = %d)\n", |
182 | "initialized (timeout = %d sec, nowayout = %d)\n", | ||
183 | wdd->timeout, nowayout); | 182 | wdd->timeout, nowayout); |
184 | 183 | ||
185 | return 0; | 184 | return 0; |
186 | } | 185 | } |
187 | 186 | ||
188 | static int ts4800_wdt_remove(struct platform_device *pdev) | ||
189 | { | ||
190 | struct ts4800_wdt *wdt = platform_get_drvdata(pdev); | ||
191 | |||
192 | watchdog_unregister_device(&wdt->wdd); | ||
193 | |||
194 | return 0; | ||
195 | } | ||
196 | |||
197 | static const struct of_device_id ts4800_wdt_of_match[] = { | 187 | static const struct of_device_id ts4800_wdt_of_match[] = { |
198 | { .compatible = "technologic,ts4800-wdt", }, | 188 | { .compatible = "technologic,ts4800-wdt", }, |
199 | { }, | 189 | { }, |
@@ -202,7 +192,6 @@ MODULE_DEVICE_TABLE(of, ts4800_wdt_of_match); | |||
202 | 192 | ||
203 | static struct platform_driver ts4800_wdt_driver = { | 193 | static struct platform_driver ts4800_wdt_driver = { |
204 | .probe = ts4800_wdt_probe, | 194 | .probe = ts4800_wdt_probe, |
205 | .remove = ts4800_wdt_remove, | ||
206 | .driver = { | 195 | .driver = { |
207 | .name = "ts4800_wdt", | 196 | .name = "ts4800_wdt", |
208 | .of_match_table = ts4800_wdt_of_match, | 197 | .of_match_table = ts4800_wdt_of_match, |
diff --git a/drivers/watchdog/ts72xx_wdt.c b/drivers/watchdog/ts72xx_wdt.c index 811e43c39ec4..bf918f5fa131 100644 --- a/drivers/watchdog/ts72xx_wdt.c +++ b/drivers/watchdog/ts72xx_wdt.c | |||
@@ -122,22 +122,20 @@ static const struct watchdog_ops ts72xx_wdt_ops = { | |||
122 | 122 | ||
123 | static int ts72xx_wdt_probe(struct platform_device *pdev) | 123 | static int ts72xx_wdt_probe(struct platform_device *pdev) |
124 | { | 124 | { |
125 | struct device *dev = &pdev->dev; | ||
125 | struct ts72xx_wdt_priv *priv; | 126 | struct ts72xx_wdt_priv *priv; |
126 | struct watchdog_device *wdd; | 127 | struct watchdog_device *wdd; |
127 | struct resource *res; | ||
128 | int ret; | 128 | int ret; |
129 | 129 | ||
130 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); | 130 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
131 | if (!priv) | 131 | if (!priv) |
132 | return -ENOMEM; | 132 | return -ENOMEM; |
133 | 133 | ||
134 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 134 | priv->control_reg = devm_platform_ioremap_resource(pdev, 0); |
135 | priv->control_reg = devm_ioremap_resource(&pdev->dev, res); | ||
136 | if (IS_ERR(priv->control_reg)) | 135 | if (IS_ERR(priv->control_reg)) |
137 | return PTR_ERR(priv->control_reg); | 136 | return PTR_ERR(priv->control_reg); |
138 | 137 | ||
139 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 138 | priv->feed_reg = devm_platform_ioremap_resource(pdev, 1); |
140 | priv->feed_reg = devm_ioremap_resource(&pdev->dev, res); | ||
141 | if (IS_ERR(priv->feed_reg)) | 139 | if (IS_ERR(priv->feed_reg)) |
142 | return PTR_ERR(priv->feed_reg); | 140 | return PTR_ERR(priv->feed_reg); |
143 | 141 | ||
@@ -146,20 +144,20 @@ static int ts72xx_wdt_probe(struct platform_device *pdev) | |||
146 | wdd->ops = &ts72xx_wdt_ops; | 144 | wdd->ops = &ts72xx_wdt_ops; |
147 | wdd->min_timeout = 1; | 145 | wdd->min_timeout = 1; |
148 | wdd->max_hw_heartbeat_ms = 8000; | 146 | wdd->max_hw_heartbeat_ms = 8000; |
149 | wdd->parent = &pdev->dev; | 147 | wdd->parent = dev; |
150 | 148 | ||
151 | watchdog_set_nowayout(wdd, nowayout); | 149 | watchdog_set_nowayout(wdd, nowayout); |
152 | 150 | ||
153 | wdd->timeout = TS72XX_WDT_DEFAULT_TIMEOUT; | 151 | wdd->timeout = TS72XX_WDT_DEFAULT_TIMEOUT; |
154 | watchdog_init_timeout(wdd, timeout, &pdev->dev); | 152 | watchdog_init_timeout(wdd, timeout, dev); |
155 | 153 | ||
156 | watchdog_set_drvdata(wdd, priv); | 154 | watchdog_set_drvdata(wdd, priv); |
157 | 155 | ||
158 | ret = devm_watchdog_register_device(&pdev->dev, wdd); | 156 | ret = devm_watchdog_register_device(dev, wdd); |
159 | if (ret) | 157 | if (ret) |
160 | return ret; | 158 | return ret; |
161 | 159 | ||
162 | dev_info(&pdev->dev, "TS-72xx Watchdog driver\n"); | 160 | dev_info(dev, "TS-72xx Watchdog driver\n"); |
163 | 161 | ||
164 | return 0; | 162 | return 0; |
165 | } | 163 | } |
diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c index 569fe85e52da..74c5737cd934 100644 --- a/drivers/watchdog/twl4030_wdt.c +++ b/drivers/watchdog/twl4030_wdt.c | |||
@@ -70,10 +70,10 @@ static const struct watchdog_ops twl4030_wdt_ops = { | |||
70 | 70 | ||
71 | static int twl4030_wdt_probe(struct platform_device *pdev) | 71 | static int twl4030_wdt_probe(struct platform_device *pdev) |
72 | { | 72 | { |
73 | int ret = 0; | 73 | struct device *dev = &pdev->dev; |
74 | struct watchdog_device *wdt; | 74 | struct watchdog_device *wdt; |
75 | 75 | ||
76 | wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); | 76 | wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
77 | if (!wdt) | 77 | if (!wdt) |
78 | return -ENOMEM; | 78 | return -ENOMEM; |
79 | 79 | ||
@@ -83,27 +83,14 @@ static int twl4030_wdt_probe(struct platform_device *pdev) | |||
83 | wdt->timeout = 30; | 83 | wdt->timeout = 30; |
84 | wdt->min_timeout = 1; | 84 | wdt->min_timeout = 1; |
85 | wdt->max_timeout = 30; | 85 | wdt->max_timeout = 30; |
86 | wdt->parent = &pdev->dev; | 86 | wdt->parent = dev; |
87 | 87 | ||
88 | watchdog_set_nowayout(wdt, nowayout); | 88 | watchdog_set_nowayout(wdt, nowayout); |
89 | platform_set_drvdata(pdev, wdt); | 89 | platform_set_drvdata(pdev, wdt); |
90 | 90 | ||
91 | twl4030_wdt_stop(wdt); | 91 | twl4030_wdt_stop(wdt); |
92 | 92 | ||
93 | ret = watchdog_register_device(wdt); | 93 | return devm_watchdog_register_device(dev, wdt); |
94 | if (ret) | ||
95 | return ret; | ||
96 | |||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | static int twl4030_wdt_remove(struct platform_device *pdev) | ||
101 | { | ||
102 | struct watchdog_device *wdt = platform_get_drvdata(pdev); | ||
103 | |||
104 | watchdog_unregister_device(wdt); | ||
105 | |||
106 | return 0; | ||
107 | } | 94 | } |
108 | 95 | ||
109 | #ifdef CONFIG_PM | 96 | #ifdef CONFIG_PM |
@@ -137,7 +124,6 @@ MODULE_DEVICE_TABLE(of, twl_wdt_of_match); | |||
137 | 124 | ||
138 | static struct platform_driver twl4030_wdt_driver = { | 125 | static struct platform_driver twl4030_wdt_driver = { |
139 | .probe = twl4030_wdt_probe, | 126 | .probe = twl4030_wdt_probe, |
140 | .remove = twl4030_wdt_remove, | ||
141 | .suspend = twl4030_wdt_suspend, | 127 | .suspend = twl4030_wdt_suspend, |
142 | .resume = twl4030_wdt_resume, | 128 | .resume = twl4030_wdt_resume, |
143 | .driver = { | 129 | .driver = { |
diff --git a/drivers/watchdog/txx9wdt.c b/drivers/watchdog/txx9wdt.c index 6f7a9deb27d0..fcb4da5b1f4c 100644 --- a/drivers/watchdog/txx9wdt.c +++ b/drivers/watchdog/txx9wdt.c | |||
@@ -103,7 +103,6 @@ static struct watchdog_device txx9wdt = { | |||
103 | 103 | ||
104 | static int __init txx9wdt_probe(struct platform_device *dev) | 104 | static int __init txx9wdt_probe(struct platform_device *dev) |
105 | { | 105 | { |
106 | struct resource *res; | ||
107 | int ret; | 106 | int ret; |
108 | 107 | ||
109 | txx9_imclk = clk_get(NULL, "imbus_clk"); | 108 | txx9_imclk = clk_get(NULL, "imbus_clk"); |
@@ -119,8 +118,7 @@ static int __init txx9wdt_probe(struct platform_device *dev) | |||
119 | goto exit; | 118 | goto exit; |
120 | } | 119 | } |
121 | 120 | ||
122 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | 121 | txx9wdt_reg = devm_platform_ioremap_resource(dev, 0); |
123 | txx9wdt_reg = devm_ioremap_resource(&dev->dev, res); | ||
124 | if (IS_ERR(txx9wdt_reg)) { | 122 | if (IS_ERR(txx9wdt_reg)) { |
125 | ret = PTR_ERR(txx9wdt_reg); | 123 | ret = PTR_ERR(txx9wdt_reg); |
126 | goto exit; | 124 | goto exit; |
diff --git a/drivers/watchdog/uniphier_wdt.c b/drivers/watchdog/uniphier_wdt.c index e20a7a459d69..8e9242c23022 100644 --- a/drivers/watchdog/uniphier_wdt.c +++ b/drivers/watchdog/uniphier_wdt.c | |||
@@ -191,8 +191,6 @@ static int uniphier_wdt_probe(struct platform_device *pdev) | |||
191 | if (!wdev) | 191 | if (!wdev) |
192 | return -ENOMEM; | 192 | return -ENOMEM; |
193 | 193 | ||
194 | platform_set_drvdata(pdev, wdev); | ||
195 | |||
196 | parent = of_get_parent(dev->of_node); /* parent should be syscon node */ | 194 | parent = of_get_parent(dev->of_node); /* parent should be syscon node */ |
197 | regmap = syscon_node_to_regmap(parent); | 195 | regmap = syscon_node_to_regmap(parent); |
198 | of_node_put(parent); | 196 | of_node_put(parent); |
diff --git a/drivers/watchdog/ux500_wdt.c b/drivers/watchdog/ux500_wdt.c index 37c084353cce..9fa7f95f7554 100644 --- a/drivers/watchdog/ux500_wdt.c +++ b/drivers/watchdog/ux500_wdt.c | |||
@@ -86,8 +86,9 @@ static struct watchdog_device ux500_wdt = { | |||
86 | 86 | ||
87 | static int ux500_wdt_probe(struct platform_device *pdev) | 87 | static int ux500_wdt_probe(struct platform_device *pdev) |
88 | { | 88 | { |
89 | struct device *dev = &pdev->dev; | ||
89 | int ret; | 90 | int ret; |
90 | struct ux500_wdt_data *pdata = dev_get_platdata(&pdev->dev); | 91 | struct ux500_wdt_data *pdata = dev_get_platdata(dev); |
91 | 92 | ||
92 | if (pdata) { | 93 | if (pdata) { |
93 | if (pdata->timeout > 0) | 94 | if (pdata->timeout > 0) |
@@ -96,7 +97,7 @@ static int ux500_wdt_probe(struct platform_device *pdev) | |||
96 | ux500_wdt.max_timeout = WATCHDOG_MAX28; | 97 | ux500_wdt.max_timeout = WATCHDOG_MAX28; |
97 | } | 98 | } |
98 | 99 | ||
99 | ux500_wdt.parent = &pdev->dev; | 100 | ux500_wdt.parent = dev; |
100 | watchdog_set_nowayout(&ux500_wdt, nowayout); | 101 | watchdog_set_nowayout(&ux500_wdt, nowayout); |
101 | 102 | ||
102 | /* disable auto off on sleep */ | 103 | /* disable auto off on sleep */ |
@@ -105,18 +106,11 @@ static int ux500_wdt_probe(struct platform_device *pdev) | |||
105 | /* set HW initial value */ | 106 | /* set HW initial value */ |
106 | prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); | 107 | prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); |
107 | 108 | ||
108 | ret = watchdog_register_device(&ux500_wdt); | 109 | ret = devm_watchdog_register_device(dev, &ux500_wdt); |
109 | if (ret) | 110 | if (ret) |
110 | return ret; | 111 | return ret; |
111 | 112 | ||
112 | dev_info(&pdev->dev, "initialized\n"); | 113 | dev_info(dev, "initialized\n"); |
113 | |||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static int ux500_wdt_remove(struct platform_device *dev) | ||
118 | { | ||
119 | watchdog_unregister_device(&ux500_wdt); | ||
120 | 114 | ||
121 | return 0; | 115 | return 0; |
122 | } | 116 | } |
@@ -153,7 +147,6 @@ static int ux500_wdt_resume(struct platform_device *pdev) | |||
153 | 147 | ||
154 | static struct platform_driver ux500_wdt_driver = { | 148 | static struct platform_driver ux500_wdt_driver = { |
155 | .probe = ux500_wdt_probe, | 149 | .probe = ux500_wdt_probe, |
156 | .remove = ux500_wdt_remove, | ||
157 | .suspend = ux500_wdt_suspend, | 150 | .suspend = ux500_wdt_suspend, |
158 | .resume = ux500_wdt_resume, | 151 | .resume = ux500_wdt_resume, |
159 | .driver = { | 152 | .driver = { |
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c index eb8fa25f8eb2..62be9e52a4de 100644 --- a/drivers/watchdog/watchdog_core.c +++ b/drivers/watchdog/watchdog_core.c | |||
@@ -105,34 +105,48 @@ static void watchdog_check_min_max_timeout(struct watchdog_device *wdd) | |||
105 | * timeout module parameter (if it is valid value) or the timeout-sec property | 105 | * timeout module parameter (if it is valid value) or the timeout-sec property |
106 | * (only if it is a valid value and the timeout_parm is out of bounds). | 106 | * (only if it is a valid value and the timeout_parm is out of bounds). |
107 | * If none of them are valid then we keep the old value (which should normally | 107 | * If none of them are valid then we keep the old value (which should normally |
108 | * be the default timeout value). | 108 | * be the default timeout value). Note that for the module parameter, '0' means |
109 | * 'use default' while it is an invalid value for the timeout-sec property. | ||
110 | * It should simply be dropped if you want to use the default value then. | ||
109 | * | 111 | * |
110 | * A zero is returned on success and -EINVAL for failure. | 112 | * A zero is returned on success or -EINVAL if all provided values are out of |
113 | * bounds. | ||
111 | */ | 114 | */ |
112 | int watchdog_init_timeout(struct watchdog_device *wdd, | 115 | int watchdog_init_timeout(struct watchdog_device *wdd, |
113 | unsigned int timeout_parm, struct device *dev) | 116 | unsigned int timeout_parm, struct device *dev) |
114 | { | 117 | { |
118 | const char *dev_str = wdd->parent ? dev_name(wdd->parent) : | ||
119 | (const char *)wdd->info->identity; | ||
115 | unsigned int t = 0; | 120 | unsigned int t = 0; |
116 | int ret = 0; | 121 | int ret = 0; |
117 | 122 | ||
118 | watchdog_check_min_max_timeout(wdd); | 123 | watchdog_check_min_max_timeout(wdd); |
119 | 124 | ||
120 | /* try to get the timeout module parameter first */ | 125 | /* check the driver supplied value (likely a module parameter) first */ |
121 | if (!watchdog_timeout_invalid(wdd, timeout_parm) && timeout_parm) { | 126 | if (timeout_parm) { |
122 | wdd->timeout = timeout_parm; | 127 | if (!watchdog_timeout_invalid(wdd, timeout_parm)) { |
123 | return ret; | 128 | wdd->timeout = timeout_parm; |
124 | } | 129 | return 0; |
125 | if (timeout_parm) | 130 | } |
131 | pr_err("%s: driver supplied timeout (%u) out of range\n", | ||
132 | dev_str, timeout_parm); | ||
126 | ret = -EINVAL; | 133 | ret = -EINVAL; |
134 | } | ||
127 | 135 | ||
128 | /* try to get the timeout_sec property */ | 136 | /* try to get the timeout_sec property */ |
129 | if (dev == NULL || dev->of_node == NULL) | 137 | if (dev && dev->of_node && |
130 | return ret; | 138 | of_property_read_u32(dev->of_node, "timeout-sec", &t) == 0) { |
131 | of_property_read_u32(dev->of_node, "timeout-sec", &t); | 139 | if (t && !watchdog_timeout_invalid(wdd, t)) { |
132 | if (!watchdog_timeout_invalid(wdd, t) && t) | 140 | wdd->timeout = t; |
133 | wdd->timeout = t; | 141 | return 0; |
134 | else | 142 | } |
143 | pr_err("%s: DT supplied timeout (%u) out of range\n", dev_str, t); | ||
135 | ret = -EINVAL; | 144 | ret = -EINVAL; |
145 | } | ||
146 | |||
147 | if (ret < 0 && wdd->timeout) | ||
148 | pr_warn("%s: falling back to default timeout (%u)\n", dev_str, | ||
149 | wdd->timeout); | ||
136 | 150 | ||
137 | return ret; | 151 | return ret; |
138 | } | 152 | } |
diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c index 56ad19608a9b..430ee4e9b185 100644 --- a/drivers/watchdog/wdat_wdt.c +++ b/drivers/watchdog/wdat_wdt.c | |||
@@ -287,7 +287,7 @@ static unsigned int wdat_wdt_get_timeleft(struct watchdog_device *wdd) | |||
287 | struct wdat_wdt *wdat = to_wdat_wdt(wdd); | 287 | struct wdat_wdt *wdat = to_wdat_wdt(wdd); |
288 | u32 periods = 0; | 288 | u32 periods = 0; |
289 | 289 | ||
290 | wdat_wdt_run_action(wdat, ACPI_WDAT_GET_COUNTDOWN, 0, &periods); | 290 | wdat_wdt_run_action(wdat, ACPI_WDAT_GET_CURRENT_COUNTDOWN, 0, &periods); |
291 | return periods * wdat->period / 1000; | 291 | return periods * wdat->period / 1000; |
292 | } | 292 | } |
293 | 293 | ||
@@ -308,6 +308,7 @@ static const struct watchdog_ops wdat_wdt_ops = { | |||
308 | 308 | ||
309 | static int wdat_wdt_probe(struct platform_device *pdev) | 309 | static int wdat_wdt_probe(struct platform_device *pdev) |
310 | { | 310 | { |
311 | struct device *dev = &pdev->dev; | ||
311 | const struct acpi_wdat_entry *entries; | 312 | const struct acpi_wdat_entry *entries; |
312 | const struct acpi_table_wdat *tbl; | 313 | const struct acpi_table_wdat *tbl; |
313 | struct wdat_wdt *wdat; | 314 | struct wdat_wdt *wdat; |
@@ -321,11 +322,11 @@ static int wdat_wdt_probe(struct platform_device *pdev) | |||
321 | if (ACPI_FAILURE(status)) | 322 | if (ACPI_FAILURE(status)) |
322 | return -ENODEV; | 323 | return -ENODEV; |
323 | 324 | ||
324 | wdat = devm_kzalloc(&pdev->dev, sizeof(*wdat), GFP_KERNEL); | 325 | wdat = devm_kzalloc(dev, sizeof(*wdat), GFP_KERNEL); |
325 | if (!wdat) | 326 | if (!wdat) |
326 | return -ENOMEM; | 327 | return -ENOMEM; |
327 | 328 | ||
328 | regs = devm_kcalloc(&pdev->dev, pdev->num_resources, sizeof(*regs), | 329 | regs = devm_kcalloc(dev, pdev->num_resources, sizeof(*regs), |
329 | GFP_KERNEL); | 330 | GFP_KERNEL); |
330 | if (!regs) | 331 | if (!regs) |
331 | return -ENOMEM; | 332 | return -ENOMEM; |
@@ -350,15 +351,15 @@ static int wdat_wdt_probe(struct platform_device *pdev) | |||
350 | 351 | ||
351 | res = &pdev->resource[i]; | 352 | res = &pdev->resource[i]; |
352 | if (resource_type(res) == IORESOURCE_MEM) { | 353 | if (resource_type(res) == IORESOURCE_MEM) { |
353 | reg = devm_ioremap_resource(&pdev->dev, res); | 354 | reg = devm_ioremap_resource(dev, res); |
354 | if (IS_ERR(reg)) | 355 | if (IS_ERR(reg)) |
355 | return PTR_ERR(reg); | 356 | return PTR_ERR(reg); |
356 | } else if (resource_type(res) == IORESOURCE_IO) { | 357 | } else if (resource_type(res) == IORESOURCE_IO) { |
357 | reg = devm_ioport_map(&pdev->dev, res->start, 1); | 358 | reg = devm_ioport_map(dev, res->start, 1); |
358 | if (!reg) | 359 | if (!reg) |
359 | return -ENOMEM; | 360 | return -ENOMEM; |
360 | } else { | 361 | } else { |
361 | dev_err(&pdev->dev, "Unsupported resource\n"); | 362 | dev_err(dev, "Unsupported resource\n"); |
362 | return -EINVAL; | 363 | return -EINVAL; |
363 | } | 364 | } |
364 | 365 | ||
@@ -376,12 +377,11 @@ static int wdat_wdt_probe(struct platform_device *pdev) | |||
376 | 377 | ||
377 | action = entries[i].action; | 378 | action = entries[i].action; |
378 | if (action >= MAX_WDAT_ACTIONS) { | 379 | if (action >= MAX_WDAT_ACTIONS) { |
379 | dev_dbg(&pdev->dev, "Skipping unknown action: %u\n", | 380 | dev_dbg(dev, "Skipping unknown action: %u\n", action); |
380 | action); | ||
381 | continue; | 381 | continue; |
382 | } | 382 | } |
383 | 383 | ||
384 | instr = devm_kzalloc(&pdev->dev, sizeof(*instr), GFP_KERNEL); | 384 | instr = devm_kzalloc(dev, sizeof(*instr), GFP_KERNEL); |
385 | if (!instr) | 385 | if (!instr) |
386 | return -ENOMEM; | 386 | return -ENOMEM; |
387 | 387 | ||
@@ -398,7 +398,7 @@ static int wdat_wdt_probe(struct platform_device *pdev) | |||
398 | } else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { | 398 | } else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { |
399 | r.flags = IORESOURCE_IO; | 399 | r.flags = IORESOURCE_IO; |
400 | } else { | 400 | } else { |
401 | dev_dbg(&pdev->dev, "Unsupported address space: %d\n", | 401 | dev_dbg(dev, "Unsupported address space: %d\n", |
402 | gas->space_id); | 402 | gas->space_id); |
403 | continue; | 403 | continue; |
404 | } | 404 | } |
@@ -413,14 +413,15 @@ static int wdat_wdt_probe(struct platform_device *pdev) | |||
413 | } | 413 | } |
414 | 414 | ||
415 | if (!instr->reg) { | 415 | if (!instr->reg) { |
416 | dev_err(&pdev->dev, "I/O resource not found\n"); | 416 | dev_err(dev, "I/O resource not found\n"); |
417 | return -EINVAL; | 417 | return -EINVAL; |
418 | } | 418 | } |
419 | 419 | ||
420 | instructions = wdat->instructions[action]; | 420 | instructions = wdat->instructions[action]; |
421 | if (!instructions) { | 421 | if (!instructions) { |
422 | instructions = devm_kzalloc(&pdev->dev, | 422 | instructions = devm_kzalloc(dev, |
423 | sizeof(*instructions), GFP_KERNEL); | 423 | sizeof(*instructions), |
424 | GFP_KERNEL); | ||
424 | if (!instructions) | 425 | if (!instructions) |
425 | return -ENOMEM; | 426 | return -ENOMEM; |
426 | 427 | ||
@@ -441,7 +442,7 @@ static int wdat_wdt_probe(struct platform_device *pdev) | |||
441 | platform_set_drvdata(pdev, wdat); | 442 | platform_set_drvdata(pdev, wdat); |
442 | 443 | ||
443 | watchdog_set_nowayout(&wdat->wdd, nowayout); | 444 | watchdog_set_nowayout(&wdat->wdd, nowayout); |
444 | return devm_watchdog_register_device(&pdev->dev, &wdat->wdd); | 445 | return devm_watchdog_register_device(dev, &wdat->wdd); |
445 | } | 446 | } |
446 | 447 | ||
447 | #ifdef CONFIG_PM_SLEEP | 448 | #ifdef CONFIG_PM_SLEEP |
diff --git a/drivers/watchdog/wm831x_wdt.c b/drivers/watchdog/wm831x_wdt.c index 116c2f47b463..9b6565a3fab4 100644 --- a/drivers/watchdog/wm831x_wdt.c +++ b/drivers/watchdog/wm831x_wdt.c | |||
@@ -180,8 +180,9 @@ static const struct watchdog_ops wm831x_wdt_ops = { | |||
180 | 180 | ||
181 | static int wm831x_wdt_probe(struct platform_device *pdev) | 181 | static int wm831x_wdt_probe(struct platform_device *pdev) |
182 | { | 182 | { |
183 | struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); | 183 | struct device *dev = &pdev->dev; |
184 | struct wm831x_pdata *chip_pdata = dev_get_platdata(pdev->dev.parent); | 184 | struct wm831x *wm831x = dev_get_drvdata(dev->parent); |
185 | struct wm831x_pdata *chip_pdata = dev_get_platdata(dev->parent); | ||
185 | struct wm831x_watchdog_pdata *pdata; | 186 | struct wm831x_watchdog_pdata *pdata; |
186 | struct wm831x_wdt_drvdata *driver_data; | 187 | struct wm831x_wdt_drvdata *driver_data; |
187 | struct watchdog_device *wm831x_wdt; | 188 | struct watchdog_device *wm831x_wdt; |
@@ -198,8 +199,7 @@ static int wm831x_wdt_probe(struct platform_device *pdev) | |||
198 | if (reg & WM831X_WDOG_DEBUG) | 199 | if (reg & WM831X_WDOG_DEBUG) |
199 | dev_warn(wm831x->dev, "Watchdog is paused\n"); | 200 | dev_warn(wm831x->dev, "Watchdog is paused\n"); |
200 | 201 | ||
201 | driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data), | 202 | driver_data = devm_kzalloc(dev, sizeof(*driver_data), GFP_KERNEL); |
202 | GFP_KERNEL); | ||
203 | if (!driver_data) | 203 | if (!driver_data) |
204 | return -ENOMEM; | 204 | return -ENOMEM; |
205 | 205 | ||
@@ -210,7 +210,7 @@ static int wm831x_wdt_probe(struct platform_device *pdev) | |||
210 | 210 | ||
211 | wm831x_wdt->info = &wm831x_wdt_info; | 211 | wm831x_wdt->info = &wm831x_wdt_info; |
212 | wm831x_wdt->ops = &wm831x_wdt_ops; | 212 | wm831x_wdt->ops = &wm831x_wdt_ops; |
213 | wm831x_wdt->parent = &pdev->dev; | 213 | wm831x_wdt->parent = dev; |
214 | watchdog_set_nowayout(wm831x_wdt, nowayout); | 214 | watchdog_set_nowayout(wm831x_wdt, nowayout); |
215 | watchdog_set_drvdata(wm831x_wdt, driver_data); | 215 | watchdog_set_drvdata(wm831x_wdt, driver_data); |
216 | 216 | ||
@@ -240,10 +240,9 @@ static int wm831x_wdt_probe(struct platform_device *pdev) | |||
240 | reg |= pdata->software << WM831X_WDOG_RST_SRC_SHIFT; | 240 | reg |= pdata->software << WM831X_WDOG_RST_SRC_SHIFT; |
241 | 241 | ||
242 | if (pdata->update_gpio) { | 242 | if (pdata->update_gpio) { |
243 | ret = devm_gpio_request_one(&pdev->dev, | 243 | ret = devm_gpio_request_one(dev, pdata->update_gpio, |
244 | pdata->update_gpio, | 244 | GPIOF_OUT_INIT_LOW, |
245 | GPIOF_OUT_INIT_LOW, | 245 | "Watchdog update"); |
246 | "Watchdog update"); | ||
247 | if (ret < 0) { | 246 | if (ret < 0) { |
248 | dev_err(wm831x->dev, | 247 | dev_err(wm831x->dev, |
249 | "Failed to request update GPIO: %d\n", | 248 | "Failed to request update GPIO: %d\n", |
@@ -268,7 +267,7 @@ static int wm831x_wdt_probe(struct platform_device *pdev) | |||
268 | } | 267 | } |
269 | } | 268 | } |
270 | 269 | ||
271 | ret = devm_watchdog_register_device(&pdev->dev, &driver_data->wdt); | 270 | ret = devm_watchdog_register_device(dev, &driver_data->wdt); |
272 | if (ret != 0) { | 271 | if (ret != 0) { |
273 | dev_err(wm831x->dev, "watchdog_register_device() failed: %d\n", | 272 | dev_err(wm831x->dev, "watchdog_register_device() failed: %d\n", |
274 | ret); | 273 | ret); |
diff --git a/drivers/watchdog/xen_wdt.c b/drivers/watchdog/xen_wdt.c index f1c016d015b3..25a1af5e1787 100644 --- a/drivers/watchdog/xen_wdt.c +++ b/drivers/watchdog/xen_wdt.c | |||
@@ -122,35 +122,33 @@ static struct watchdog_device xen_wdt_dev = { | |||
122 | 122 | ||
123 | static int xen_wdt_probe(struct platform_device *pdev) | 123 | static int xen_wdt_probe(struct platform_device *pdev) |
124 | { | 124 | { |
125 | struct device *dev = &pdev->dev; | ||
125 | struct sched_watchdog wd = { .id = ~0 }; | 126 | struct sched_watchdog wd = { .id = ~0 }; |
126 | int ret = HYPERVISOR_sched_op(SCHEDOP_watchdog, &wd); | 127 | int ret = HYPERVISOR_sched_op(SCHEDOP_watchdog, &wd); |
127 | 128 | ||
128 | if (ret == -ENOSYS) { | 129 | if (ret == -ENOSYS) { |
129 | dev_err(&pdev->dev, "watchdog not supported by hypervisor\n"); | 130 | dev_err(dev, "watchdog not supported by hypervisor\n"); |
130 | return -ENODEV; | 131 | return -ENODEV; |
131 | } | 132 | } |
132 | 133 | ||
133 | if (ret != -EINVAL) { | 134 | if (ret != -EINVAL) { |
134 | dev_err(&pdev->dev, "unexpected hypervisor error (%d)\n", ret); | 135 | dev_err(dev, "unexpected hypervisor error (%d)\n", ret); |
135 | return -ENODEV; | 136 | return -ENODEV; |
136 | } | 137 | } |
137 | 138 | ||
138 | if (watchdog_init_timeout(&xen_wdt_dev, timeout, NULL)) | 139 | watchdog_init_timeout(&xen_wdt_dev, timeout, NULL); |
139 | dev_info(&pdev->dev, "timeout value invalid, using %d\n", | ||
140 | xen_wdt_dev.timeout); | ||
141 | watchdog_set_nowayout(&xen_wdt_dev, nowayout); | 140 | watchdog_set_nowayout(&xen_wdt_dev, nowayout); |
142 | watchdog_stop_on_reboot(&xen_wdt_dev); | 141 | watchdog_stop_on_reboot(&xen_wdt_dev); |
143 | watchdog_stop_on_unregister(&xen_wdt_dev); | 142 | watchdog_stop_on_unregister(&xen_wdt_dev); |
144 | 143 | ||
145 | ret = devm_watchdog_register_device(&pdev->dev, &xen_wdt_dev); | 144 | ret = devm_watchdog_register_device(dev, &xen_wdt_dev); |
146 | if (ret) { | 145 | if (ret) { |
147 | dev_err(&pdev->dev, "cannot register watchdog device (%d)\n", | 146 | dev_err(dev, "cannot register watchdog device (%d)\n", ret); |
148 | ret); | ||
149 | return ret; | 147 | return ret; |
150 | } | 148 | } |
151 | 149 | ||
152 | dev_info(&pdev->dev, "initialized (timeout=%ds, nowayout=%d)\n", | 150 | dev_info(dev, "initialized (timeout=%ds, nowayout=%d)\n", |
153 | xen_wdt_dev.timeout, nowayout); | 151 | xen_wdt_dev.timeout, nowayout); |
154 | 152 | ||
155 | return 0; | 153 | return 0; |
156 | } | 154 | } |
diff --git a/drivers/watchdog/ziirave_wdt.c b/drivers/watchdog/ziirave_wdt.c index d3594aa3a374..43e6b575c32c 100644 --- a/drivers/watchdog/ziirave_wdt.c +++ b/drivers/watchdog/ziirave_wdt.c | |||
@@ -658,11 +658,7 @@ static int ziirave_wdt_probe(struct i2c_client *client, | |||
658 | w_priv->wdd.parent = &client->dev; | 658 | w_priv->wdd.parent = &client->dev; |
659 | w_priv->wdd.groups = ziirave_wdt_groups; | 659 | w_priv->wdd.groups = ziirave_wdt_groups; |
660 | 660 | ||
661 | ret = watchdog_init_timeout(&w_priv->wdd, wdt_timeout, &client->dev); | 661 | watchdog_init_timeout(&w_priv->wdd, wdt_timeout, &client->dev); |
662 | if (ret) { | ||
663 | dev_info(&client->dev, | ||
664 | "Unable to select timeout value, using default\n"); | ||
665 | } | ||
666 | 662 | ||
667 | /* | 663 | /* |
668 | * The default value set in the watchdog should be perfectly valid, so | 664 | * The default value set in the watchdog should be perfectly valid, so |
diff --git a/drivers/watchdog/zx2967_wdt.c b/drivers/watchdog/zx2967_wdt.c index 9261f7c77f6d..c8549bf07cc9 100644 --- a/drivers/watchdog/zx2967_wdt.c +++ b/drivers/watchdog/zx2967_wdt.c | |||
@@ -188,11 +188,15 @@ static void zx2967_wdt_reset_sysctrl(struct device *dev) | |||
188 | of_node_put(out_args.np); | 188 | of_node_put(out_args.np); |
189 | } | 189 | } |
190 | 190 | ||
191 | static void zx2967_clk_disable_unprepare(void *data) | ||
192 | { | ||
193 | clk_disable_unprepare(data); | ||
194 | } | ||
195 | |||
191 | static int zx2967_wdt_probe(struct platform_device *pdev) | 196 | static int zx2967_wdt_probe(struct platform_device *pdev) |
192 | { | 197 | { |
193 | struct device *dev = &pdev->dev; | 198 | struct device *dev = &pdev->dev; |
194 | struct zx2967_wdt *wdt; | 199 | struct zx2967_wdt *wdt; |
195 | struct resource *base; | ||
196 | int ret; | 200 | int ret; |
197 | struct reset_control *rstc; | 201 | struct reset_control *rstc; |
198 | 202 | ||
@@ -207,10 +211,9 @@ static int zx2967_wdt_probe(struct platform_device *pdev) | |||
207 | wdt->wdt_device.timeout = ZX2967_WDT_DEFAULT_TIMEOUT; | 211 | wdt->wdt_device.timeout = ZX2967_WDT_DEFAULT_TIMEOUT; |
208 | wdt->wdt_device.max_timeout = ZX2967_WDT_MAX_TIMEOUT; | 212 | wdt->wdt_device.max_timeout = ZX2967_WDT_MAX_TIMEOUT; |
209 | wdt->wdt_device.min_timeout = ZX2967_WDT_MIN_TIMEOUT; | 213 | wdt->wdt_device.min_timeout = ZX2967_WDT_MIN_TIMEOUT; |
210 | wdt->wdt_device.parent = &pdev->dev; | 214 | wdt->wdt_device.parent = dev; |
211 | 215 | ||
212 | base = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 216 | wdt->reg_base = devm_platform_ioremap_resource(pdev, 0); |
213 | wdt->reg_base = devm_ioremap_resource(dev, base); | ||
214 | if (IS_ERR(wdt->reg_base)) | 217 | if (IS_ERR(wdt->reg_base)) |
215 | return PTR_ERR(wdt->reg_base); | 218 | return PTR_ERR(wdt->reg_base); |
216 | 219 | ||
@@ -227,13 +230,16 @@ static int zx2967_wdt_probe(struct platform_device *pdev) | |||
227 | dev_err(dev, "failed to enable clock\n"); | 230 | dev_err(dev, "failed to enable clock\n"); |
228 | return ret; | 231 | return ret; |
229 | } | 232 | } |
233 | ret = devm_add_action_or_reset(dev, zx2967_clk_disable_unprepare, | ||
234 | wdt->clock); | ||
235 | if (ret) | ||
236 | return ret; | ||
230 | clk_set_rate(wdt->clock, ZX2967_WDT_CLK_FREQ); | 237 | clk_set_rate(wdt->clock, ZX2967_WDT_CLK_FREQ); |
231 | 238 | ||
232 | rstc = devm_reset_control_get_exclusive(dev, NULL); | 239 | rstc = devm_reset_control_get_exclusive(dev, NULL); |
233 | if (IS_ERR(rstc)) { | 240 | if (IS_ERR(rstc)) { |
234 | dev_err(dev, "failed to get rstc"); | 241 | dev_err(dev, "failed to get rstc"); |
235 | ret = PTR_ERR(rstc); | 242 | return PTR_ERR(rstc); |
236 | goto err; | ||
237 | } | 243 | } |
238 | 244 | ||
239 | reset_control_assert(rstc); | 245 | reset_control_assert(rstc); |
@@ -244,28 +250,14 @@ static int zx2967_wdt_probe(struct platform_device *pdev) | |||
244 | ZX2967_WDT_DEFAULT_TIMEOUT, dev); | 250 | ZX2967_WDT_DEFAULT_TIMEOUT, dev); |
245 | watchdog_set_nowayout(&wdt->wdt_device, WATCHDOG_NOWAYOUT); | 251 | watchdog_set_nowayout(&wdt->wdt_device, WATCHDOG_NOWAYOUT); |
246 | 252 | ||
247 | ret = watchdog_register_device(&wdt->wdt_device); | 253 | ret = devm_watchdog_register_device(dev, &wdt->wdt_device); |
248 | if (ret) | 254 | if (ret) |
249 | goto err; | 255 | return ret; |
250 | 256 | ||
251 | dev_info(dev, "watchdog enabled (timeout=%d sec, nowayout=%d)", | 257 | dev_info(dev, "watchdog enabled (timeout=%d sec, nowayout=%d)", |
252 | wdt->wdt_device.timeout, WATCHDOG_NOWAYOUT); | 258 | wdt->wdt_device.timeout, WATCHDOG_NOWAYOUT); |
253 | 259 | ||
254 | return 0; | 260 | return 0; |
255 | |||
256 | err: | ||
257 | clk_disable_unprepare(wdt->clock); | ||
258 | return ret; | ||
259 | } | ||
260 | |||
261 | static int zx2967_wdt_remove(struct platform_device *pdev) | ||
262 | { | ||
263 | struct zx2967_wdt *wdt = platform_get_drvdata(pdev); | ||
264 | |||
265 | watchdog_unregister_device(&wdt->wdt_device); | ||
266 | clk_disable_unprepare(wdt->clock); | ||
267 | |||
268 | return 0; | ||
269 | } | 261 | } |
270 | 262 | ||
271 | static const struct of_device_id zx2967_wdt_match[] = { | 263 | static const struct of_device_id zx2967_wdt_match[] = { |
@@ -276,7 +268,6 @@ MODULE_DEVICE_TABLE(of, zx2967_wdt_match); | |||
276 | 268 | ||
277 | static struct platform_driver zx2967_wdt_driver = { | 269 | static struct platform_driver zx2967_wdt_driver = { |
278 | .probe = zx2967_wdt_probe, | 270 | .probe = zx2967_wdt_probe, |
279 | .remove = zx2967_wdt_remove, | ||
280 | .driver = { | 271 | .driver = { |
281 | .name = "zx2967-wdt", | 272 | .name = "zx2967-wdt", |
282 | .of_match_table = of_match_ptr(zx2967_wdt_match), | 273 | .of_match_table = of_match_ptr(zx2967_wdt_match), |