mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
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>
This commit is contained in:
committed by
Wim Van Sebroeck
parent
7a87982420
commit
f4e9c82f64
@@ -104,6 +104,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
|
||||
@@ -111,6 +112,9 @@ 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;
|
||||
@@ -124,6 +128,7 @@ 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 */
|
||||
|
Reference in New Issue
Block a user