aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/wd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/mei/wd.c')
-rw-r--r--drivers/misc/mei/wd.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
index 755a58305a7e..0824166a7303 100644
--- a/drivers/misc/mei/wd.c
+++ b/drivers/misc/mei/wd.c
@@ -67,6 +67,7 @@ int mei_wd_host_init(struct mei_device *dev)
67 /* look for WD client and connect to it */ 67 /* look for WD client and connect to it */
68 dev->wd_cl.state = MEI_FILE_DISCONNECTED; 68 dev->wd_cl.state = MEI_FILE_DISCONNECTED;
69 dev->wd_timeout = MEI_WD_DEFAULT_TIMEOUT; 69 dev->wd_timeout = MEI_WD_DEFAULT_TIMEOUT;
70 dev->wd_state = MEI_WD_IDLE;
70 71
71 /* find ME WD client */ 72 /* find ME WD client */
72 mei_me_cl_update_filext(dev, &dev->wd_cl, 73 mei_me_cl_update_filext(dev, &dev->wd_cl,
@@ -128,18 +129,17 @@ int mei_wd_send(struct mei_device *dev)
128 * -EIO when message send fails 129 * -EIO when message send fails
129 * -EINVAL when invalid message is to be sent 130 * -EINVAL when invalid message is to be sent
130 */ 131 */
131int mei_wd_stop(struct mei_device *dev, bool preserve) 132int mei_wd_stop(struct mei_device *dev)
132{ 133{
133 int ret; 134 int ret;
134 u16 wd_timeout = dev->wd_timeout;
135 135
136 cancel_delayed_work(&dev->timer_work); 136 if (dev->wd_cl.state != MEI_FILE_CONNECTED ||
137 if (dev->wd_cl.state != MEI_FILE_CONNECTED || !dev->wd_timeout) 137 dev->wd_state != MEI_WD_RUNNING)
138 return 0; 138 return 0;
139 139
140 dev->wd_timeout = 0;
141 memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_STOP_MSG_SIZE); 140 memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_STOP_MSG_SIZE);
142 dev->stop = true; 141
142 dev->wd_state = MEI_WD_STOPPING;
143 143
144 ret = mei_flow_ctrl_creds(dev, &dev->wd_cl); 144 ret = mei_flow_ctrl_creds(dev, &dev->wd_cl);
145 if (ret < 0) 145 if (ret < 0)
@@ -161,13 +161,14 @@ int mei_wd_stop(struct mei_device *dev, bool preserve)
161 } else { 161 } else {
162 dev->wd_pending = true; 162 dev->wd_pending = true;
163 } 163 }
164 dev->wd_stopped = false; 164
165 mutex_unlock(&dev->device_lock); 165 mutex_unlock(&dev->device_lock);
166 166
167 ret = wait_event_interruptible_timeout(dev->wait_stop_wd, 167 ret = wait_event_interruptible_timeout(dev->wait_stop_wd,
168 dev->wd_stopped, 10 * HZ); 168 dev->wd_state == MEI_WD_IDLE,
169 msecs_to_jiffies(MEI_WD_STOP_TIMEOUT));
169 mutex_lock(&dev->device_lock); 170 mutex_lock(&dev->device_lock);
170 if (dev->wd_stopped) { 171 if (dev->wd_state == MEI_WD_IDLE) {
171 dev_dbg(&dev->pdev->dev, "wd: stop completed ret=%d.\n", ret); 172 dev_dbg(&dev->pdev->dev, "wd: stop completed ret=%d.\n", ret);
172 ret = 0; 173 ret = 0;
173 } else { 174 } else {
@@ -177,9 +178,6 @@ int mei_wd_stop(struct mei_device *dev, bool preserve)
177 "wd: stop failed to complete ret=%d.\n", ret); 178 "wd: stop failed to complete ret=%d.\n", ret);
178 } 179 }
179 180
180 if (preserve)
181 dev->wd_timeout = wd_timeout;
182
183out: 181out:
184 return ret; 182 return ret;
185} 183}
@@ -239,7 +237,7 @@ static int mei_wd_ops_stop(struct watchdog_device *wd_dev)
239 return -ENODEV; 237 return -ENODEV;
240 238
241 mutex_lock(&dev->device_lock); 239 mutex_lock(&dev->device_lock);
242 mei_wd_stop(dev, false); 240 mei_wd_stop(dev);
243 mutex_unlock(&dev->device_lock); 241 mutex_unlock(&dev->device_lock);
244 242
245 return 0; 243 return 0;
@@ -269,6 +267,8 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev)
269 goto end; 267 goto end;
270 } 268 }
271 269
270 dev->wd_state = MEI_WD_RUNNING;
271
272 /* Check if we can send the ping to HW*/ 272 /* Check if we can send the ping to HW*/
273 if (dev->mei_host_buffer_is_empty && 273 if (dev->mei_host_buffer_is_empty &&
274 mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) { 274 mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {