Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://www.linux-watchdog.org/linux-watchdog

Pull watchdog updates from Wim Van Sebroeck:
- lots of devm_ conversions and cleanup
- platform_set_drvdata cleanups
- s3c2410: dev_err/dev_info + dev_pm_ops
- watchdog_core: don't try to stop device if not running fix
- wdrtas: use print_hex_dump
- xilinx cleanups
- orion_wdt fixes
- softdog cleanup
- hpwdt: check on UEFI bits
- deletion of mpcore_wdt driver
- addition of broadcom BCM2835 watchdog timer driver
- addition of MEN A21 watcdog devices

* git://www.linux-watchdog.org/linux-watchdog: (38 commits)
watchdog: hpwdt: Add check for UEFI bits
watchdog: softdog: remove replaceable ping operation
watchdog: New watchdog driver for MEN A21 watchdogs
Watchdog: fix clearing of the watchdog interrupt
Watchdog: allow orion_wdt to be built for Dove
watchdog: Add Broadcom BCM2835 watchdog timer driver
watchdog: delete mpcore_wdt driver
watchdog: xilinx: Setup the origin compatible string
watchdog: xilinx: Fix driver header
watchdog: wdrtas: don't use custom version of print_hex_dump
watchdog: core: don't try to stop device if not running
watchdog: jz4740: Pass device to clk_get
watchdog: twl4030: Remove redundant platform_set_drvdata()
watchdog: mpcore: Remove redundant platform_set_drvdata()
watchdog: da9055: use platform_{get,set}_drvdata()
watchdog: da9052: use platform_{get,set}_drvdata()
watchdog: cpwd: use platform_{get,set}_drvdata()
watchdog: s3c2410_wdt: convert s3c2410wdt to dev_pm_ops
watchdog: s3c2410_wdt: use dev_err()/dev_info() instead of pr_err()/pr_info()
watchdog: wm831x: use platform_{get,set}_drvdata()
...

