unsigned int min_timeout;
unsigned int max_timeout;
void *driver_data;
+ struct mutex lock;
unsigned long status;
};
* 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
{
int err = 0;
+ mutex_lock(&wddev->lock);
+
if (!watchdog_active(wddev))
goto out_ping;
err = wddev->ops->start(wddev); /* restart watchdog */
out_ping:
+ mutex_unlock(&wddev->lock);
return err;
}
{
int err = 0;
+ mutex_lock(&wddev->lock);
+
if (watchdog_active(wddev))
goto out_start;
set_bit(WDOG_ACTIVE, &wddev->status);
out_start:
+ mutex_unlock(&wddev->lock);
return err;
}
{
int err = 0;
+ mutex_lock(&wddev->lock);
+
if (!watchdog_active(wddev))
goto out_stop;
clear_bit(WDOG_ACTIVE, &wddev->status);
out_stop:
+ mutex_unlock(&wddev->lock);
return err;
}
if (!wddev->ops->status)
return -EOPNOTSUPP;
+ mutex_lock(&wddev->lock);
+
*status = wddev->ops->status(wddev);
+ mutex_unlock(&wddev->lock);
return err;
}
(timeout < wddev->min_timeout || timeout > wddev->max_timeout))
return -EINVAL;
+ mutex_lock(&wddev->lock);
+
err = wddev->ops->set_timeout(wddev, timeout);
+ mutex_unlock(&wddev->lock);
return err;
}
if (!wddev->ops->get_timeleft)
return -EOPNOTSUPP;
+ mutex_lock(&wddev->lock);
+
*timeleft = wddev->ops->get_timeleft(wddev);
+ mutex_unlock(&wddev->lock);
return err;
}
if (!wddev->ops->ioctl)
return -ENOIOCTLCMD;
+ mutex_lock(&wddev->lock);
+
err = wddev->ops->ioctl(wddev, cmd, arg);
+ mutex_unlock(&wddev->lock);
return err;
}
* @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
*
* 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;
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 */