watchdog - v3.5 Merge window part 2
Subsystems (5)
Hi Linus,
Please pull from 'master' branch of
git://www.linux-watchdog.org/linux-watchdog.git
This changeset contains following changes:
* Add support for multiple watchdog devices. We use dynamically allocated device id's for this.
* Add locking into the generic watchdog infrastructure.
* Add support for dynamically allocated watchdog_device structs so that we can deal with devices that get unbound.
* convert following drivers to the generic watchdog framework:
sch5627, sch5636 and sp805_wdt.
* Add DA9052/53 PMIC watchdog support
* Fix printk format warnings for iTCO_wdt.c
This will update the following files:
b/Documentation/watchdog/watchdog-kernel-api.txt | 43 ++ b/Documentation/watchdog/watchdog-parameters.txt | 5 b/drivers/hwmon/Kconfig | 6 b/drivers/hwmon/sch5627.c | 2 b/drivers/hwmon/sch5636.c | 2 b/drivers/hwmon/sch56xx-common.c | 406 ++++------------------- b/drivers/hwmon/sch56xx-common.h | 2 b/drivers/watchdog/Kconfig | 13 b/drivers/watchdog/Makefile | 1 b/drivers/watchdog/da9052_wdt.c | 251 ++++++++++++++ b/drivers/watchdog/iTCO_wdt.c | 6 b/drivers/watchdog/sp805_wdt.c | 249 +++++--------- b/drivers/watchdog/via_wdt.c | 2 b/drivers/watchdog/watchdog_core.c | 74 +++- b/drivers/watchdog/watchdog_core.h | 37 ++ b/drivers/watchdog/watchdog_dev.c | 375 ++++++++++++++++----- b/include/linux/watchdog.h | 28 + drivers/watchdog/watchdog_dev.h | 33 - 18 files changed, 922 insertions(+), 613 deletions(-)
with these Changes:
commit 4b98b32aefb2c143a40cdaa254eb905f1bb06b5d
Author: Randy Dunlap <[email protected]> Date: Mon May 14 13:15:20 2012 -0700
watchdog: iTCO_wdt.c: fix printk format warnings
Fix printk format warnings:
drivers/watchdog/iTCO_wdt.c:577:3: warning: format '%04llx' expects type 'long long unsigned int', but argument 2 has type 'resource_size_t' drivers/watchdog/iTCO_wdt.c:594:3: warning: format '%04llx' expects type 'long long unsigned int', but argument 2 has type 'resource_size_t' drivers/watchdog/iTCO_wdt.c:600:2: warning: format '%04llx' expects type 'long long unsigned int', but argument 4 has type 'resource_size_t'
commit d9df0ef1eb9e1048f0ab4a6e93c85f60c5594c2f
Author: Viresh Kumar <[email protected]> Date: Mon Mar 12 09:52:17 2012 +0530
watchdog: sp805_wdt: Add clk_{un}prepare support
clk_{un}prepare() routines are required for required on some platforms to run part of clk enable/disable() routines from contexts that can schedule.
This patch adds support for these routines in sp805 driver.
commit 4a516539faba13deca2399cff8faaa84d251a4ea
Author: Viresh Kumar <[email protected]> Date: Mon Mar 12 09:52:16 2012 +0530
watchdog: sp805_wdt: convert to watchdog core
This patch converts existing sp805 watchdog driver to use already in place common infrastructure present in watchdog core. With this lot of code goes away.
commit 2d8c7ff52c2459a25034ac8ddc230e67cc0e2b67
Author: Hans de Goede <[email protected]> Date: Thu May 24 22:18:58 2012 +0200
hwmon/sch56xx: Depend on watchdog for watchdog core functions
Since the watchdog code in sch56xx-common now uses the watchdog core, the Kconfig entires for the sch5627 and sch5636 should depend on WATCHDOG being set. Also select the watchdog core when we select one of the drivers.
commit bb644913a7d6dabcc4a1640817fa7b68938a56eb
Author: Dan Carpenter <[email protected]> Date: Thu May 24 18:58:02 2012 +0300
watchdog: sch56xx-common: set correct bits in register()
WDOG_NO_WAY_OUT (3) and WDOG_ACTIVE (0) are the bit numbers, not a mask. So "data->wddev.status |= WDOG_ACTIVE;" was intended to set bit zero but it is a no-op.
commit 664a0d7862a6b10c709d4b4a3655fe2c59a20064
Author: Ashish Jangam <[email protected]> Date: Thu May 24 18:31:14 2012 +0530
Watchdog: DA9052/53 PMIC watchdog support
This driver adds support for the watchdog functionality provided by the Dialog Semiconductor DA9052 PMIC chip.
Tested on samsung smdkv6410 and i.mx53 QS boards.
commit 54e2dc9341aca23d5241699e3b74c8dce609fa2d
Author: Hans de Goede <[email protected]> Date: Tue May 22 11:40:27 2012 +0200
watchdog: sch56xx-common: Add proper ref-counting of watchdog data
This fixes referencing free-ed memory in the corner case where /dev/watchdog is open when the platform driver gets unbound from the platform device.
commit 85a2e40cb5053574cd3b1f33c00194309ce3704c
Author: Hans de Goede <[email protected]> Date: Tue May 22 11:40:25 2012 +0200
watchdog: sch56xx: Remove unnecessary checks for register changes
Since the watchdog core keeps track of the watchdog's active state, start/stop will never get called when no changes are necessary. So we can remove the check for the output_enable register changing before writing it (which is an expensive operation).
commit fb551405c0f8e15d6fc7ae6e16a5e15382f8b8ac
Author: Hans de Goede <[email protected]> Date: Tue May 22 11:40:24 2012 +0200
watchdog: sch56xx: Use watchdog core
Convert sch56xx drivers to the generic watchdog core.
Note this patch depends on the "watchdog: Add multiple device support" patch from Alan Cox.
commit e907df32725204d6d2cb79b872529911c8eadcdf
Author: Hans de Goede <[email protected]> Date: Tue May 22 11:40:26 2012 +0200
watchdog: Add support for dynamically allocated watchdog_device structs
If a driver's watchdog_device struct is part of a dynamically allocated struct (which it often will be), merely locking the module is not enough, even with a drivers module locked, the driver can be unbound from the device, examples:
1) The root user can unbind it through sysfd
2) The i2c bus master driver being unloaded for an i2c watchdog
I will gladly admit that these are corner cases, but we still need to handle them correctly.
The fix for this consists of 2 parts:
1) Add ref / unref operations, so that the driver can refcount the struct holding the watchdog_device struct and delay freeing it until any open filehandles referring to it are closed
2) Most driver operations will do IO on the device and the driver should not do any IO on the device after it has been unbound. Rather then letting each driver deal with this internally, it is better to ensure at the watchdog core level that no operations (other then unref) will get called after the driver has called watchdog_unregister_device(). This actually is the bulk of this patch.
commit f4e9c82f64b524314a390b13d3ba7d483f09258f
Author: Hans de Goede <[email protected]> Date: Tue May 22 11:40:26 2012 +0200
watchdog: Add Locking support
This patch fixes some potential multithreading issues, despite only allowing one process to open the /dev/watchdog device, we can still get called multiple times at the same time, since a program could be using thread, or could share the fd after a fork.
This causes 2 potential problems:
1) watchdog_start / open do an unlocked test_n_set / test_n_clear, if these 2 race, the watchdog could be stopped while the active bit indicates it is running or visa versa.
2) Most watchdog_dev drivers probably assume that only one watchdog-op will get called at a time, this is not necessary true atm.
commit 7a87982420e5e126bfefeb42232d1fd92052794e
Author: Hans de Goede <[email protected]> Date: Tue May 22 11:40:26 2012 +0200
watchdog: watchdog_dev: Rewrite wrapper code
Rewrite and extend the wrapper code so that we can easily introduce locking (this to be able to prevent potential multithreading issues).
commit 3dfd6218da4cb9d0eae596581a08de9959aa2b1f
Author: Alan Cox <[email protected]> Date: Fri May 11 12:00:22 2012 +0200
watchdog: use dev_ functions
While they are registered all our watchdogs now have a valid device object so we can in turn use that to report problems nicely.
commit d6b469d915ae348b3bb8b25034063d6870ff4a00
Author: Alan Cox <[email protected]> Date: Fri May 11 12:00:20 2012 +0200
watchdog: create all the proper device files
Create the watchdog class and it's associated devices.
commit 2bbeed016dd96045ec82c3a309afddcc3a0db1d2
Author: Alan Cox <[email protected]> Date: Fri May 11 12:00:19 2012 +0200
watchdog: Add a flag to indicate the watchdog doesn't reboot things
Some watchdogs merely trigger external alarms and controls. In a managed environment this is very useful but we want drivers to be able to figure out which is which now multiple dogs can be loaded. Thus add an ALARMONLY feature flag.
commit 45f5fed30a6460ec58f159ff297a2974153a97de
Author: Alan Cox <[email protected]> Date: Thu May 10 21:48:59 2012 +0200
watchdog: Add multiple device support
We keep the old /dev/watchdog interface file for the first watchdog via miscdev. This is basically a cut and paste of the relevant interface code from the rtc driver layer tweaked for watchdog.
Revised to fix problems noted by Hans de Goede
commit fb5f6658163412dce22724e906e324ab7fd62c18
Author: Wim Van Sebroeck <[email protected]> Date: Mon May 21 15:33:05 2012 +0200
watchdog: watchdog_core.h: make functions extern
Make the functions in watchdog_core.h extern like it should.
commit 6cfb5aa836884bcd66e2c5d0a101e97ba78aaafd
Author: Wim Van Sebroeck <[email protected]> Date: Mon May 21 15:31:06 2012 +0200
watchdog: correct the name of the watchdog_core inlude file
The watchdog_core include file should have been named watchdog_core.h and not watchdog_dev.h . Correct this.
commit 257f8c4aae392654d4ab846030b9f4518f16ed32
Author: Viresh Kumar <[email protected]> Date: Mon Mar 12 09:51:56 2012 +0530
watchdog: Add watchdog_active() routine
Some watchdog may need to check if watchdog is ACTIVE or not, for example in their suspend/resume hooks.
This patch adds this routine and changes the core drivers to use it.
commit 09a46e739780aab2eadf47afdefa70c9cd69d83d
Author: H Hartley Sweeten <[email protected]> Date: Fri Apr 20 13:28:24 2012 -0700
watchdog: watchdog_dev: include private header to pickup global symbol prototypes
Include the private watchdog_dev.h header to pickup the prototypes for the watchdog_dev_register/unregister functions.
This quiets the following sparse warnings:
warning: symbol 'watchdog_dev_register' was not declared. Should it be static?
warning: symbol 'watchdog_dev_unregister' was not declared. Should it be static?
For completeness, I added the overal diff below.
Greetings,
Wim.
================================================================================
Documentation/watchdog/watchdog-kernel-api.txt +42 -1
@@ -1,6 +1,6 @@ The Linux WatchDog Timer Driver Core kernel API. =============================================== -Last reviewed: 16-Mar-2012 +Last reviewed: 22-May-2012 Wim Van Sebroeck <[email protected]>
@@ -39,6 +39,10 @@ watchdog_device structure. The watchdog device structure looks like this: struct watchdog_device { + int id; + struct cdev cdev; + struct device *dev; + struct device *parent; const struct watchdog_info *info; const struct watchdog_ops *ops; unsigned int bootstatus;
@@ -46,10 +50,20 @@ struct watchdog_device { unsigned int min_timeout; unsigned int max_timeout; void *driver_data; + struct mutex lock; unsigned long status; }; It contains following fields: +* id: set by watchdog_register_device, id 0 is special. It has both a + /dev/watchdog0 cdev (dynamic major, minor 0) as well as the old + /dev/watchdog miscdev. The id is set automatically when calling + watchdog_register_device. +* cdev: cdev for the dynamic /dev/watchdog<id> device nodes. This + field is also populated by watchdog_register_device. +* dev: device under the watchdog class (created by watchdog_register_device). +* parent: set this to the parent device (or NULL) before calling + watchdog_register_device. * info: a pointer to a watchdog_info structure. This structure gives some additional information about the watchdog timer itself. (Like it's unique name) * ops: a pointer to the list of watchdog operations that the watchdog supports.
@@ -61,6 +75,7 @@ It contains following fields: * driver_data: a pointer to the drivers private data of a watchdog device. This data should only be accessed via the watchdog_set_drvdata and watchdog_get_drvdata routines. +* lock: Mutex for WatchDog Timer Driver Core internal use only. * status: this field contains a number of status bits that give extra information about the status of the device (Like: is the watchdog timer running/active, is the nowayout bit set, is the device opened via
@@ -78,6 +93,8 @@ struct watchdog_ops { unsigned int (*status)(struct watchdog_device *); int (*set_timeout)(struct watchdog_device *, unsigned int); unsigned int (*get_timeleft)(struct watchdog_device *); + void (*ref)(struct watchdog_device *); + void (*unref)(struct watchdog_device *); long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); };
@@ -85,6 +102,21 @@ It is important that you first define the module owner of the watchdog timer driver's operations. This module owner will be used to lock the module when the watchdog is active. (This to avoid a system crash when you unload the module and /dev/watchdog is still open). + +If the watchdog_device struct is dynamically allocated, just locking the module +is not enough and a driver also needs to define the ref and unref operations to +ensure the structure holding the watchdog_device does not go away. + +The simplest (and usually sufficient) implementation of this is to: +1) Add a kref struct to the same structure which is holding the watchdog_device +2) Define a release callback for the kref which frees the struct holding both +3) Call kref_init on this kref *before* calling watchdog_register_device() +4) Define a ref operation calling kref_get on this kref +5) Define a unref operation calling kref_put on this kref +6) When it is time to cleanup: + * Do not kfree() the struct holding both, the last kref_put will do this! + * *After* calling watchdog_unregister_device() call kref_put on the kref + Some operations are mandatory and some are optional. The mandatory operations are: * start: this is a pointer to the routine that starts the watchdog timer
@@ -125,6 +157,10 @@ they are supported. These optional routines/operations are: (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the watchdog's info structure). * get_timeleft: this routines returns the time that's left before a reset. +* ref: the operation that calls kref_get on the kref of a dynamically + allocated watchdog_device struct. +* unref: the operation that calls kref_put on the kref of a dynamically + allocated watchdog_device struct. * ioctl: if this routine is present then it will be called first before we do our own internal ioctl call handling. This routine should return -ENOIOCTLCMD if a command is not supported. The parameters that are passed to the ioctl
@@ -144,6 +180,11 @@ bit-operations. The status bits that are defined are: (This bit should only be used by the WatchDog Timer Driver Core). * WDOG_NO_WAY_OUT: this bit stores the nowayout setting for the watchdog. If this bit is set then the watchdog timer will not be able to stop. +* WDOG_UNREGISTERED: this bit gets set by the WatchDog Timer Driver Core + after calling watchdog_unregister_device, and then checked before calling + any watchdog_ops, so that you can be sure that no operations (other then + unref) will get called after unregister, even if userspace still holds a + reference to /dev/watchdog To set the WDOG_NO_WAY_OUT status bit (before registering your watchdog timer device) you can either:
Documentation/watchdog/watchdog-parameters.txt +5 -0
@@ -78,6 +78,11 @@ wd0_timeout: Default watchdog0 timeout in 1/10secs wd1_timeout: Default watchdog1 timeout in 1/10secs wd2_timeout: Default watchdog2 timeout in 1/10secs ------------------------------------------------- +da9052wdt: +timeout: Watchdog timeout in seconds. 2<= timeout <=131, default=2.048s +nowayout: Watchdog cannot be stopped once started + (default=kernel config parameter) +------------------------------------------------- davinci_wdt: heartbeat: Watchdog heartbeat period in seconds from 1 to 600, default 60 -------------------------------------------------
drivers/hwmon/Kconfig +4 -2
@@ -1036,8 +1036,9 @@ config SENSORS_SCH56XX_COMMON config SENSORS_SCH5627 tristate "SMSC SCH5627" - depends on !PPC + depends on !PPC && WATCHDOG select SENSORS_SCH56XX_COMMON + select WATCHDOG_CORE help If you say yes here you get support for the hardware monitoring features of the SMSC SCH5627 Super-I/O chip including support for
@@ -1048,8 +1049,9 @@ config SENSORS_SCH5627 config SENSORS_SCH5636 tristate "SMSC SCH5636" - depends on !PPC + depends on !PPC && WATCHDOG select SENSORS_SCH56XX_COMMON + select WATCHDOG_CORE help SMSC SCH5636 Super I/O chips include an embedded microcontroller for hardware monitoring solutions, allowing motherboard manufacturers to
drivers/hwmon/sch5627.c +1 -1
@@ -579,7 +579,7 @@ static int __devinit sch5627_probe(struct platform_device *pdev) }/* Note failing to register the watchdog is not a fatal error */ - data->watchdog =sch56xx_watchdog_register (data->addr, + data->watchdog =sch56xx_watchdog_register (&pdev->dev, data->addr, (build_code <<24 ) | (build_id <<8 ) | hwmon_rev, &data->update_lock,1 );
drivers/hwmon/sch5636.c +1 -1
@@ -510,7 +510,7 @@ static int __devinit sch5636_probe(struct platform_device *pdev) }/* Note failing to register the watchdog is not a fatal error */ - data->watchdog =sch56xx_watchdog_register (data->addr, + data->watchdog =sch56xx_watchdog_register (&pdev->dev, data->addr, (revision[0 ] <<8 ) | revision[1 ], &data->update_lock,0 );
drivers/hwmon/sch56xx-common.c +85 -321
528 lines not on this page · raw message
drivers/hwmon/sch56xx-common.h +1 -1
@@ -27,6 +27,6 @@ int sch56xx_read_virtual_reg16(u16 addr, u16 reg);int sch56xx_read_virtual_reg12 (u16 addr,u16 msb_reg,u16 lsn_reg,int high_nibble); -struct sch56xx_watchdog_data *sch56xx_watchdog_register ( +struct sch56xx_watchdog_data *sch56xx_watchdog_register (struct device *parent,u16 addr,u32 revision,struct mutex *io_lock,int check_enabled);void sch56xx_watchdog_unregister (struct sch56xx_watchdog_data *data);
drivers/watchdog/Kconfig +13 -0
@@ -64,6 +64,18 @@ config SOFT_WATCHDOG To compile this driver as a module, choose M here: the module will be called softdog. +config DA9052_WATCHDOG + tristate "Dialog DA9052 Watchdog" + depends on PMIC_DA9052 + select WATCHDOG_CORE + help + Support for the watchdog in the DA9052 PMIC. Watchdog trigger + cause system reset. + + Say Y here to include support for the DA9052 watchdog. + Alternatively say M to compile the driver as a module, + which will be called da9052_wdt. + config WM831X_WATCHDOG tristate "WM831x watchdog" depends on MFD_WM831X
@@ -87,6 +99,7 @@ config WM8350_WATCHDOG config ARM_SP805_WATCHDOG tristate "ARM SP805 Watchdog" depends on ARM_AMBA + select WATCHDOG_CORE help ARM Primecell SP805 Watchdog timer. This will reboot your system when the timeout is reached.
drivers/watchdog/Makefile +1 -0
@@ -163,6 +163,7 @@ obj-$(CONFIG_WATCHDOG_CP1XXX) += cpwd.o obj-$(CONFIG_XEN_WDT) += xen_wdt.o # Architecture Independent +obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o obj-$(CONFIG_MAX63XX_WATCHDOG) += max63xx_wdt.o
drivers/watchdog/da9052_wdt.c new file +251 -0
251 lines not on this page · raw message
drivers/watchdog/iTCO_wdt.c +3 -3
@@ -575,7 +575,7 @@ static int __devinit iTCO_wdt_probe(struct platform_device *dev)if (!request_region (iTCO_wdt_private.smi_res->start,resource_size (iTCO_wdt_private.smi_res), dev->name)) {pr_err ("I/O address 0x%04llx already in use, device disabled\n" , -SMI_EN ); + (u64 )SMI_EN ); ret = -EBUSY ; goto unmap_gcs; }
@@ -592,13 +592,13 @@ static int __devinit iTCO_wdt_probe(struct platform_device *dev)if (!request_region (iTCO_wdt_private.tco_res->start,resource_size (iTCO_wdt_private.tco_res), dev->name)) {pr_err ("I/O address 0x%04llx already in use, device disabled\n" , -TCOBASE ); + (u64 )TCOBASE ); ret = -EBUSY ; goto unreg_smi; }pr_info ("Found a %s TCO device (Version=%d, TCOBASE=0x%04llx)\n" , - ich_info->name, ich_info->iTCO_version,TCOBASE ); + ich_info->name, ich_info->iTCO_version, (u64 )TCOBASE );/* Clear out the (probably old) status */ outw (0x0008 ,TCO1_STS );/* Clear the Time Out Status bit */
drivers/watchdog/sp805_wdt.c +90 -159
382 lines not on this page · raw message
drivers/watchdog/via_wdt.c +1 -1
@@ -91,7 +91,7 @@ static inline void wdt_reset(void)static void wdt_timer_tick (unsigned long data) {if (time_before (jiffies, next_heartbeat) || - (!test_bit (WDOG_ACTIVE , &wdt_dev.status))) { + (!watchdog_active (&wdt_dev))) {wdt_reset ();mod_timer (&timer, jiffies +WDT_HEARTBEAT ); }else
drivers/watchdog/watchdog_core.c +70 -4
110 lines not on this page · raw message
drivers/watchdog/watchdog_core.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* watchdog_core.h +* +* (c) Copyright 2008-2011 Alan Cox <[email protected]>, +* All Rights Reserved. +* +* (c) Copyright 2008-2011 Wim Van Sebroeck <[email protected]>. +* +* This source code is part of the generic code that can be used +* by all the watchdog timer drivers. +* +* Based on source code of the following authors: +* Matt Domsch <[email protected]>, +* Rob Radez <[email protected]>, +* Rusty Lynch <[email protected]> +* Satyam Sharma <[email protected]> +* Randy Dunlap <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +* +* Neither Alan Cox, CymruNet Ltd., Wim Van Sebroeck nor Iguana vzw. +* admit liability nor provide warranty for any of this software. +* This material is provided "AS-IS" and at no charge. +*/ + +#define MAX_DOGS 32/* Maximum number of watchdog devices */ + +/* +* Functions/procedures to be called by the core +*/ +extern int watchdog_dev_register (struct watchdog_device *); +extern int watchdog_dev_unregister (struct watchdog_device *); +extern int __init watchdog_dev_init (void ); +extern void __exit watchdog_dev_exit(void);
drivers/watchdog/watchdog_dev.c +289 -86
517 lines not on this page · raw message
drivers/watchdog/watchdog_dev.h deleted +0 -33
@@ -1,33 +0,0 @@ -/* -* watchdog_core.h -* -* (c) Copyright 2008-2011 Alan Cox <[email protected]>, -* All Rights Reserved. -* -* (c) Copyright 2008-2011 Wim Van Sebroeck <[email protected]>. -* -* This source code is part of the generic code that can be used -* by all the watchdog timer drivers. -* -* Based on source code of the following authors: -* Matt Domsch <[email protected]>, -* Rob Radez <[email protected]>, -* Rusty Lynch <[email protected]> -* Satyam Sharma <[email protected]> -* Randy Dunlap <[email protected]> -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version -* 2 of the License, or (at your option) any later version. -* -* Neither Alan Cox, CymruNet Ltd., Wim Van Sebroeck nor Iguana vzw. -* admit liability nor provide warranty for any of this software. -* This material is provided "AS-IS" and at no charge. -*/ - -/* -* Functions/procedures to be called by the core -*/ -int watchdog_dev_register (struct watchdog_device *); -int watchdog_dev_unregister (struct watchdog_device *);
include/linux/watchdog.h +28 -0
@@ -45,6 +45,8 @@ struct watchdog_info {#define WDIOF_SETTIMEOUT 0x0080/* Set timeout (in seconds) */ #define WDIOF_MAGICCLOSE 0x0100/* Supports magic close char */ #define WDIOF_PRETIMEOUT 0x0200/* Pretimeout (in seconds), get/set */ +#define WDIOF_ALARMONLY 0x0400/* Watchdog triggers a management or +other external alarm not a reboot */ #define WDIOF_KEEPALIVEPING 0x8000/* Keep alive ping reply */ #define WDIOS_DISABLECARD 0x0001/* Turn off the watchdog timer */
@@ -54,6 +56,8 @@ struct watchdog_info {#ifdef __KERNEL__#include <linux/bitops.h> +#include <linux/device.h> +#include <linux/cdev.h> struct watchdog_ops ;struct watchdog_device ;
@@ -67,6 +71,8 @@ struct watchdog_device;* @status: The routine that shows the status of the watchdog device. * @set_timeout:The routine for setting the watchdog devices timeout value. * @get_timeleft:The routine that get's the time that's left before a reset. +* @ref: The ref operation for dyn. allocated watchdog_device structs +* @unref: The unref operation for dyn. allocated watchdog_device structs * @ioctl: The routines that handles extra ioctl calls. * * The watchdog_ops structure contains a list of low-level operations
@@ -84,11 +90,17 @@ struct watchdog_ops {unsigned int (*status)(struct watchdog_device *);int (*set_timeout)(struct watchdog_device *,unsigned int );unsigned int (*get_timeleft)(struct watchdog_device *); +void (*ref)(struct watchdog_device *); +void (*unref)(struct watchdog_device *);long (*ioctl)(struct watchdog_device *,unsigned int ,unsigned long ); };/** struct watchdog_device - The structure that defines a watchdog device * +* @id: The watchdog's ID. (Allocated by watchdog_register_device) +* @cdev: The watchdog's Character device. +* @dev: The device for our watchdog +* @parent: The parent bus device * @info: Pointer to a watchdog_info structure. * @ops: Pointer to the list of watchdog operations. * @bootstatus: Status of the watchdog device at boot.
@@ -96,6 +108,7 @@ struct watchdog_ops {* @min_timeout:The watchdog devices minimum timeout value. * @max_timeout:The watchdog devices maximum timeout value. * @driver-data:Pointer to the drivers private data. +* @lock: Lock for watchdog core internal use only. * @status: Field that contains the devices internal status bits. * * The watchdog_device structure contains all information about a
@@ -103,8 +116,15 @@ struct watchdog_ops {* * The driver-data field may not be accessed directly. It must be accessed * via the watchdog_set_drvdata and watchdog_get_drvdata helpers. +* +* The lock field is for watchdog core internal use only and should not be +* touched. */ struct watchdog_device { +int id; +struct cdev cdev; +struct device *dev; +struct device *parent;const struct watchdog_info *info;const struct watchdog_ops *ops;unsigned int bootstatus;
@@ -112,12 +132,14 @@ struct watchdog_device {unsigned int min_timeout;unsigned int max_timeout;void *driver_data; +struct mutex lock;unsigned long status;/* Bit numbers for status flags */ #define WDOG_ACTIVE 0/* Is the watchdog running/active */ #define WDOG_DEV_OPEN 1/* Opened via /dev/watchdog ? */ #define WDOG_ALLOW_RELEASE 2/* Did we receive the magic char ? */ #define WDOG_NO_WAY_OUT 3/* Is 'nowayout' feature set ? */ +#define WDOG_UNREGISTERED 4/* Has the device been unregistered */ };#ifdef CONFIG_WATCHDOG_NOWAYOUT
@@ -128,6 +150,12 @@ struct watchdog_device {#define WATCHDOG_NOWAYOUT_INIT_STATUS 0#endif +/* Use the following function to check wether or not the watchdog is active */ +static inline bool watchdog_active (struct watchdog_device *wdd) +{ +return test_bit (WDOG_ACTIVE , &wdd->status); +} +/* Use the following function to set the nowayout feature */ static inline void watchdog_set_nowayout (struct watchdog_device *wdd,bool nowayout) {