diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-05-22 05:40:26 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2012-05-30 01:55:23 -0400 |
commit | f4e9c82f64b524314a390b13d3ba7d483f09258f (patch) | |
tree | 82d688ae7782234dc01c6a340596bac21531aae4 /include | |
parent | 7a87982420e5e126bfefeb42232d1fd92052794e (diff) |
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.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/watchdog.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index c3545c5d918a..da1dc1b52744 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h | |||
@@ -104,6 +104,7 @@ struct watchdog_ops { | |||
104 | * @min_timeout:The watchdog devices minimum timeout value. | 104 | * @min_timeout:The watchdog devices minimum timeout value. |
105 | * @max_timeout:The watchdog devices maximum timeout value. | 105 | * @max_timeout:The watchdog devices maximum timeout value. |
106 | * @driver-data:Pointer to the drivers private data. | 106 | * @driver-data:Pointer to the drivers private data. |
107 | * @lock: Lock for watchdog core internal use only. | ||
107 | * @status: Field that contains the devices internal status bits. | 108 | * @status: Field that contains the devices internal status bits. |
108 | * | 109 | * |
109 | * The watchdog_device structure contains all information about a | 110 | * The watchdog_device structure contains all information about a |
@@ -111,6 +112,9 @@ struct watchdog_ops { | |||
111 | * | 112 | * |
112 | * The driver-data field may not be accessed directly. It must be accessed | 113 | * The driver-data field may not be accessed directly. It must be accessed |
113 | * via the watchdog_set_drvdata and watchdog_get_drvdata helpers. | 114 | * via the watchdog_set_drvdata and watchdog_get_drvdata helpers. |
115 | * | ||
116 | * The lock field is for watchdog core internal use only and should not be | ||
117 | * touched. | ||
114 | */ | 118 | */ |
115 | struct watchdog_device { | 119 | struct watchdog_device { |
116 | int id; | 120 | int id; |
@@ -124,6 +128,7 @@ struct watchdog_device { | |||
124 | unsigned int min_timeout; | 128 | unsigned int min_timeout; |
125 | unsigned int max_timeout; | 129 | unsigned int max_timeout; |
126 | void *driver_data; | 130 | void *driver_data; |
131 | struct mutex lock; | ||
127 | unsigned long status; | 132 | unsigned long status; |
128 | /* Bit numbers for status flags */ | 133 | /* Bit numbers for status flags */ |
129 | #define WDOG_ACTIVE 0 /* Is the watchdog running/active */ | 134 | #define WDOG_ACTIVE 0 /* Is the watchdog running/active */ |