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. Signed-off-by: Viresh Kumar <viresh.kumar@st.com> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
This commit is contained in:
parent
09a46e7397
commit
257f8c4aae
@ -91,7 +91,7 @@ static inline void wdt_reset(void)
|
|||||||
static void wdt_timer_tick(unsigned long data)
|
static void wdt_timer_tick(unsigned long data)
|
||||||
{
|
{
|
||||||
if (time_before(jiffies, next_heartbeat) ||
|
if (time_before(jiffies, next_heartbeat) ||
|
||||||
(!test_bit(WDOG_ACTIVE, &wdt_dev.status))) {
|
(!watchdog_active(&wdt_dev))) {
|
||||||
wdt_reset();
|
wdt_reset();
|
||||||
mod_timer(&timer, jiffies + WDT_HEARTBEAT);
|
mod_timer(&timer, jiffies + WDT_HEARTBEAT);
|
||||||
} else
|
} else
|
||||||
|
@ -61,7 +61,7 @@ static struct watchdog_device *wdd;
|
|||||||
|
|
||||||
static int watchdog_ping(struct watchdog_device *wddev)
|
static int watchdog_ping(struct watchdog_device *wddev)
|
||||||
{
|
{
|
||||||
if (test_bit(WDOG_ACTIVE, &wddev->status)) {
|
if (watchdog_active(wddev)) {
|
||||||
if (wddev->ops->ping)
|
if (wddev->ops->ping)
|
||||||
return wddev->ops->ping(wddev); /* ping the watchdog */
|
return wddev->ops->ping(wddev); /* ping the watchdog */
|
||||||
else
|
else
|
||||||
@ -83,7 +83,7 @@ static int watchdog_start(struct watchdog_device *wddev)
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!test_bit(WDOG_ACTIVE, &wddev->status)) {
|
if (!watchdog_active(wddev)) {
|
||||||
err = wddev->ops->start(wddev);
|
err = wddev->ops->start(wddev);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
@ -113,7 +113,7 @@ static int watchdog_stop(struct watchdog_device *wddev)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_bit(WDOG_ACTIVE, &wddev->status)) {
|
if (watchdog_active(wddev)) {
|
||||||
err = wddev->ops->stop(wddev);
|
err = wddev->ops->stop(wddev);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
@ -128,6 +128,12 @@ struct watchdog_device {
|
|||||||
#define WATCHDOG_NOWAYOUT_INIT_STATUS 0
|
#define WATCHDOG_NOWAYOUT_INIT_STATUS 0
|
||||||
#endif
|
#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 */
|
/* Use the following function to set the nowayout feature */
|
||||||
static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool nowayout)
|
static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool nowayout)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user