+629 -740
+25
Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
··· 1 + Bindings for MEN A21 Watchdog device connected to GPIO lines 2 + 3 + Required properties: 4 + - compatible: "men,a021-wdt" 5 + - gpios: Specifies the pins that control the Watchdog, order: 6 + 1: Watchdog enable 7 + 2: Watchdog fast-mode 8 + 3: Watchdog trigger 9 + 4: Watchdog reset cause bit 0 10 + 5: Watchdog reset cause bit 1 11 + 6: Watchdog reset cause bit 2 12 + 13 + Optional properties: 14 + - None 15 + 16 + Example: 17 + watchdog { 18 + compatible ="men,a021-wdt"; 19 + gpios = <&gpio3 9 1 /* WD_EN */ 20 + &gpio3 10 1 /* WD_FAST */ 21 + &gpio3 11 1 /* WD_TRIG */ 22 + &gpio3 6 1 /* RST_CAUSE[0] */ 23 + &gpio3 7 1 /* RST_CAUSE[1] */ 24 + &gpio3 8 1>; /* RST_CAUSE[2] */ 25 + };
+5
Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt
··· 5 5 - compatible : should be "brcm,bcm2835-pm-wdt" 6 6 - reg : Specifies base physical address and size of the registers. 7 7 8 + Optional properties: 9 + 10 + - timeout-sec : Contains the watchdog timeout in seconds 11 + 8 12 Example: 9 13 10 14 watchdog { 11 15 compatible = "brcm,bcm2835-pm-wdt"; 12 16 reg = <0x7e100000 0x28>; 17 + timeout-sec = <10>; 13 18 };
-8
Documentation/watchdog/watchdog-parameters.txt
··· 194 194 nowayout: Watchdog cannot be stopped once started 195 195 (default=kernel config parameter) 196 196 ------------------------------------------------- 197 - mpcore_wdt: 198 - mpcore_margin: MPcore timer margin in seconds. 199 - (0 < mpcore_margin < 65536, default=60) 200 - nowayout: Watchdog cannot be stopped once started 201 - (default=kernel config parameter) 202 - mpcore_noboot: MPcore watchdog action, set to 1 to ignore reboots, 203 - 0 to reboot (default=0 204 - ------------------------------------------------- 205 197 mv64x60_wdt: 206 198 nowayout: Watchdog cannot be stopped once started 207 199 (default=kernel config parameter)
+6
MAINTAINERS
··· 5387 5387 F: include/linux/mtd/ 5388 5388 F: include/uapi/mtd/ 5389 5389 5390 + MEN A21 WATCHDOG DRIVER 5391 + M: Johannes Thumshirn <johannes.thumshirn@men.de> 5392 + L: linux-watchdog@vger.kernel.org 5393 + S: Supported 5394 + F: drivers/watchdog/mena21_wdt.c 5395 + 5390 5396 METAG ARCHITECTURE 5391 5397 M: James Hogan <james.hogan@imgtec.com> 5392 5398 S: Supported
-1
arch/arm/configs/spear13xx_defconfig
··· 61 61 CONFIG_GPIO_PL061=y 62 62 # CONFIG_HWMON is not set 63 63 CONFIG_WATCHDOG=y 64 - CONFIG_MPCORE_WATCHDOG=y 65 64 # CONFIG_HID_SUPPORT is not set 66 65 CONFIG_USB=y 67 66 # CONFIG_USB_DEVICE_CLASS is not set
+1
arch/arm/mach-dove/include/mach/bridge-regs.h
··· 26 26 #define SYSTEM_SOFT_RESET (BRIDGE_VIRT_BASE + 0x010c) 27 27 #define SOFT_RESET 0x00000001 28 28 29 + #define BRIDGE_CAUSE (BRIDGE_VIRT_BASE + 0x0110) 29 30 #define BRIDGE_INT_TIMER1_CLR (~0x0004) 30 31 31 32 #define IRQ_VIRT_BASE (BRIDGE_VIRT_BASE + 0x0200)
-2
arch/arm/mach-kirkwood/include/mach/bridge-regs.h
··· 21 21 #define CPU_RESET 0x00000002 22 22 23 23 #define RSTOUTn_MASK (BRIDGE_VIRT_BASE + 0x0108) 24 - #define WDT_RESET_OUT_EN 0x00000002 25 24 #define SOFT_RESET_OUT_EN 0x00000004 26 25 27 26 #define SYSTEM_SOFT_RESET (BRIDGE_VIRT_BASE + 0x010c) 28 27 #define SOFT_RESET 0x00000001 29 28 30 29 #define BRIDGE_CAUSE (BRIDGE_VIRT_BASE + 0x0110) 31 - #define WDT_INT_REQ 0x0008 32 30 33 31 #define BRIDGE_INT_TIMER1_CLR (~0x0004) 34 32
-3
arch/arm/mach-orion5x/include/mach/bridge-regs.h
··· 18 18 #define CPU_CTRL (ORION5X_BRIDGE_VIRT_BASE + 0x104) 19 19 20 20 #define RSTOUTn_MASK (ORION5X_BRIDGE_VIRT_BASE + 0x108) 21 - #define WDT_RESET_OUT_EN 0x0002 22 21 23 22 #define CPU_SOFT_RESET (ORION5X_BRIDGE_VIRT_BASE + 0x10c) 24 23 25 24 #define BRIDGE_CAUSE (ORION5X_BRIDGE_VIRT_BASE + 0x110) 26 25 27 26 #define POWER_MNG_CTRL_REG (ORION5X_BRIDGE_VIRT_BASE + 0x11C) 28 - 29 - #define WDT_INT_REQ 0x0008 30 27 31 28 #define BRIDGE_INT_TIMER1_CLR (~0x0004) 32 29
+24 -10
drivers/watchdog/Kconfig
··· 221 221 To compile this driver as a module, choose M here: the 222 222 module will be called dw_wdt. 223 223 224 - config MPCORE_WATCHDOG 225 - tristate "MPcore watchdog" 226 - depends on HAVE_ARM_TWD 227 - help 228 - Watchdog timer embedded into the MPcore system. 229 - 230 - To compile this driver as a module, choose M here: the 231 - module will be called mpcore_wdt. 232 - 233 224 config EP93XX_WATCHDOG 234 225 tristate "EP93xx Watchdog" 235 226 depends on ARCH_EP93XX ··· 282 291 283 292 config ORION_WATCHDOG 284 293 tristate "Orion watchdog" 285 - depends on ARCH_ORION5X || ARCH_KIRKWOOD 294 + depends on ARCH_ORION5X || ARCH_KIRKWOOD || ARCH_DOVE 286 295 select WATCHDOG_CORE 287 296 help 288 297 Say Y here if to include support for the watchdog timer ··· 1100 1109 To compile this driver as a loadable module, choose M here. 1101 1110 The module will be called bcm63xx_wdt. 1102 1111 1112 + config BCM2835_WDT 1113 + tristate "Broadcom BCM2835 hardware watchdog" 1114 + depends on ARCH_BCM2835 1115 + select WATCHDOG_CORE 1116 + help 1117 + Watchdog driver for the built in watchdog hardware in Broadcom 1118 + BCM2835 SoC. 1119 + 1120 + To compile this driver as a loadable module, choose M here. 1121 + The module will be called bcm2835_wdt. 1122 + 1103 1123 config LANTIQ_WDT 1104 1124 tristate "Lantiq SoC watchdog" 1105 1125 depends on LANTIQ ··· 1184 1182 For other Book-E processors, this is a number between 0 and 3. 1185 1183 1186 1184 The value can be overridden by the wdt_period command-line parameter. 1185 + 1186 + config MEN_A21_WDT 1187 + tristate "MEN A21 VME CPU Carrier Board Watchdog Timer" 1188 + select WATCHDOG_CORE 1189 + depends on GPIOLIB 1190 + help 1191 + Watchdog driver for MEN A21 VMEbus CPU Carrier Boards. 1192 + 1193 + The driver can also be built as a module. If so, the module will be 1194 + called mena21_wdt. 1195 + 1196 + If unsure select N here. 1187 1197 1188 1198 # PPC64 Architecture 1189 1199
+2 -1
drivers/watchdog/Makefile
··· 41 41 obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o 42 42 obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o 43 43 obj-$(CONFIG_DW_WATCHDOG) += dw_wdt.o 44 - obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o 45 44 obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o 46 45 obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o 47 46 obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o ··· 53 54 obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o 54 55 obj-$(CONFIG_UX500_WATCHDOG) += ux500_wdt.o 55 56 obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o 57 + obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o 56 58 57 59 # AVR32 Architecture 58 60 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o ··· 144 144 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o 145 145 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o 146 146 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o 147 + obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o 147 148 148 149 # PPC64 Architecture 149 150 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
+5 -12
drivers/watchdog/at32ap700x_wdt.c
··· 321 321 return -ENXIO; 322 322 } 323 323 324 - wdt = kzalloc(sizeof(struct wdt_at32ap700x), GFP_KERNEL); 324 + wdt = devm_kzalloc(&pdev->dev, sizeof(struct wdt_at32ap700x), 325 + GFP_KERNEL); 325 326 if (!wdt) { 326 327 dev_dbg(&pdev->dev, "no memory for wdt structure\n"); 327 328 return -ENOMEM; 328 329 } 329 330 330 - wdt->regs = ioremap(regs->start, resource_size(regs)); 331 + wdt->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs)); 331 332 if (!wdt->regs) { 332 333 ret = -ENOMEM; 333 334 dev_dbg(&pdev->dev, "could not map I/O memory\n"); ··· 343 342 dev_info(&pdev->dev, "CPU must be reset with external " 344 343 "reset or POR due to silicon errata.\n"); 345 344 ret = -EIO; 346 - goto err_iounmap; 345 + goto err_free; 347 346 } else { 348 347 wdt->users = 0; 349 348 } ··· 365 364 ret = misc_register(&wdt->miscdev); 366 365 if (ret) { 367 366 dev_dbg(&pdev->dev, "failed to register wdt miscdev\n"); 368 - goto err_register; 367 + goto err_free; 369 368 } 370 369 371 370 dev_info(&pdev->dev, ··· 374 373 375 374 return 0; 376 375 377 - err_register: 378 - platform_set_drvdata(pdev, NULL); 379 - err_iounmap: 380 - iounmap(wdt->regs); 381 376 err_free: 382 - kfree(wdt); 383 377 wdt = NULL; 384 378 return ret; 385 379 } ··· 387 391 at32_wdt_stop(); 388 392 389 393 misc_deregister(&wdt->miscdev); 390 - iounmap(wdt->regs); 391 - kfree(wdt); 392 394 wdt = NULL; 393 - platform_set_drvdata(pdev, NULL); 394 395 } 395 396 return 0; 396 397 }
+189
drivers/watchdog/bcm2835_wdt.c
··· 1 + /* 2 + * Watchdog driver for Broadcom BCM2835 3 + * 4 + * "bcm2708_wdog" driver written by Luke Diamand that was obtained from 5 + * branch "rpi-3.6.y" of git://github.com/raspberrypi/linux.git was used 6 + * as a hardware reference for the Broadcom BCM2835 watchdog timer. 7 + * 8 + * Copyright (C) 2013 Lubomir Rintel <lkundrak@v3.sk> 9 + * 10 + * This program is free software; you can redistribute it and/or modify it 11 + * under the terms of the GNU General Public License as published by the 12 + * Free Software Foundation; either version 2 of the License, or (at your 13 + * option) any later version. 14 + */ 15 + 16 + #include <linux/types.h> 17 + #include <linux/module.h> 18 + #include <linux/io.h> 19 + #include <linux/watchdog.h> 20 + #include <linux/platform_device.h> 21 + #include <linux/of_address.h> 22 + #include <linux/miscdevice.h> 23 + 24 + #define PM_RSTC 0x1c 25 + #define PM_WDOG 0x24 26 + 27 + #define PM_PASSWORD 0x5a000000 28 + 29 + #define PM_WDOG_TIME_SET 0x000fffff 30 + #define PM_RSTC_WRCFG_CLR 0xffffffcf 31 + #define PM_RSTC_WRCFG_SET 0x00000030 32 + #define PM_RSTC_WRCFG_FULL_RESET 0x00000020 33 + #define PM_RSTC_RESET 0x00000102 34 + 35 + #define SECS_TO_WDOG_TICKS(x) ((x) << 16) 36 + #define WDOG_TICKS_TO_SECS(x) ((x) >> 16) 37 + 38 + struct bcm2835_wdt { 39 + void __iomem *base; 40 + spinlock_t lock; 41 + }; 42 + 43 + static unsigned int heartbeat; 44 + static bool nowayout = WATCHDOG_NOWAYOUT; 45 + 46 + static int bcm2835_wdt_start(struct watchdog_device *wdog) 47 + { 48 + struct bcm2835_wdt *wdt = watchdog_get_drvdata(wdog); 49 + uint32_t cur; 50 + unsigned long flags; 51 + 52 + spin_lock_irqsave(&wdt->lock, flags); 53 + 54 + writel_relaxed(PM_PASSWORD | (SECS_TO_WDOG_TICKS(wdog->timeout) & 55 + PM_WDOG_TIME_SET), wdt->base + PM_WDOG); 56 + cur = readl_relaxed(wdt->base + PM_RSTC); 57 + writel_relaxed(PM_PASSWORD | (cur & PM_RSTC_WRCFG_CLR) | 58 + PM_RSTC_WRCFG_FULL_RESET, wdt->base + PM_RSTC); 59 + 60 + spin_unlock_irqrestore(&wdt->lock, flags); 61 + 62 + return 0; 63 + } 64 + 65 + static int bcm2835_wdt_stop(struct watchdog_device *wdog) 66 + { 67 + struct bcm2835_wdt *wdt = watchdog_get_drvdata(wdog); 68 + 69 + writel_relaxed(PM_PASSWORD | PM_RSTC_RESET, wdt->base + PM_RSTC); 70 + dev_info(wdog->dev, "Watchdog timer stopped"); 71 + return 0; 72 + } 73 + 74 + static int bcm2835_wdt_set_timeout(struct watchdog_device *wdog, unsigned int t) 75 + { 76 + wdog->timeout = t; 77 + return 0; 78 + } 79 + 80 + static unsigned int bcm2835_wdt_get_timeleft(struct watchdog_device *wdog) 81 + { 82 + struct bcm2835_wdt *wdt = watchdog_get_drvdata(wdog); 83 + 84 + uint32_t ret = readl_relaxed(wdt->base + PM_WDOG); 85 + return WDOG_TICKS_TO_SECS(ret & PM_WDOG_TIME_SET); 86 + } 87 + 88 + static struct watchdog_ops bcm2835_wdt_ops = { 89 + .owner = THIS_MODULE, 90 + .start = bcm2835_wdt_start, 91 + .stop = bcm2835_wdt_stop, 92 + .set_timeout = bcm2835_wdt_set_timeout, 93 + .get_timeleft = bcm2835_wdt_get_timeleft, 94 + }; 95 + 96 + static struct watchdog_info bcm2835_wdt_info = { 97 + .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | 98 + WDIOF_KEEPALIVEPING, 99 + .identity = "Broadcom BCM2835 Watchdog timer", 100 + }; 101 + 102 + static struct watchdog_device bcm2835_wdt_wdd = { 103 + .info = &bcm2835_wdt_info, 104 + .ops = &bcm2835_wdt_ops, 105 + .min_timeout = 1, 106 + .max_timeout = WDOG_TICKS_TO_SECS(PM_WDOG_TIME_SET), 107 + .timeout = WDOG_TICKS_TO_SECS(PM_WDOG_TIME_SET), 108 + }; 109 + 110 + static int bcm2835_wdt_probe(struct platform_device *pdev) 111 + { 112 + struct device *dev = &pdev->dev; 113 + struct device_node *np = dev->of_node; 114 + struct bcm2835_wdt *wdt; 115 + int err; 116 + 117 + wdt = devm_kzalloc(dev, sizeof(struct bcm2835_wdt), GFP_KERNEL); 118 + if (!wdt) { 119 + dev_err(dev, "Failed to allocate memory for watchdog device"); 120 + return -ENOMEM; 121 + } 122 + platform_set_drvdata(pdev, wdt); 123 + 124 + spin_lock_init(&wdt->lock); 125 + 126 + wdt->base = of_iomap(np, 0); 127 + if (!wdt->base) { 128 + dev_err(dev, "Failed to remap watchdog regs"); 129 + return -ENODEV; 130 + } 131 + 132 + watchdog_set_drvdata(&bcm2835_wdt_wdd, wdt); 133 + watchdog_init_timeout(&bcm2835_wdt_wdd, heartbeat, dev); 134 + watchdog_set_nowayout(&bcm2835_wdt_wdd, nowayout); 135 + err = watchdog_register_device(&bcm2835_wdt_wdd); 136 + if (err) { 137 + dev_err(dev, "Failed to register watchdog device"); 138 + iounmap(wdt->base); 139 + return err; 140 + } 141 + 142 + dev_info(dev, "Broadcom BCM2835 watchdog timer"); 143 + return 0; 144 + } 145 + 146 + static int bcm2835_wdt_remove(struct platform_device *pdev) 147 + { 148 + struct bcm2835_wdt *wdt = platform_get_drvdata(pdev); 149 + 150 + watchdog_unregister_device(&bcm2835_wdt_wdd); 151 + iounmap(wdt->base); 152 + 153 + return 0; 154 + } 155 + 156 + static void bcm2835_wdt_shutdown(struct platform_device *pdev) 157 + { 158 + bcm2835_wdt_stop(&bcm2835_wdt_wdd); 159 + } 160 + 161 + static const struct of_device_id bcm2835_wdt_of_match[] = { 162 + { .compatible = "brcm,bcm2835-pm-wdt", }, 163 + {}, 164 + }; 165 + MODULE_DEVICE_TABLE(of, bcm2835_wdt_of_match); 166 + 167 + static struct platform_driver bcm2835_wdt_driver = { 168 + .probe = bcm2835_wdt_probe, 169 + .remove = bcm2835_wdt_remove, 170 + .shutdown = bcm2835_wdt_shutdown, 171 + .driver = { 172 + .name = "bcm2835-wdt", 173 + .owner = THIS_MODULE, 174 + .of_match_table = bcm2835_wdt_of_match, 175 + }, 176 + }; 177 + module_platform_driver(bcm2835_wdt_driver); 178 + 179 + module_param(heartbeat, uint, 0); 180 + MODULE_PARM_DESC(heartbeat, "Initial watchdog heartbeat in seconds"); 181 + 182 + module_param(nowayout, bool, 0); 183 + MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 184 + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 185 + 186 + MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>"); 187 + MODULE_DESCRIPTION("Driver for Broadcom BCM2835 watchdog timer"); 188 + MODULE_LICENSE("GPL"); 189 + MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
+4 -5
drivers/watchdog/bcm63xx_wdt.c
··· 16 16 #include <linux/errno.h> 17 17 #include <linux/fs.h> 18 18 #include <linux/init.h> 19 + #include <linux/io.h> 19 20 #include <linux/kernel.h> 20 21 #include <linux/miscdevice.h> 21 22 #include <linux/module.h> ··· 250 249 return -ENODEV; 251 250 } 252 251 253 - bcm63xx_wdt_device.regs = ioremap_nocache(r->start, resource_size(r)); 252 + bcm63xx_wdt_device.regs = devm_ioremap_nocache(&pdev->dev, r->start, 253 + resource_size(r)); 254 254 if (!bcm63xx_wdt_device.regs) { 255 255 dev_err(&pdev->dev, "failed to remap I/O resources\n"); 256 256 return -ENXIO; ··· 260 258 ret = bcm63xx_timer_register(TIMER_WDT_ID, bcm63xx_wdt_isr, NULL); 261 259 if (ret < 0) { 262 260 dev_err(&pdev->dev, "failed to register wdt timer isr\n"); 263 - goto unmap; 261 + return ret; 264 262 } 265 263 266 264 if (bcm63xx_wdt_settimeout(wdt_time)) { ··· 283 281 284 282 unregister_timer: 285 283 bcm63xx_timer_unregister(TIMER_WDT_ID); 286 - unmap: 287 - iounmap(bcm63xx_wdt_device.regs); 288 284 return ret; 289 285 } 290 286 ··· 293 293 294 294 misc_deregister(&bcm63xx_wdt_miscdev); 295 295 bcm63xx_timer_unregister(TIMER_WDT_ID); 296 - iounmap(bcm63xx_wdt_device.regs); 297 296 return 0; 298 297 } 299 298
+2 -2
drivers/watchdog/cpwd.c
··· 621 621 WD_BADMODEL); 622 622 } 623 623 624 - dev_set_drvdata(&op->dev, p); 624 + platform_set_drvdata(op, p); 625 625 cpwd_device = p; 626 626 err = 0; 627 627 ··· 642 642 643 643 static int cpwd_remove(struct platform_device *op) 644 644 { 645 - struct cpwd *p = dev_get_drvdata(&op->dev); 645 + struct cpwd *p = platform_get_drvdata(op); 646 646 int i; 647 647 648 648 for (i = 0; i < WD_NUMDEVS; i++) {
+2 -2
drivers/watchdog/da9052_wdt.c
··· 215 215 goto err; 216 216 } 217 217 218 - dev_set_drvdata(&pdev->dev, driver_data); 218 + platform_set_drvdata(pdev, driver_data); 219 219 err: 220 220 return ret; 221 221 } 222 222 223 223 static int da9052_wdt_remove(struct platform_device *pdev) 224 224 { 225 - struct da9052_wdt_data *driver_data = dev_get_drvdata(&pdev->dev); 225 + struct da9052_wdt_data *driver_data = platform_get_drvdata(pdev); 226 226 227 227 watchdog_unregister_device(&driver_data->wdt); 228 228 kref_put(&driver_data->kref, da9052_wdt_release_resources);
+2 -2
drivers/watchdog/da9055_wdt.c
··· 174 174 goto err; 175 175 } 176 176 177 - dev_set_drvdata(&pdev->dev, driver_data); 177 + platform_set_drvdata(pdev, driver_data); 178 178 179 179 ret = watchdog_register_device(&driver_data->wdt); 180 180 if (ret != 0) ··· 187 187 188 188 static int da9055_wdt_remove(struct platform_device *pdev) 189 189 { 190 - struct da9055_wdt_data *driver_data = dev_get_drvdata(&pdev->dev); 190 + struct da9055_wdt_data *driver_data = platform_get_drvdata(pdev); 191 191 192 192 watchdog_unregister_device(&driver_data->wdt); 193 193 kref_put(&driver_data->kref, da9055_wdt_release_resources);
+4 -7
drivers/watchdog/dw_wdt.c
··· 154 154 return nonseekable_open(inode, filp); 155 155 } 156 156 157 - ssize_t dw_wdt_write(struct file *filp, const char __user *buf, size_t len, 158 - loff_t *offset) 157 + static ssize_t dw_wdt_write(struct file *filp, const char __user *buf, 158 + size_t len, loff_t *offset) 159 159 { 160 160 if (!len) 161 161 return 0; ··· 305 305 if (IS_ERR(dw_wdt.regs)) 306 306 return PTR_ERR(dw_wdt.regs); 307 307 308 - dw_wdt.clk = clk_get(&pdev->dev, NULL); 308 + dw_wdt.clk = devm_clk_get(&pdev->dev, NULL); 309 309 if (IS_ERR(dw_wdt.clk)) 310 310 return PTR_ERR(dw_wdt.clk); 311 311 312 312 ret = clk_enable(dw_wdt.clk); 313 313 if (ret) 314 - goto out_put_clk; 314 + return ret; 315 315 316 316 spin_lock_init(&dw_wdt.lock); 317 317 ··· 327 327 328 328 out_disable_clk: 329 329 clk_disable(dw_wdt.clk); 330 - out_put_clk: 331 - clk_put(dw_wdt.clk); 332 330 333 331 return ret; 334 332 } ··· 336 338 misc_deregister(&dw_wdt_miscdev); 337 339 338 340 clk_disable(dw_wdt.clk); 339 - clk_put(dw_wdt.clk); 340 341 341 342 return 0; 342 343 }
+7 -4
drivers/watchdog/hpwdt.c
··· 39 39 #endif /* CONFIG_HPWDT_NMI_DECODING */ 40 40 #include <asm/nmi.h> 41 41 42 - #define HPWDT_VERSION "1.3.1" 42 + #define HPWDT_VERSION "1.3.2" 43 43 #define SECS_TO_TICKS(secs) ((secs) * 1000 / 128) 44 44 #define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000) 45 45 #define HPWDT_MAX_TIMER TICKS_TO_SECS(65535) ··· 148 148 static unsigned int hpwdt_nmi_decoding; 149 149 static unsigned int allow_kdump = 1; 150 150 static unsigned int is_icru; 151 + static unsigned int is_uefi; 151 152 static DEFINE_SPINLOCK(rom_lock); 152 153 static void *cru_rom_addr; 153 154 static struct cmn_registers cmn_regs; ··· 485 484 goto out; 486 485 487 486 spin_lock_irqsave(&rom_lock, rom_pl); 488 - if (!die_nmi_called && !is_icru) 487 + if (!die_nmi_called && !is_icru && !is_uefi) 489 488 asminline_call(&cmn_regs, cru_rom_addr); 490 489 die_nmi_called = 1; 491 490 spin_unlock_irqrestore(&rom_lock, rom_pl); ··· 493 492 if (allow_kdump) 494 493 hpwdt_stop(); 495 494 496 - if (!is_icru) { 495 + if (!is_icru && !is_uefi) { 497 496 if (cmn_regs.u1.ral == 0) { 498 497 panic("An NMI occurred, " 499 498 "but unable to determine source.\n"); ··· 680 679 smbios_proliant_ptr = (struct smbios_proliant_info *) dm; 681 680 if (smbios_proliant_ptr->misc_features & 0x01) 682 681 is_icru = 1; 682 + if (smbios_proliant_ptr->misc_features & 0x408) 683 + is_uefi = 1; 683 684 } 684 685 } 685 686 ··· 700 697 * the old cru detect code. 701 698 */ 702 699 dmi_walk(dmi_find_icru, NULL); 703 - if (!is_icru) { 700 + if (!is_icru && !is_uefi) { 704 701 705 702 /* 706 703 * We need to map the ROM to get the CRU service.
+2 -4
drivers/watchdog/imx2_wdt.c
··· 261 261 if (IS_ERR(imx2_wdt.base)) 262 262 return PTR_ERR(imx2_wdt.base); 263 263 264 - imx2_wdt.clk = clk_get(&pdev->dev, NULL); 264 + imx2_wdt.clk = devm_clk_get(&pdev->dev, NULL); 265 265 if (IS_ERR(imx2_wdt.clk)) { 266 266 dev_err(&pdev->dev, "can't get Watchdog clock\n"); 267 267 return PTR_ERR(imx2_wdt.clk); ··· 286 286 287 287 fail: 288 288 imx2_wdt_miscdev.parent = NULL; 289 - clk_put(imx2_wdt.clk); 290 289 return ret; 291 290 } 292 291 ··· 298 299 299 300 dev_crit(imx2_wdt_miscdev.parent, 300 301 "Device removed: Expect reboot!\n"); 301 - } else 302 - clk_put(imx2_wdt.clk); 302 + } 303 303 304 304 imx2_wdt_miscdev.parent = NULL; 305 305 return 0;
+1 -1
drivers/watchdog/jz4740_wdt.c
··· 177 177 goto err_out; 178 178 } 179 179 180 - drvdata->rtc_clk = clk_get(NULL, "rtc"); 180 + drvdata->rtc_clk = clk_get(&pdev->dev, "rtc"); 181 181 if (IS_ERR(drvdata->rtc_clk)) { 182 182 dev_err(&pdev->dev, "cannot find RTC clock\n"); 183 183 ret = PTR_ERR(drvdata->rtc_clk);
+270
drivers/watchdog/mena21_wdt.c
··· 1 + /* 2 + * Watchdog driver for the A21 VME CPU Boards 3 + * 4 + * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License 8 + * as published by the Free Software Foundation 9 + */ 10 + #include <linux/module.h> 11 + #include <linux/moduleparam.h> 12 + #include <linux/types.h> 13 + #include <linux/kernel.h> 14 + #include <linux/slab.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/watchdog.h> 17 + #include <linux/uaccess.h> 18 + #include <linux/gpio.h> 19 + #include <linux/of_gpio.h> 20 + #include <linux/delay.h> 21 + #include <linux/bitops.h> 22 + 23 + #define NUM_GPIOS 6 24 + 25 + enum a21_wdt_gpios { 26 + GPIO_WD_ENAB, 27 + GPIO_WD_FAST, 28 + GPIO_WD_TRIG, 29 + GPIO_WD_RST0, 30 + GPIO_WD_RST1, 31 + GPIO_WD_RST2, 32 + }; 33 + 34 + struct a21_wdt_drv { 35 + struct watchdog_device wdt; 36 + struct mutex lock; 37 + unsigned gpios[NUM_GPIOS]; 38 + }; 39 + 40 + static bool nowayout = WATCHDOG_NOWAYOUT; 41 + module_param(nowayout, bool, 0); 42 + MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 43 + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 44 + 45 + static unsigned int a21_wdt_get_bootstatus(struct a21_wdt_drv *drv) 46 + { 47 + int reset = 0; 48 + 49 + reset |= gpio_get_value(drv->gpios[GPIO_WD_RST0]) ? (1 << 0) : 0; 50 + reset |= gpio_get_value(drv->gpios[GPIO_WD_RST1]) ? (1 << 1) : 0; 51 + reset |= gpio_get_value(drv->gpios[GPIO_WD_RST2]) ? (1 << 2) : 0; 52 + 53 + return reset; 54 + } 55 + 56 + static int a21_wdt_start(struct watchdog_device *wdt) 57 + { 58 + struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt); 59 + 60 + mutex_lock(&drv->lock); 61 + 62 + gpio_set_value(drv->gpios[GPIO_WD_ENAB], 1); 63 + 64 + mutex_unlock(&drv->lock); 65 + 66 + return 0; 67 + } 68 + 69 + static int a21_wdt_stop(struct watchdog_device *wdt) 70 + { 71 + struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt); 72 + 73 + mutex_lock(&drv->lock); 74 + 75 + gpio_set_value(drv->gpios[GPIO_WD_ENAB], 0); 76 + 77 + mutex_unlock(&drv->lock); 78 + 79 + return 0; 80 + } 81 + 82 + static int a21_wdt_ping(struct watchdog_device *wdt) 83 + { 84 + struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt); 85 + 86 + mutex_lock(&drv->lock); 87 + 88 + gpio_set_value(drv->gpios[GPIO_WD_TRIG], 0); 89 + ndelay(10); 90 + gpio_set_value(drv->gpios[GPIO_WD_TRIG], 1); 91 + 92 + mutex_unlock(&drv->lock); 93 + 94 + return 0; 95 + } 96 + 97 + static int a21_wdt_set_timeout(struct watchdog_device *wdt, 98 + unsigned int timeout) 99 + { 100 + struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt); 101 + 102 + if (timeout != 1 && timeout != 30) { 103 + dev_err(wdt->dev, "Only 1 and 30 allowed as timeout\n"); 104 + return -EINVAL; 105 + } 106 + 107 + if (timeout == 30 && wdt->timeout == 1) { 108 + dev_err(wdt->dev, 109 + "Transition from fast to slow mode not allowed\n"); 110 + return -EINVAL; 111 + } 112 + 113 + mutex_lock(&drv->lock); 114 + 115 + if (timeout == 1) 116 + gpio_set_value(drv->gpios[GPIO_WD_FAST], 1); 117 + else 118 + gpio_set_value(drv->gpios[GPIO_WD_FAST], 0); 119 + 120 + wdt->timeout = timeout; 121 + 122 + mutex_unlock(&drv->lock); 123 + 124 + return 0; 125 + } 126 + 127 + static const struct watchdog_info a21_wdt_info = { 128 + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 129 + .identity = "MEN A21 Watchdog", 130 + }; 131 + 132 + static const struct watchdog_ops a21_wdt_ops = { 133 + .owner = THIS_MODULE, 134 + .start = a21_wdt_start, 135 + .stop = a21_wdt_stop, 136 + .ping = a21_wdt_ping, 137 + .set_timeout = a21_wdt_set_timeout, 138 + }; 139 + 140 + static struct watchdog_device a21_wdt = { 141 + .info = &a21_wdt_info, 142 + .ops = &a21_wdt_ops, 143 + .min_timeout = 1, 144 + .max_timeout = 30, 145 + }; 146 + 147 + static int a21_wdt_probe(struct platform_device *pdev) 148 + { 149 + struct device_node *node; 150 + struct a21_wdt_drv *drv; 151 + unsigned int reset = 0; 152 + int num_gpios; 153 + int ret; 154 + int i; 155 + 156 + drv = devm_kzalloc(&pdev->dev, sizeof(struct a21_wdt_drv), GFP_KERNEL); 157 + if (!drv) 158 + return -ENOMEM; 159 + 160 + /* Fill GPIO pin array */ 161 + node = pdev->dev.of_node; 162 + 163 + num_gpios = of_gpio_count(node); 164 + if (num_gpios != NUM_GPIOS) { 165 + dev_err(&pdev->dev, "gpios DT property wrong, got %d want %d", 166 + num_gpios, NUM_GPIOS); 167 + return -ENODEV; 168 + } 169 + 170 + for (i = 0; i < num_gpios; i++) { 171 + int val; 172 + 173 + val = of_get_gpio(node, i); 174 + if (val < 0) 175 + return val; 176 + 177 + drv->gpios[i] = val; 178 + } 179 + 180 + /* Request the used GPIOs */ 181 + for (i = 0; i < num_gpios; i++) { 182 + ret = devm_gpio_request(&pdev->dev, drv->gpios[i], 183 + "MEN A21 Watchdog"); 184 + if (ret) 185 + return ret; 186 + 187 + if (i < GPIO_WD_RST0) 188 + ret = gpio_direction_output(drv->gpios[i], 189 + gpio_get_value(drv->gpios[i])); 190 + else /* GPIO_WD_RST[0..2] are inputs */ 191 + ret = gpio_direction_input(drv->gpios[i]); 192 + if (ret) 193 + return ret; 194 + } 195 + 196 + mutex_init(&drv->lock); 197 + watchdog_init_timeout(&a21_wdt, 30, &pdev->dev); 198 + watchdog_set_nowayout(&a21_wdt, nowayout); 199 + watchdog_set_drvdata(&a21_wdt, drv); 200 + 201 + reset = a21_wdt_get_bootstatus(drv); 202 + if (reset == 2) 203 + a21_wdt.bootstatus |= WDIOF_EXTERN1; 204 + else if (reset == 4) 205 + a21_wdt.bootstatus |= WDIOF_CARDRESET; 206 + else if (reset == 5) 207 + a21_wdt.bootstatus |= WDIOF_POWERUNDER; 208 + else if (reset == 7) 209 + a21_wdt.bootstatus |= WDIOF_EXTERN2; 210 + 211 + ret = watchdog_register_device(&a21_wdt); 212 + if (ret) { 213 + dev_err(&pdev->dev, "Cannot register watchdog device\n"); 214 + goto err_register_wd; 215 + } 216 + 217 + dev_set_drvdata(&pdev->dev, drv); 218 + 219 + dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n"); 220 + 221 + return 0; 222 + 223 + err_register_wd: 224 + mutex_destroy(&drv->lock); 225 + 226 + return ret; 227 + } 228 + 229 + static int a21_wdt_remove(struct platform_device *pdev) 230 + { 231 + struct a21_wdt_drv *drv = dev_get_drvdata(&pdev->dev); 232 + 233 + dev_warn(&pdev->dev, 234 + "Unregistering A21 watchdog driver, board may reboot\n"); 235 + 236 + watchdog_unregister_device(&drv->wdt); 237 + 238 + mutex_destroy(&drv->lock); 239 + 240 + return 0; 241 + } 242 + 243 + static void a21_wdt_shutdown(struct platform_device *pdev) 244 + { 245 + struct a21_wdt_drv *drv = dev_get_drvdata(&pdev->dev); 246 + 247 + gpio_set_value(drv->gpios[GPIO_WD_ENAB], 0); 248 + } 249 + 250 + static const struct of_device_id a21_wdt_ids[] = { 251 + { .compatible = "men,a021-wdt" }, 252 + { }, 253 + }; 254 + 255 + static struct platform_driver a21_wdt_driver = { 256 + .probe = a21_wdt_probe, 257 + .remove = a21_wdt_remove, 258 + .shutdown = a21_wdt_shutdown, 259 + .driver = { 260 + .name = "a21-watchdog", 261 + .of_match_table = a21_wdt_ids, 262 + }, 263 + }; 264 + 265 + module_platform_driver(a21_wdt_driver); 266 + 267 + MODULE_AUTHOR("MEN Mikro Elektronik"); 268 + MODULE_DESCRIPTION("MEN A21 Watchdog"); 269 + MODULE_LICENSE("GPL"); 270 + MODULE_ALIAS("platform:a21-watchdog");
-456
drivers/watchdog/mpcore_wdt.c
··· 1 - /* 2 - * Watchdog driver for the mpcore watchdog timer 3 - * 4 - * (c) Copyright 2004 ARM Limited 5 - * 6 - * Based on the SoftDog driver: 7 - * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>, 8 - * All Rights Reserved. 9 - * 10 - * This program is free software; you can redistribute it and/or 11 - * modify it under the terms of the GNU General Public License 12 - * as published by the Free Software Foundation; either version 13 - * 2 of the License, or (at your option) any later version. 14 - * 15 - * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 16 - * warranty for any of this software. This material is provided 17 - * "AS-IS" and at no charge. 18 - * 19 - * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> 20 - * 21 - */ 22 - 23 - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 24 - 25 - #include <linux/module.h> 26 - #include <linux/moduleparam.h> 27 - #include <linux/types.h> 28 - #include <linux/miscdevice.h> 29 - #include <linux/watchdog.h> 30 - #include <linux/fs.h> 31 - #include <linux/reboot.h> 32 - #include <linux/init.h> 33 - #include <linux/interrupt.h> 34 - #include <linux/platform_device.h> 35 - #include <linux/uaccess.h> 36 - #include <linux/slab.h> 37 - #include <linux/io.h> 38 - 39 - #include <asm/smp_twd.h> 40 - 41 - struct mpcore_wdt { 42 - unsigned long timer_alive; 43 - struct device *dev; 44 - void __iomem *base; 45 - int irq; 46 - unsigned int perturb; 47 - char expect_close; 48 - }; 49 - 50 - static struct platform_device *mpcore_wdt_pdev; 51 - static DEFINE_SPINLOCK(wdt_lock); 52 - 53 - #define TIMER_MARGIN 60 54 - static int mpcore_margin = TIMER_MARGIN; 55 - module_param(mpcore_margin, int, 0); 56 - MODULE_PARM_DESC(mpcore_margin, 57 - "MPcore timer margin in seconds. (0 < mpcore_margin < 65536, default=" 58 - __MODULE_STRING(TIMER_MARGIN) ")"); 59 - 60 - static bool nowayout = WATCHDOG_NOWAYOUT; 61 - module_param(nowayout, bool, 0); 62 - MODULE_PARM_DESC(nowayout, 63 - "Watchdog cannot be stopped once started (default=" 64 - __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 65 - 66 - #define ONLY_TESTING 0 67 - static int mpcore_noboot = ONLY_TESTING; 68 - module_param(mpcore_noboot, int, 0); 69 - MODULE_PARM_DESC(mpcore_noboot, "MPcore watchdog action, " 70 - "set to 1 to ignore reboots, 0 to reboot (default=" 71 - __MODULE_STRING(ONLY_TESTING) ")"); 72 - 73 - /* 74 - * This is the interrupt handler. Note that we only use this 75 - * in testing mode, so don't actually do a reboot here. 76 - */ 77 - static irqreturn_t mpcore_wdt_fire(int irq, void *arg) 78 - { 79 - struct mpcore_wdt *wdt = arg; 80 - 81 - /* Check it really was our interrupt */ 82 - if (readl(wdt->base + TWD_WDOG_INTSTAT)) { 83 - dev_crit(wdt->dev, "Triggered - Reboot ignored\n"); 84 - /* Clear the interrupt on the watchdog */ 85 - writel(1, wdt->base + TWD_WDOG_INTSTAT); 86 - return IRQ_HANDLED; 87 - } 88 - return IRQ_NONE; 89 - } 90 - 91 - /* 92 - * mpcore_wdt_keepalive - reload the timer 93 - * 94 - * Note that the spec says a DIFFERENT value must be written to the reload 95 - * register each time. The "perturb" variable deals with this by adding 1 96 - * to the count every other time the function is called. 97 - */ 98 - static void mpcore_wdt_keepalive(struct mpcore_wdt *wdt) 99 - { 100 - unsigned long count; 101 - 102 - spin_lock(&wdt_lock); 103 - /* Assume prescale is set to 256 */ 104 - count = __raw_readl(wdt->base + TWD_WDOG_COUNTER); 105 - count = (0xFFFFFFFFU - count) * (HZ / 5); 106 - count = (count / 256) * mpcore_margin; 107 - 108 - /* Reload the counter */ 109 - writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD); 110 - wdt->perturb = wdt->perturb ? 0 : 1; 111 - spin_unlock(&wdt_lock); 112 - } 113 - 114 - static void mpcore_wdt_stop(struct mpcore_wdt *wdt) 115 - { 116 - spin_lock(&wdt_lock); 117 - writel(0x12345678, wdt->base + TWD_WDOG_DISABLE); 118 - writel(0x87654321, wdt->base + TWD_WDOG_DISABLE); 119 - writel(0x0, wdt->base + TWD_WDOG_CONTROL); 120 - spin_unlock(&wdt_lock); 121 - } 122 - 123 - static void mpcore_wdt_start(struct mpcore_wdt *wdt) 124 - { 125 - dev_info(wdt->dev, "enabling watchdog\n"); 126 - 127 - /* This loads the count register but does NOT start the count yet */ 128 - mpcore_wdt_keepalive(wdt); 129 - 130 - if (mpcore_noboot) { 131 - /* Enable watchdog - prescale=256, watchdog mode=0, enable=1 */ 132 - writel(0x0000FF01, wdt->base + TWD_WDOG_CONTROL); 133 - } else { 134 - /* Enable watchdog - prescale=256, watchdog mode=1, enable=1 */ 135 - writel(0x0000FF09, wdt->base + TWD_WDOG_CONTROL); 136 - } 137 - } 138 - 139 - static int mpcore_wdt_set_heartbeat(int t) 140 - { 141 - if (t < 0x0001 || t > 0xFFFF) 142 - return -EINVAL; 143 - 144 - mpcore_margin = t; 145 - return 0; 146 - } 147 - 148 - /* 149 - * /dev/watchdog handling 150 - */ 151 - static int mpcore_wdt_open(struct inode *inode, struct file *file) 152 - { 153 - struct mpcore_wdt *wdt = platform_get_drvdata(mpcore_wdt_pdev); 154 - 155 - if (test_and_set_bit(0, &wdt->timer_alive)) 156 - return -EBUSY; 157 - 158 - if (nowayout) 159 - __module_get(THIS_MODULE); 160 - 161 - file->private_data = wdt; 162 - 163 - /* 164 - * Activate timer 165 - */ 166 - mpcore_wdt_start(wdt); 167 - 168 - return nonseekable_open(inode, file); 169 - } 170 - 171 - static int mpcore_wdt_release(struct inode *inode, struct file *file) 172 - { 173 - struct mpcore_wdt *wdt = file->private_data; 174 - 175 - /* 176 - * Shut off the timer. 177 - * Lock it in if it's a module and we set nowayout 178 - */ 179 - if (wdt->expect_close == 42) 180 - mpcore_wdt_stop(wdt); 181 - else { 182 - dev_crit(wdt->dev, 183 - "unexpected close, not stopping watchdog!\n"); 184 - mpcore_wdt_keepalive(wdt); 185 - } 186 - clear_bit(0, &wdt->timer_alive); 187 - wdt->expect_close = 0; 188 - return 0; 189 - } 190 - 191 - static ssize_t mpcore_wdt_write(struct file *file, const char *data, 192 - size_t len, loff_t *ppos) 193 - { 194 - struct mpcore_wdt *wdt = file->private_data; 195 - 196 - /* 197 - * Refresh the timer. 198 - */ 199 - if (len) { 200 - if (!nowayout) { 201 - size_t i; 202 - 203 - /* In case it was set long ago */ 204 - wdt->expect_close = 0; 205 - 206 - for (i = 0; i != len; i++) { 207 - char c; 208 - 209 - if (get_user(c, data + i)) 210 - return -EFAULT; 211 - if (c == 'V') 212 - wdt->expect_close = 42; 213 - } 214 - } 215 - mpcore_wdt_keepalive(wdt); 216 - } 217 - return len; 218 - } 219 - 220 - static const struct watchdog_info ident = { 221 - .options = WDIOF_SETTIMEOUT | 222 - WDIOF_KEEPALIVEPING | 223 - WDIOF_MAGICCLOSE, 224 - .identity = "MPcore Watchdog", 225 - }; 226 - 227 - static long mpcore_wdt_ioctl(struct file *file, unsigned int cmd, 228 - unsigned long arg) 229 - { 230 - struct mpcore_wdt *wdt = file->private_data; 231 - int ret; 232 - union { 233 - struct watchdog_info ident; 234 - int i; 235 - } uarg; 236 - 237 - if (_IOC_DIR(cmd) && _IOC_SIZE(cmd) > sizeof(uarg)) 238 - return -ENOTTY; 239 - 240 - if (_IOC_DIR(cmd) & _IOC_WRITE) { 241 - ret = copy_from_user(&uarg, (void __user *)arg, _IOC_SIZE(cmd)); 242 - if (ret) 243 - return -EFAULT; 244 - } 245 - 246 - switch (cmd) { 247 - case WDIOC_GETSUPPORT: 248 - uarg.ident = ident; 249 - ret = 0; 250 - break; 251 - 252 - case WDIOC_GETSTATUS: 253 - case WDIOC_GETBOOTSTATUS: 254 - uarg.i = 0; 255 - ret = 0; 256 - break; 257 - 258 - case WDIOC_SETOPTIONS: 259 - ret = -EINVAL; 260 - if (uarg.i & WDIOS_DISABLECARD) { 261 - mpcore_wdt_stop(wdt); 262 - ret = 0; 263 - } 264 - if (uarg.i & WDIOS_ENABLECARD) { 265 - mpcore_wdt_start(wdt); 266 - ret = 0; 267 - } 268 - break; 269 - 270 - case WDIOC_KEEPALIVE: 271 - mpcore_wdt_keepalive(wdt); 272 - ret = 0; 273 - break; 274 - 275 - case WDIOC_SETTIMEOUT: 276 - ret = mpcore_wdt_set_heartbeat(uarg.i); 277 - if (ret) 278 - break; 279 - 280 - mpcore_wdt_keepalive(wdt); 281 - /* Fall */ 282 - case WDIOC_GETTIMEOUT: 283 - uarg.i = mpcore_margin; 284 - ret = 0; 285 - break; 286 - 287 - default: 288 - return -ENOTTY; 289 - } 290 - 291 - if (ret == 0 && _IOC_DIR(cmd) & _IOC_READ) { 292 - ret = copy_to_user((void __user *)arg, &uarg, _IOC_SIZE(cmd)); 293 - if (ret) 294 - ret = -EFAULT; 295 - } 296 - return ret; 297 - } 298 - 299 - /* 300 - * System shutdown handler. Turn off the watchdog if we're 301 - * restarting or halting the system. 302 - */ 303 - static void mpcore_wdt_shutdown(struct platform_device *pdev) 304 - { 305 - struct mpcore_wdt *wdt = platform_get_drvdata(pdev); 306 - 307 - if (system_state == SYSTEM_RESTART || system_state == SYSTEM_HALT) 308 - mpcore_wdt_stop(wdt); 309 - } 310 - 311 - /* 312 - * Kernel Interfaces 313 - */ 314 - static const struct file_operations mpcore_wdt_fops = { 315 - .owner = THIS_MODULE, 316 - .llseek = no_llseek, 317 - .write = mpcore_wdt_write, 318 - .unlocked_ioctl = mpcore_wdt_ioctl, 319 - .open = mpcore_wdt_open, 320 - .release = mpcore_wdt_release, 321 - }; 322 - 323 - static struct miscdevice mpcore_wdt_miscdev = { 324 - .minor = WATCHDOG_MINOR, 325 - .name = "watchdog", 326 - .fops = &mpcore_wdt_fops, 327 - }; 328 - 329 - static int mpcore_wdt_probe(struct platform_device *pdev) 330 - { 331 - struct mpcore_wdt *wdt; 332 - struct resource *res; 333 - int ret; 334 - 335 - /* We only accept one device, and it must have an id of -1 */ 336 - if (pdev->id != -1) 337 - return -ENODEV; 338 - 339 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 340 - if (!res) 341 - return -ENODEV; 342 - 343 - wdt = devm_kzalloc(&pdev->dev, sizeof(struct mpcore_wdt), GFP_KERNEL); 344 - if (!wdt) 345 - return -ENOMEM; 346 - 347 - wdt->dev = &pdev->dev; 348 - wdt->irq = platform_get_irq(pdev, 0); 349 - if (wdt->irq >= 0) { 350 - ret = devm_request_irq(wdt->dev, wdt->irq, mpcore_wdt_fire, 0, 351 - "mpcore_wdt", wdt); 352 - if (ret) { 353 - dev_err(wdt->dev, 354 - "cannot register IRQ%d for watchdog\n", 355 - wdt->irq); 356 - return ret; 357 - } 358 - } 359 - 360 - wdt->base = devm_ioremap(wdt->dev, res->start, resource_size(res)); 361 - if (!wdt->base) 362 - return -ENOMEM; 363 - 364 - mpcore_wdt_miscdev.parent = &pdev->dev; 365 - ret = misc_register(&mpcore_wdt_miscdev); 366 - if (ret) { 367 - dev_err(wdt->dev, 368 - "cannot register miscdev on minor=%d (err=%d)\n", 369 - WATCHDOG_MINOR, ret); 370 - return ret; 371 - } 372 - 373 - mpcore_wdt_stop(wdt); 374 - platform_set_drvdata(pdev, wdt); 375 - mpcore_wdt_pdev = pdev; 376 - 377 - return 0; 378 - } 379 - 380 - static int mpcore_wdt_remove(struct platform_device *pdev) 381 - { 382 - platform_set_drvdata(pdev, NULL); 383 - 384 - misc_deregister(&mpcore_wdt_miscdev); 385 - 386 - mpcore_wdt_pdev = NULL; 387 - 388 - return 0; 389 - } 390 - 391 - #ifdef CONFIG_PM 392 - static int mpcore_wdt_suspend(struct platform_device *pdev, pm_message_t msg) 393 - { 394 - struct mpcore_wdt *wdt = platform_get_drvdata(pdev); 395 - mpcore_wdt_stop(wdt); /* Turn the WDT off */ 396 - return 0; 397 - } 398 - 399 - static int mpcore_wdt_resume(struct platform_device *pdev) 400 - { 401 - struct mpcore_wdt *wdt = platform_get_drvdata(pdev); 402 - /* re-activate timer */ 403 - if (test_bit(0, &wdt->timer_alive)) 404 - mpcore_wdt_start(wdt); 405 - return 0; 406 - } 407 - #else 408 - #define mpcore_wdt_suspend NULL 409 - #define mpcore_wdt_resume NULL 410 - #endif 411 - 412 - /* work with hotplug and coldplug */ 413 - MODULE_ALIAS("platform:mpcore_wdt"); 414 - 415 - static struct platform_driver mpcore_wdt_driver = { 416 - .probe = mpcore_wdt_probe, 417 - .remove = mpcore_wdt_remove, 418 - .suspend = mpcore_wdt_suspend, 419 - .resume = mpcore_wdt_resume, 420 - .shutdown = mpcore_wdt_shutdown, 421 - .driver = { 422 - .owner = THIS_MODULE, 423 - .name = "mpcore_wdt", 424 - }, 425 - }; 426 - 427 - static int __init mpcore_wdt_init(void) 428 - { 429 - /* 430 - * Check that the margin value is within it's range; 431 - * if not reset to the default 432 - */ 433 - if (mpcore_wdt_set_heartbeat(mpcore_margin)) { 434 - mpcore_wdt_set_heartbeat(TIMER_MARGIN); 435 - pr_info("mpcore_margin value must be 0 < mpcore_margin < 65536, using %d\n", 436 - TIMER_MARGIN); 437 - } 438 - 439 - pr_info("MPcore Watchdog Timer: 0.1. mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n", 440 - mpcore_noboot, mpcore_margin, nowayout); 441 - 442 - return platform_driver_register(&mpcore_wdt_driver); 443 - } 444 - 445 - static void __exit mpcore_wdt_exit(void) 446 - { 447 - platform_driver_unregister(&mpcore_wdt_driver); 448 - } 449 - 450 - module_init(mpcore_wdt_init); 451 - module_exit(mpcore_wdt_exit); 452 - 453 - MODULE_AUTHOR("ARM Limited"); 454 - MODULE_DESCRIPTION("MPcore Watchdog Device Driver"); 455 - MODULE_LICENSE("GPL"); 456 - MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
+1 -2
drivers/watchdog/mtx-1_wdt.c
··· 209 209 int ret; 210 210 211 211 mtx1_wdt_device.gpio = pdev->resource[0].start; 212 - ret = gpio_request_one(mtx1_wdt_device.gpio, 212 + ret = devm_gpio_request_one(&pdev->dev, mtx1_wdt_device.gpio, 213 213 GPIOF_OUT_INIT_HIGH, "mtx1-wdt"); 214 214 if (ret < 0) { 215 215 dev_err(&pdev->dev, "failed to request gpio"); ··· 241 241 wait_for_completion(&mtx1_wdt_device.stop); 242 242 } 243 243 244 - gpio_free(mtx1_wdt_device.gpio); 245 244 misc_deregister(&mtx1_wdt_misc); 246 245 return 0; 247 246 }
+1 -3
drivers/watchdog/mv64x60_wdt.c
··· 276 276 if (!r) 277 277 return -ENODEV; 278 278 279 - mv64x60_wdt_regs = ioremap(r->start, resource_size(r)); 279 + mv64x60_wdt_regs = devm_ioremap(&dev->dev, r->start, resource_size(r)); 280 280 if (mv64x60_wdt_regs == NULL) 281 281 return -ENOMEM; 282 282 ··· 292 292 misc_deregister(&mv64x60_wdt_miscdev); 293 293 294 294 mv64x60_wdt_handler_disable(); 295 - 296 - iounmap(mv64x60_wdt_regs); 297 295 298 296 return 0; 299 297 }
+11 -39
drivers/watchdog/nuc900_wdt.c
··· 61 61 "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 62 62 63 63 struct nuc900_wdt { 64 - struct resource *res; 65 64 struct clk *wdt_clock; 66 65 struct platform_device *pdev; 67 66 void __iomem *wdt_base; ··· 243 244 244 245 static int nuc900wdt_probe(struct platform_device *pdev) 245 246 { 247 + struct resource *res; 246 248 int ret = 0; 247 249 248 - nuc900_wdt = kzalloc(sizeof(struct nuc900_wdt), GFP_KERNEL); 250 + nuc900_wdt = devm_kzalloc(&pdev->dev, sizeof(*nuc900_wdt), 251 + GFP_KERNEL); 249 252 if (!nuc900_wdt) 250 253 return -ENOMEM; 251 254 ··· 255 254 256 255 spin_lock_init(&nuc900_wdt->wdt_lock); 257 256 258 - nuc900_wdt->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 259 - if (nuc900_wdt->res == NULL) { 257 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 258 + if (res == NULL) { 260 259 dev_err(&pdev->dev, "no memory resource specified\n"); 261 - ret = -ENOENT; 262 - goto err_get; 260 + return -ENOENT; 263 261 } 264 262 265 - if (!request_mem_region(nuc900_wdt->res->start, 266 - resource_size(nuc900_wdt->res), pdev->name)) { 267 - dev_err(&pdev->dev, "failed to get memory region\n"); 268 - ret = -ENOENT; 269 - goto err_get; 270 - } 263 + nuc900_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res); 264 + if (IS_ERR(nuc900_wdt->wdt_base)) 265 + return PTR_ERR(nuc900_wdt->wdt_base); 271 266 272 - nuc900_wdt->wdt_base = ioremap(nuc900_wdt->res->start, 273 - resource_size(nuc900_wdt->res)); 274 - if (nuc900_wdt->wdt_base == NULL) { 275 - dev_err(&pdev->dev, "failed to ioremap() region\n"); 276 - ret = -EINVAL; 277 - goto err_req; 278 - } 279 - 280 - nuc900_wdt->wdt_clock = clk_get(&pdev->dev, NULL); 267 + nuc900_wdt->wdt_clock = devm_clk_get(&pdev->dev, NULL); 281 268 if (IS_ERR(nuc900_wdt->wdt_clock)) { 282 269 dev_err(&pdev->dev, "failed to find watchdog clock source\n"); 283 - ret = PTR_ERR(nuc900_wdt->wdt_clock); 284 - goto err_map; 270 + return PTR_ERR(nuc900_wdt->wdt_clock); 285 271 } 286 272 287 273 clk_enable(nuc900_wdt->wdt_clock); ··· 286 298 287 299 err_clk: 288 300 clk_disable(nuc900_wdt->wdt_clock); 289 - clk_put(nuc900_wdt->wdt_clock); 290 - err_map: 291 - iounmap(nuc900_wdt->wdt_base); 292 - err_req: 293 - release_mem_region(nuc900_wdt->res->start, 294 - resource_size(nuc900_wdt->res)); 295 - err_get: 296 - kfree(nuc900_wdt); 297 301 return ret; 298 302 } 299 303 ··· 294 314 misc_deregister(&nuc900wdt_miscdev); 295 315 296 316 clk_disable(nuc900_wdt->wdt_clock); 297 - clk_put(nuc900_wdt->wdt_clock); 298 - 299 - iounmap(nuc900_wdt->wdt_base); 300 - 301 - release_mem_region(nuc900_wdt->res->start, 302 - resource_size(nuc900_wdt->res)); 303 - 304 - kfree(nuc900_wdt); 305 317 306 318 return 0; 307 319 }
+11 -20
drivers/watchdog/of_xilinx_wdt.c
··· 1 1 /* 2 - * of_xilinx_wdt.c 1.01 A Watchdog Device Driver for Xilinx xps_timebase_wdt 3 - * 4 - * (C) Copyright 2011 (Alejandro Cabrera <aldaya@gmail.com>) 5 - * 6 - * ----------------------- 7 - * 8 - * This program is free software; you can redistribute it and/or 9 - * modify it under the terms of the GNU General Public License 10 - * as published by the Free Software Foundation; either version 11 - * 2 of the License, or (at your option) any later version. 12 - * 13 - * ----------------------- 14 - * 30-May-2011 Alejandro Cabrera <aldaya@gmail.com> 15 - * - If "xlnx,wdt-enable-once" wasn't found on device tree the 16 - * module will use CONFIG_WATCHDOG_NOWAYOUT 17 - * - If the device tree parameters ("clock-frequency" and 18 - * "xlnx,wdt-interval") wasn't found the driver won't 19 - * know the wdt reset interval 20 - */ 2 + * Watchdog Device Driver for Xilinx axi/xps_timebase_wdt 3 + * 4 + * (C) Copyright 2011 (Alejandro Cabrera <aldaya@gmail.com>) 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License 8 + * as published by the Free Software Foundation; either version 9 + * 2 of the License, or (at your option) any later version. 10 + */ 21 11 22 12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 23 13 ··· 384 394 385 395 /* Match table for of_platform binding */ 386 396 static struct of_device_id xwdt_of_match[] = { 397 + { .compatible = "xlnx,xps-timebase-wdt-1.00.a", }, 387 398 { .compatible = "xlnx,xps-timebase-wdt-1.01.a", }, 388 399 {}, 389 400 }; ··· 404 413 405 414 MODULE_AUTHOR("Alejandro Cabrera <aldaya@gmail.com>"); 406 415 MODULE_DESCRIPTION("Xilinx Watchdog driver"); 407 - MODULE_LICENSE("GPL"); 416 + MODULE_LICENSE("GPL v2"); 408 417 MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
+4 -3
drivers/watchdog/orion_wdt.c
··· 38 38 #define WDT_IN_USE 0 39 39 #define WDT_OK_TO_CLOSE 1 40 40 41 + #define WDT_RESET_OUT_EN BIT(1) 42 + #define WDT_INT_REQ BIT(3) 43 + 41 44 static bool nowayout = WATCHDOG_NOWAYOUT; 42 45 static int heartbeat = -1; /* module parameter (seconds) */ 43 46 static unsigned int wdt_max_duration; /* (seconds) */ ··· 70 67 writel(wdt_tclk * wdt_dev->timeout, wdt_reg + WDT_VAL); 71 68 72 69 /* Clear watchdog timer interrupt */ 73 - reg = readl(BRIDGE_CAUSE); 74 - reg &= ~WDT_INT_REQ; 75 - writel(reg, BRIDGE_CAUSE); 70 + writel(~WDT_INT_REQ, BRIDGE_CAUSE); 76 71 77 72 /* Enable watchdog timer */ 78 73 reg = readl(wdt_reg + TIMER_CTRL);
+2 -5
drivers/watchdog/pnx4008_wdt.c
··· 159 159 if (IS_ERR(wdt_base)) 160 160 return PTR_ERR(wdt_base); 161 161 162 - wdt_clk = clk_get(&pdev->dev, NULL); 162 + wdt_clk = devm_clk_get(&pdev->dev, NULL); 163 163 if (IS_ERR(wdt_clk)) 164 164 return PTR_ERR(wdt_clk); 165 165 166 166 ret = clk_enable(wdt_clk); 167 167 if (ret) 168 - goto out; 168 + return ret; 169 169 170 170 pnx4008_wdd.bootstatus = (readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ? 171 171 WDIOF_CARDRESET : 0; ··· 186 186 187 187 disable_clk: 188 188 clk_disable(wdt_clk); 189 - out: 190 - clk_put(wdt_clk); 191 189 return ret; 192 190 } 193 191 ··· 194 196 watchdog_unregister_device(&pnx4008_wdd); 195 197 196 198 clk_disable(wdt_clk); 197 - clk_put(wdt_clk); 198 199 199 200 return 0; 200 201 }
+3 -7
drivers/watchdog/rc32434_wdt.c
··· 32 32 #include <linux/platform_device.h> /* For platform_driver framework */ 33 33 #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ 34 34 #include <linux/uaccess.h> /* For copy_to_user/put_user/... */ 35 + #include <linux/io.h> /* For devm_ioremap_nocache */ 35 36 36 37 #include <asm/mach-rc32434/integ.h> /* For the Watchdog registers */ 37 38 ··· 272 271 return -ENODEV; 273 272 } 274 273 275 - wdt_reg = ioremap_nocache(r->start, resource_size(r)); 274 + wdt_reg = devm_ioremap_nocache(&pdev->dev, r->start, resource_size(r)); 276 275 if (!wdt_reg) { 277 276 pr_err("failed to remap I/O resources\n"); 278 277 return -ENXIO; ··· 294 293 ret = misc_register(&rc32434_wdt_miscdev); 295 294 if (ret < 0) { 296 295 pr_err("failed to register watchdog device\n"); 297 - goto unmap; 296 + return ret; 298 297 } 299 298 300 299 pr_info("Watchdog Timer version " VERSION ", timer margin: %d sec\n", 301 300 timeout); 302 301 303 302 return 0; 304 - 305 - unmap: 306 - iounmap(wdt_reg); 307 - return ret; 308 303 } 309 304 310 305 static int rc32434_wdt_remove(struct platform_device *pdev) 311 306 { 312 307 misc_deregister(&rc32434_wdt_miscdev); 313 - iounmap(wdt_reg); 314 308 return 0; 315 309 } 316 310
+4 -8
drivers/watchdog/riowd.c
··· 183 183 goto out; 184 184 185 185 err = -ENOMEM; 186 - p = kzalloc(sizeof(*p), GFP_KERNEL); 186 + p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL); 187 187 if (!p) 188 188 goto out; 189 189 ··· 192 192 p->regs = of_ioremap(&op->resource[0], 0, 2, DRIVER_NAME); 193 193 if (!p->regs) { 194 194 pr_err("Cannot map registers\n"); 195 - goto out_free; 195 + goto out; 196 196 } 197 197 /* Make miscdev useable right away */ 198 198 riowd_device = p; ··· 206 206 pr_info("Hardware watchdog [%i minutes], regs at %p\n", 207 207 riowd_timeout, p->regs); 208 208 209 - dev_set_drvdata(&op->dev, p); 209 + platform_set_drvdata(op, p); 210 210 return 0; 211 211 212 212 out_iounmap: 213 213 riowd_device = NULL; 214 214 of_iounmap(&op->resource[0], p->regs, 2); 215 - 216 - out_free: 217 - kfree(p); 218 215 219 216 out: 220 217 return err; ··· 219 222 220 223 static int riowd_remove(struct platform_device *op) 221 224 { 222 - struct riowd *p = dev_get_drvdata(&op->dev); 225 + struct riowd *p = platform_get_drvdata(op); 223 226 224 227 misc_deregister(&riowd_miscdev); 225 228 of_iounmap(&op->resource[0], p->regs, 2); 226 - kfree(p); 227 229 228 230 return 0; 229 231 }
+9 -11
drivers/watchdog/s3c2410_wdt.c
··· 358 358 359 359 ret = s3c2410wdt_cpufreq_register(); 360 360 if (ret < 0) { 361 - pr_err("failed to register cpufreq\n"); 361 + dev_err(dev, "failed to register cpufreq\n"); 362 362 goto err_clk; 363 363 } 364 364 ··· 448 448 s3c2410wdt_stop(&s3c2410_wdd); 449 449 } 450 450 451 - #ifdef CONFIG_PM 451 + #ifdef CONFIG_PM_SLEEP 452 452 453 453 static unsigned long wtcon_save; 454 454 static unsigned long wtdat_save; 455 455 456 - static int s3c2410wdt_suspend(struct platform_device *dev, pm_message_t state) 456 + static int s3c2410wdt_suspend(struct device *dev) 457 457 { 458 458 /* Save watchdog state, and turn it off. */ 459 459 wtcon_save = readl(wdt_base + S3C2410_WTCON); ··· 465 465 return 0; 466 466 } 467 467 468 - static int s3c2410wdt_resume(struct platform_device *dev) 468 + static int s3c2410wdt_resume(struct device *dev) 469 469 { 470 470 /* Restore watchdog state. */ 471 471 ··· 473 473 writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */ 474 474 writel(wtcon_save, wdt_base + S3C2410_WTCON); 475 475 476 - pr_info("watchdog %sabled\n", 476 + dev_info(dev, "watchdog %sabled\n", 477 477 (wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis"); 478 478 479 479 return 0; 480 480 } 481 + #endif 481 482 482 - #else 483 - #define s3c2410wdt_suspend NULL 484 - #define s3c2410wdt_resume NULL 485 - #endif /* CONFIG_PM */ 483 + static SIMPLE_DEV_PM_OPS(s3c2410wdt_pm_ops, s3c2410wdt_suspend, 484 + s3c2410wdt_resume); 486 485 487 486 #ifdef CONFIG_OF 488 487 static const struct of_device_id s3c2410_wdt_match[] = { ··· 495 496 .probe = s3c2410wdt_probe, 496 497 .remove = s3c2410wdt_remove, 497 498 .shutdown = s3c2410wdt_shutdown, 498 - .suspend = s3c2410wdt_suspend, 499 - .resume = s3c2410wdt_resume, 500 499 .driver = { 501 500 .owner = THIS_MODULE, 502 501 .name = "s3c2410-wdt", 502 + .pm = &s3c2410wdt_pm_ops, 503 503 .of_match_table = of_match_ptr(s3c2410_wdt_match), 504 504 }, 505 505 };
+4 -14
drivers/watchdog/shwdt.c
··· 241 241 242 242 wdt->dev = &pdev->dev; 243 243 244 - wdt->clk = clk_get(&pdev->dev, NULL); 244 + wdt->clk = devm_clk_get(&pdev->dev, NULL); 245 245 if (IS_ERR(wdt->clk)) { 246 246 /* 247 247 * Clock framework support is optional, continue on ··· 251 251 } 252 252 253 253 wdt->base = devm_ioremap_resource(wdt->dev, res); 254 - if (IS_ERR(wdt->base)) { 255 - rc = PTR_ERR(wdt->base); 256 - goto err; 257 - } 254 + if (IS_ERR(wdt->base)) 255 + return PTR_ERR(wdt->base); 258 256 259 257 watchdog_set_nowayout(&sh_wdt_dev, nowayout); 260 258 watchdog_set_drvdata(&sh_wdt_dev, wdt); ··· 275 277 rc = watchdog_register_device(&sh_wdt_dev); 276 278 if (unlikely(rc)) { 277 279 dev_err(&pdev->dev, "Can't register watchdog (err=%d)\n", rc); 278 - goto err; 280 + return rc; 279 281 } 280 282 281 283 init_timer(&wdt->timer); ··· 290 292 pm_runtime_enable(&pdev->dev); 291 293 292 294 return 0; 293 - 294 - err: 295 - clk_put(wdt->clk); 296 - 297 - return rc; 298 295 } 299 296 300 297 static int sh_wdt_remove(struct platform_device *pdev) 301 298 { 302 299 struct sh_wdt *wdt = platform_get_drvdata(pdev); 303 300 304 - platform_set_drvdata(pdev, NULL); 305 - 306 301 watchdog_unregister_device(&sh_wdt_dev); 307 302 308 303 pm_runtime_disable(&pdev->dev); 309 - clk_put(wdt->clk); 310 304 311 305 return 0; 312 306 }
-1
drivers/watchdog/softdog.c
··· 152 152 .owner = THIS_MODULE, 153 153 .start = softdog_ping, 154 154 .stop = softdog_stop, 155 - .ping = softdog_ping, 156 155 .set_timeout = softdog_set_timeout, 157 156 }; 158 157
+2 -5
drivers/watchdog/sp805_wdt.c
··· 231 231 goto err; 232 232 } 233 233 234 - wdt->clk = clk_get(&adev->dev, NULL); 234 + wdt->clk = devm_clk_get(&adev->dev, NULL); 235 235 if (IS_ERR(wdt->clk)) { 236 236 dev_warn(&adev->dev, "Clock not found\n"); 237 237 ret = PTR_ERR(wdt->clk); ··· 251 251 if (ret) { 252 252 dev_err(&adev->dev, "watchdog_register_device() failed: %d\n", 253 253 ret); 254 - goto err_register; 254 + goto err; 255 255 } 256 256 amba_set_drvdata(adev, wdt); 257 257 258 258 dev_info(&adev->dev, "registration successful\n"); 259 259 return 0; 260 260 261 - err_register: 262 - clk_put(wdt->clk); 263 261 err: 264 262 dev_err(&adev->dev, "Probe Failed!!!\n"); 265 263 return ret; ··· 270 272 watchdog_unregister_device(&wdt->wdd); 271 273 amba_set_drvdata(adev, NULL); 272 274 watchdog_set_drvdata(&wdt->wdd, NULL); 273 - clk_put(wdt->clk); 274 275 275 276 return 0; 276 277 }
+10 -57
drivers/watchdog/ts72xx_wdt.c
··· 396 396 struct resource *r1, *r2; 397 397 int error = 0; 398 398 399 - wdt = kzalloc(sizeof(struct ts72xx_wdt), GFP_KERNEL); 399 + wdt = devm_kzalloc(&pdev->dev, sizeof(struct ts72xx_wdt), GFP_KERNEL); 400 400 if (!wdt) { 401 401 dev_err(&pdev->dev, "failed to allocate memory\n"); 402 402 return -ENOMEM; ··· 405 405 r1 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 406 406 if (!r1) { 407 407 dev_err(&pdev->dev, "failed to get memory resource\n"); 408 - error = -ENODEV; 409 - goto fail; 408 + return -ENODEV; 410 409 } 411 410 412 - r1 = request_mem_region(r1->start, resource_size(r1), pdev->name); 413 - if (!r1) { 414 - dev_err(&pdev->dev, "cannot request memory region\n"); 415 - error = -EBUSY; 416 - goto fail; 417 - } 418 - 419 - wdt->control_reg = ioremap(r1->start, resource_size(r1)); 420 - if (!wdt->control_reg) { 421 - dev_err(&pdev->dev, "failed to map memory\n"); 422 - error = -ENODEV; 423 - goto fail_free_control; 424 - } 411 + wdt->control_reg = devm_ioremap_resource(&pdev->dev, r1); 412 + if (IS_ERR(wdt->control_reg)) 413 + return PTR_ERR(wdt->control_reg); 425 414 426 415 r2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 427 416 if (!r2) { 428 417 dev_err(&pdev->dev, "failed to get memory resource\n"); 429 - error = -ENODEV; 430 - goto fail_unmap_control; 418 + return -ENODEV; 431 419 } 432 420 433 - r2 = request_mem_region(r2->start, resource_size(r2), pdev->name); 434 - if (!r2) { 435 - dev_err(&pdev->dev, "cannot request memory region\n"); 436 - error = -EBUSY; 437 - goto fail_unmap_control; 438 - } 439 - 440 - wdt->feed_reg = ioremap(r2->start, resource_size(r2)); 441 - if (!wdt->feed_reg) { 442 - dev_err(&pdev->dev, "failed to map memory\n"); 443 - error = -ENODEV; 444 - goto fail_free_feed; 445 - } 421 + wdt->feed_reg = devm_ioremap_resource(&pdev->dev, r2); 422 + if (IS_ERR(wdt->feed_reg)) 423 + return PTR_ERR(wdt->feed_reg); 446 424 447 425 platform_set_drvdata(pdev, wdt); 448 426 ts72xx_wdt_pdev = pdev; ··· 433 455 error = misc_register(&ts72xx_wdt_miscdev); 434 456 if (error) { 435 457 dev_err(&pdev->dev, "failed to register miscdev\n"); 436 - goto fail_unmap_feed; 458 + return error; 437 459 } 438 460 439 461 dev_info(&pdev->dev, "TS-72xx Watchdog driver\n"); 440 462 441 463 return 0; 442 - 443 - fail_unmap_feed: 444 - platform_set_drvdata(pdev, NULL); 445 - iounmap(wdt->feed_reg); 446 - fail_free_feed: 447 - release_mem_region(r2->start, resource_size(r2)); 448 - fail_unmap_control: 449 - iounmap(wdt->control_reg); 450 - fail_free_control: 451 - release_mem_region(r1->start, resource_size(r1)); 452 - fail: 453 - kfree(wdt); 454 - return error; 455 464 } 456 465 457 466 static int ts72xx_wdt_remove(struct platform_device *pdev) 458 467 { 459 - struct ts72xx_wdt *wdt = platform_get_drvdata(pdev); 460 - struct resource *res; 461 468 int error; 462 469 463 470 error = misc_deregister(&ts72xx_wdt_miscdev); 464 - platform_set_drvdata(pdev, NULL); 465 471 466 - iounmap(wdt->feed_reg); 467 - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 468 - release_mem_region(res->start, resource_size(res)); 469 - 470 - iounmap(wdt->control_reg); 471 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 472 - release_mem_region(res->start, resource_size(res)); 473 - 474 - kfree(wdt); 475 472 return error; 476 473 } 477 474
+1 -4
drivers/watchdog/twl4030_wdt.c
··· 90 90 twl4030_wdt_stop(wdt); 91 91 92 92 ret = watchdog_register_device(wdt); 93 - if (ret) { 94 - platform_set_drvdata(pdev, NULL); 93 + if (ret) 95 94 return ret; 96 - } 97 95 98 96 return 0; 99 97 } ··· 101 103 struct watchdog_device *wdt = platform_get_drvdata(pdev); 102 104 103 105 watchdog_unregister_device(wdt); 104 - platform_set_drvdata(pdev, NULL); 105 106 106 107 return 0; 107 108 }
+4 -2
drivers/watchdog/watchdog_dev.c
··· 469 469 * or if WDIOF_MAGICCLOSE is not set. If nowayout was set then 470 470 * watchdog_stop will fail. 471 471 */ 472 - if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) || 473 - !(wdd->info->options & WDIOF_MAGICCLOSE)) 472 + if (!test_bit(WDOG_ACTIVE, &wdd->status)) 473 + err = 0; 474 + else if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) || 475 + !(wdd->info->options & WDIOF_MAGICCLOSE)) 474 476 err = watchdog_stop(wdd); 475 477 476 478 /* If the watchdog was not stopped, send a keepalive ping */
+3 -26
drivers/watchdog/wdrtas.c
··· 162 162 } 163 163 164 164 /** 165 - * wdrtas_log_scanned_event - logs an event we received during keepalive 166 - * 167 - * wdrtas_log_scanned_event prints a message to the log buffer dumping 168 - * the results of the last event-scan call 169 - */ 170 - static void wdrtas_log_scanned_event(void) 171 - { 172 - int i; 173 - 174 - for (i = 0; i < WDRTAS_LOGBUFFER_LEN; i += 16) 175 - pr_info("dumping event (line %i/%i), data = " 176 - "%02x %02x %02x %02x %02x %02x %02x %02x " 177 - "%02x %02x %02x %02x %02x %02x %02x %02x\n", 178 - (i / 16) + 1, (WDRTAS_LOGBUFFER_LEN / 16), 179 - wdrtas_logbuffer[i + 0], wdrtas_logbuffer[i + 1], 180 - wdrtas_logbuffer[i + 2], wdrtas_logbuffer[i + 3], 181 - wdrtas_logbuffer[i + 4], wdrtas_logbuffer[i + 5], 182 - wdrtas_logbuffer[i + 6], wdrtas_logbuffer[i + 7], 183 - wdrtas_logbuffer[i + 8], wdrtas_logbuffer[i + 9], 184 - wdrtas_logbuffer[i + 10], wdrtas_logbuffer[i + 11], 185 - wdrtas_logbuffer[i + 12], wdrtas_logbuffer[i + 13], 186 - wdrtas_logbuffer[i + 14], wdrtas_logbuffer[i + 15]); 187 - } 188 - 189 - /** 190 165 * wdrtas_timer_keepalive - resets watchdog timer to keep system alive 191 166 * 192 167 * wdrtas_timer_keepalive restarts the watchdog timer by calling the ··· 180 205 if (result < 0) 181 206 pr_err("event-scan failed: %li\n", result); 182 207 if (result == 0) 183 - wdrtas_log_scanned_event(); 208 + print_hex_dump(KERN_INFO, "dumping event, data: ", 209 + DUMP_PREFIX_OFFSET, 16, 1, 210 + wdrtas_logbuffer, WDRTAS_LOGBUFFER_LEN, false); 184 211 } while (result == 0); 185 212 } 186 213
+8 -13
drivers/watchdog/wm831x_wdt.c
··· 247 247 reg |= pdata->software << WM831X_WDOG_RST_SRC_SHIFT; 248 248 249 249 if (pdata->update_gpio) { 250 - ret = gpio_request_one(pdata->update_gpio, 251 - GPIOF_DIR_OUT | GPIOF_INIT_LOW, 252 - "Watchdog update"); 250 + ret = devm_gpio_request_one(&pdev->dev, 251 + pdata->update_gpio, 252 + GPIOF_OUT_INIT_LOW, 253 + "Watchdog update"); 253 254 if (ret < 0) { 254 255 dev_err(wm831x->dev, 255 256 "Failed to request update GPIO: %d\n", ··· 271 270 } else { 272 271 dev_err(wm831x->dev, 273 272 "Failed to unlock security key: %d\n", ret); 274 - goto err_gpio; 273 + goto err; 275 274 } 276 275 } 277 276 ··· 279 278 if (ret != 0) { 280 279 dev_err(wm831x->dev, "watchdog_register_device() failed: %d\n", 281 280 ret); 282 - goto err_gpio; 281 + goto err; 283 282 } 284 283 285 - dev_set_drvdata(&pdev->dev, driver_data); 284 + platform_set_drvdata(pdev, driver_data); 286 285 287 286 return 0; 288 287 289 - err_gpio: 290 - if (driver_data->update_gpio) 291 - gpio_free(driver_data->update_gpio); 292 288 err: 293 289 return ret; 294 290 } 295 291 296 292 static int wm831x_wdt_remove(struct platform_device *pdev) 297 293 { 298 - struct wm831x_wdt_drvdata *driver_data = dev_get_drvdata(&pdev->dev); 294 + struct wm831x_wdt_drvdata *driver_data = platform_get_drvdata(pdev); 299 295 300 296 watchdog_unregister_device(&driver_data->wdt); 301 - 302 - if (driver_data->update_gpio) 303 - gpio_free(driver_data->update_gpio); 304 297 305 298 return 0; 306 299 }