aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2015-12-25 19:01:41 -0500
committerWim Van Sebroeck <wim@iguana.be>2015-12-29 14:36:02 -0500
commite7d162faa6d067777548cb98d55206cf7cd3438e (patch)
treefe4c3c54833ce1f7bc8011b163b536ba49333267
parent32ecc6392654a0db34b310e8924b5b2c3b8bf503 (diff)
watchdog: diag288: Stop re-using watchdog core internal flags
A watchdog driver should not use watchdog subsystem internal flags. Use a driver variable and flag instead to maintain the watchdog state and to determine if a suspend operation is possible or not. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
-rw-r--r--drivers/watchdog/diag288_wdt.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/watchdog/diag288_wdt.c b/drivers/watchdog/diag288_wdt.c
index 3db9d0e0673d..861d3d3133f8 100644
--- a/drivers/watchdog/diag288_wdt.c
+++ b/drivers/watchdog/diag288_wdt.c
@@ -106,6 +106,10 @@ static int __diag288_lpar(unsigned int func, unsigned int timeout,
106 return __diag288(func, timeout, action, 0); 106 return __diag288(func, timeout, action, 0);
107} 107}
108 108
109static unsigned long wdt_status;
110
111#define DIAG_WDOG_BUSY 0
112
109static int wdt_start(struct watchdog_device *dev) 113static int wdt_start(struct watchdog_device *dev)
110{ 114{
111 char *ebc_cmd; 115 char *ebc_cmd;
@@ -113,12 +117,17 @@ static int wdt_start(struct watchdog_device *dev)
113 int ret; 117 int ret;
114 unsigned int func; 118 unsigned int func;
115 119
120 if (test_and_set_bit(DIAG_WDOG_BUSY, &wdt_status))
121 return -EBUSY;
122
116 ret = -ENODEV; 123 ret = -ENODEV;
117 124
118 if (MACHINE_IS_VM) { 125 if (MACHINE_IS_VM) {
119 ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL); 126 ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL);
120 if (!ebc_cmd) 127 if (!ebc_cmd) {
128 clear_bit(DIAG_WDOG_BUSY, &wdt_status);
121 return -ENOMEM; 129 return -ENOMEM;
130 }
122 len = strlcpy(ebc_cmd, wdt_cmd, MAX_CMDLEN); 131 len = strlcpy(ebc_cmd, wdt_cmd, MAX_CMDLEN);
123 ASCEBC(ebc_cmd, MAX_CMDLEN); 132 ASCEBC(ebc_cmd, MAX_CMDLEN);
124 EBC_TOUPPER(ebc_cmd, MAX_CMDLEN); 133 EBC_TOUPPER(ebc_cmd, MAX_CMDLEN);
@@ -135,6 +144,7 @@ static int wdt_start(struct watchdog_device *dev)
135 144
136 if (ret) { 145 if (ret) {
137 pr_err("The watchdog cannot be activated\n"); 146 pr_err("The watchdog cannot be activated\n");
147 clear_bit(DIAG_WDOG_BUSY, &wdt_status);
138 return ret; 148 return ret;
139 } 149 }
140 return 0; 150 return 0;
@@ -146,6 +156,9 @@ static int wdt_stop(struct watchdog_device *dev)
146 156
147 diag_stat_inc(DIAG_STAT_X288); 157 diag_stat_inc(DIAG_STAT_X288);
148 ret = __diag288(WDT_FUNC_CANCEL, 0, 0, 0); 158 ret = __diag288(WDT_FUNC_CANCEL, 0, 0, 0);
159
160 clear_bit(DIAG_WDOG_BUSY, &wdt_status);
161
149 return ret; 162 return ret;
150} 163}
151 164
@@ -220,17 +233,10 @@ static struct watchdog_device wdt_dev = {
220 * It makes no sense to go into suspend while the watchdog is running. 233 * It makes no sense to go into suspend while the watchdog is running.
221 * Depending on the memory size, the watchdog might trigger, while we 234 * Depending on the memory size, the watchdog might trigger, while we
222 * are still saving the memory. 235 * are still saving the memory.
223 * We reuse the open flag to ensure that suspend and watchdog open are
224 * exclusive operations
225 */ 236 */
226static int wdt_suspend(void) 237static int wdt_suspend(void)
227{ 238{
228 if (test_and_set_bit(WDOG_DEV_OPEN, &wdt_dev.status)) { 239 if (test_and_set_bit(DIAG_WDOG_BUSY, &wdt_status)) {
229 pr_err("Linux cannot be suspended while the watchdog is in use\n");
230 return notifier_from_errno(-EBUSY);
231 }
232 if (test_bit(WDOG_ACTIVE, &wdt_dev.status)) {
233 clear_bit(WDOG_DEV_OPEN, &wdt_dev.status);
234 pr_err("Linux cannot be suspended while the watchdog is in use\n"); 240 pr_err("Linux cannot be suspended while the watchdog is in use\n");
235 return notifier_from_errno(-EBUSY); 241 return notifier_from_errno(-EBUSY);
236 } 242 }
@@ -239,7 +245,7 @@ static int wdt_suspend(void)
239 245
240static int wdt_resume(void) 246static int wdt_resume(void)
241{ 247{
242 clear_bit(WDOG_DEV_OPEN, &wdt_dev.status); 248 clear_bit(DIAG_WDOG_BUSY, &wdt_status);
243 return NOTIFY_DONE; 249 return NOTIFY_DONE;
244} 250}
245 251