diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-30 12:59:13 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-30 12:59:13 -0400 |
| commit | 19ce0a995ff230b364c7329fd488c70e91c171d9 (patch) | |
| tree | e24fe57a87d16a54cbffd087fb6af2083f7f2ad0 /include/linux | |
| parent | 6bb340c7868fbfd7bd0e8a0e23397a2bcb528429 (diff) | |
| parent | 4b98b32aefb2c143a40cdaa254eb905f1bb06b5d (diff) | |
Merge git://www.linux-watchdog.org/linux-watchdog
Pull second set of watchdog updates from Wim Van Sebroeck:
"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"
* git://www.linux-watchdog.org/linux-watchdog:
watchdog: iTCO_wdt.c: fix printk format warnings
watchdog: sp805_wdt: Add clk_{un}prepare support
watchdog: sp805_wdt: convert to watchdog core
hwmon/sch56xx: Depend on watchdog for watchdog core functions
watchdog: sch56xx-common: set correct bits in register()
Watchdog: DA9052/53 PMIC watchdog support
watchdog: sch56xx-common: Add proper ref-counting of watchdog data
watchdog: sch56xx: Remove unnecessary checks for register changes
watchdog: sch56xx: Use watchdog core
watchdog: Add support for dynamically allocated watchdog_device structs
watchdog: Add Locking support
watchdog: watchdog_dev: Rewrite wrapper code
watchdog: use dev_ functions
watchdog: create all the proper device files
watchdog: Add a flag to indicate the watchdog doesn't reboot things
watchdog: Add multiple device support
watchdog: watchdog_core.h: make functions extern
watchdog: correct the name of the watchdog_core inlude file
watchdog: Add watchdog_active() routine
watchdog: watchdog_dev: include private header to pickup global symbol prototypes
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/watchdog.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index ac40716b44e9..da70f0facd2b 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h | |||
| @@ -45,6 +45,8 @@ struct watchdog_info { | |||
| 45 | #define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ | 45 | #define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ |
| 46 | #define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ | 46 | #define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ |
| 47 | #define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */ | 47 | #define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */ |
| 48 | #define WDIOF_ALARMONLY 0x0400 /* Watchdog triggers a management or | ||
| 49 | other external alarm not a reboot */ | ||
| 48 | #define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */ | 50 | #define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */ |
| 49 | 51 | ||
| 50 | #define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */ | 52 | #define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */ |
| @@ -54,6 +56,8 @@ struct watchdog_info { | |||
| 54 | #ifdef __KERNEL__ | 56 | #ifdef __KERNEL__ |
| 55 | 57 | ||
| 56 | #include <linux/bitops.h> | 58 | #include <linux/bitops.h> |
| 59 | #include <linux/device.h> | ||
| 60 | #include <linux/cdev.h> | ||
| 57 | 61 | ||
| 58 | struct watchdog_ops; | 62 | struct watchdog_ops; |
| 59 | struct watchdog_device; | 63 | struct watchdog_device; |
| @@ -67,6 +71,8 @@ struct watchdog_device; | |||
| 67 | * @status: The routine that shows the status of the watchdog device. | 71 | * @status: The routine that shows the status of the watchdog device. |
| 68 | * @set_timeout:The routine for setting the watchdog devices timeout value. | 72 | * @set_timeout:The routine for setting the watchdog devices timeout value. |
| 69 | * @get_timeleft:The routine that get's the time that's left before a reset. | 73 | * @get_timeleft:The routine that get's the time that's left before a reset. |
| 74 | * @ref: The ref operation for dyn. allocated watchdog_device structs | ||
| 75 | * @unref: The unref operation for dyn. allocated watchdog_device structs | ||
| 70 | * @ioctl: The routines that handles extra ioctl calls. | 76 | * @ioctl: The routines that handles extra ioctl calls. |
| 71 | * | 77 | * |
| 72 | * The watchdog_ops structure contains a list of low-level operations | 78 | * The watchdog_ops structure contains a list of low-level operations |
| @@ -84,11 +90,17 @@ struct watchdog_ops { | |||
| 84 | unsigned int (*status)(struct watchdog_device *); | 90 | unsigned int (*status)(struct watchdog_device *); |
| 85 | int (*set_timeout)(struct watchdog_device *, unsigned int); | 91 | int (*set_timeout)(struct watchdog_device *, unsigned int); |
| 86 | unsigned int (*get_timeleft)(struct watchdog_device *); | 92 | unsigned int (*get_timeleft)(struct watchdog_device *); |
| 93 | void (*ref)(struct watchdog_device *); | ||
| 94 | void (*unref)(struct watchdog_device *); | ||
| 87 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); | 95 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); |
| 88 | }; | 96 | }; |
| 89 | 97 | ||
| 90 | /** struct watchdog_device - The structure that defines a watchdog device | 98 | /** struct watchdog_device - The structure that defines a watchdog device |
| 91 | * | 99 | * |
| 100 | * @id: The watchdog's ID. (Allocated by watchdog_register_device) | ||
| 101 | * @cdev: The watchdog's Character device. | ||
| 102 | * @dev: The device for our watchdog | ||
| 103 | * @parent: The parent bus device | ||
| 92 | * @info: Pointer to a watchdog_info structure. | 104 | * @info: Pointer to a watchdog_info structure. |
| 93 | * @ops: Pointer to the list of watchdog operations. | 105 | * @ops: Pointer to the list of watchdog operations. |
| 94 | * @bootstatus: Status of the watchdog device at boot. | 106 | * @bootstatus: Status of the watchdog device at boot. |
| @@ -96,6 +108,7 @@ struct watchdog_ops { | |||
| 96 | * @min_timeout:The watchdog devices minimum timeout value. | 108 | * @min_timeout:The watchdog devices minimum timeout value. |
| 97 | * @max_timeout:The watchdog devices maximum timeout value. | 109 | * @max_timeout:The watchdog devices maximum timeout value. |
| 98 | * @driver-data:Pointer to the drivers private data. | 110 | * @driver-data:Pointer to the drivers private data. |
| 111 | * @lock: Lock for watchdog core internal use only. | ||
| 99 | * @status: Field that contains the devices internal status bits. | 112 | * @status: Field that contains the devices internal status bits. |
| 100 | * | 113 | * |
| 101 | * The watchdog_device structure contains all information about a | 114 | * The watchdog_device structure contains all information about a |
| @@ -103,8 +116,15 @@ struct watchdog_ops { | |||
| 103 | * | 116 | * |
| 104 | * The driver-data field may not be accessed directly. It must be accessed | 117 | * The driver-data field may not be accessed directly. It must be accessed |
| 105 | * via the watchdog_set_drvdata and watchdog_get_drvdata helpers. | 118 | * via the watchdog_set_drvdata and watchdog_get_drvdata helpers. |
| 119 | * | ||
| 120 | * The lock field is for watchdog core internal use only and should not be | ||
| 121 | * touched. | ||
| 106 | */ | 122 | */ |
| 107 | struct watchdog_device { | 123 | struct watchdog_device { |
| 124 | int id; | ||
| 125 | struct cdev cdev; | ||
| 126 | struct device *dev; | ||
| 127 | struct device *parent; | ||
| 108 | const struct watchdog_info *info; | 128 | const struct watchdog_info *info; |
| 109 | const struct watchdog_ops *ops; | 129 | const struct watchdog_ops *ops; |
| 110 | unsigned int bootstatus; | 130 | unsigned int bootstatus; |
| @@ -112,12 +132,14 @@ struct watchdog_device { | |||
| 112 | unsigned int min_timeout; | 132 | unsigned int min_timeout; |
| 113 | unsigned int max_timeout; | 133 | unsigned int max_timeout; |
| 114 | void *driver_data; | 134 | void *driver_data; |
| 135 | struct mutex lock; | ||
| 115 | unsigned long status; | 136 | unsigned long status; |
| 116 | /* Bit numbers for status flags */ | 137 | /* Bit numbers for status flags */ |
| 117 | #define WDOG_ACTIVE 0 /* Is the watchdog running/active */ | 138 | #define WDOG_ACTIVE 0 /* Is the watchdog running/active */ |
| 118 | #define WDOG_DEV_OPEN 1 /* Opened via /dev/watchdog ? */ | 139 | #define WDOG_DEV_OPEN 1 /* Opened via /dev/watchdog ? */ |
| 119 | #define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */ | 140 | #define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */ |
| 120 | #define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */ | 141 | #define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */ |
| 142 | #define WDOG_UNREGISTERED 4 /* Has the device been unregistered */ | ||
| 121 | }; | 143 | }; |
| 122 | 144 | ||
| 123 | #ifdef CONFIG_WATCHDOG_NOWAYOUT | 145 | #ifdef CONFIG_WATCHDOG_NOWAYOUT |
| @@ -128,6 +150,12 @@ struct watchdog_device { | |||
| 128 | #define WATCHDOG_NOWAYOUT_INIT_STATUS 0 | 150 | #define WATCHDOG_NOWAYOUT_INIT_STATUS 0 |
| 129 | #endif | 151 | #endif |
| 130 | 152 | ||
| 153 | /* Use the following function to check wether or not the watchdog is active */ | ||
| 154 | static inline bool watchdog_active(struct watchdog_device *wdd) | ||
| 155 | { | ||
| 156 | return test_bit(WDOG_ACTIVE, &wdd->status); | ||
| 157 | } | ||
| 158 | |||
| 131 | /* Use the following function to set the nowayout feature */ | 159 | /* Use the following function to set the nowayout feature */ |
| 132 | static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool nowayout) | 160 | static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool nowayout) |
| 133 | { | 161 | { |
