Lines Matching refs:dev
42 static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout) in mei_wd_set_start_timeout() argument
44 dev_dbg(dev->dev, "wd: set timeout=%d.\n", timeout); in mei_wd_set_start_timeout()
45 memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE); in mei_wd_set_start_timeout()
46 memcpy(dev->wd_data + MEI_WD_HDR_SIZE, &timeout, sizeof(u16)); in mei_wd_set_start_timeout()
59 int mei_wd_host_init(struct mei_device *dev, struct mei_me_client *me_cl) in mei_wd_host_init() argument
61 struct mei_cl *cl = &dev->wd_cl; in mei_wd_host_init()
64 mei_cl_init(cl, dev); in mei_wd_host_init()
66 dev->wd_timeout = MEI_WD_DEFAULT_TIMEOUT; in mei_wd_host_init()
67 dev->wd_state = MEI_WD_IDLE; in mei_wd_host_init()
71 dev_info(dev->dev, "wd: failed link client\n"); in mei_wd_host_init()
77 dev_err(dev->dev, "wd: failed to connect = %d\n", ret); in mei_wd_host_init()
82 ret = mei_watchdog_register(dev); in mei_wd_host_init()
100 int mei_wd_send(struct mei_device *dev) in mei_wd_send() argument
102 struct mei_cl *cl = &dev->wd_cl; in mei_wd_send()
112 if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE)) in mei_wd_send()
114 else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_HDR_SIZE)) in mei_wd_send()
117 dev_err(dev->dev, "wd: invalid message is to be sent, aborting\n"); in mei_wd_send()
121 ret = mei_write_message(dev, &hdr, dev->wd_data); in mei_wd_send()
123 dev_err(dev->dev, "wd: write message failed\n"); in mei_wd_send()
129 dev_err(dev->dev, "wd: flow_ctrl_reduce failed.\n"); in mei_wd_send()
147 int mei_wd_stop(struct mei_device *dev) in mei_wd_stop() argument
149 struct mei_cl *cl = &dev->wd_cl; in mei_wd_stop()
153 dev->wd_state != MEI_WD_RUNNING) in mei_wd_stop()
156 memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_STOP_MSG_SIZE); in mei_wd_stop()
158 dev->wd_state = MEI_WD_STOPPING; in mei_wd_stop()
164 if (ret && mei_hbuf_acquire(dev)) { in mei_wd_stop()
165 ret = mei_wd_send(dev); in mei_wd_stop()
168 dev->wd_pending = false; in mei_wd_stop()
170 dev->wd_pending = true; in mei_wd_stop()
173 mutex_unlock(&dev->device_lock); in mei_wd_stop()
175 ret = wait_event_timeout(dev->wait_stop_wd, in mei_wd_stop()
176 dev->wd_state == MEI_WD_IDLE, in mei_wd_stop()
178 mutex_lock(&dev->device_lock); in mei_wd_stop()
179 if (dev->wd_state != MEI_WD_IDLE) { in mei_wd_stop()
182 dev_warn(dev->dev, "wd: stop failed to complete ret=%d\n", ret); in mei_wd_stop()
185 dev_dbg(dev->dev, "wd: stop completed after %u msec\n", in mei_wd_stop()
201 struct mei_device *dev; in mei_wd_ops_start() local
205 dev = watchdog_get_drvdata(wd_dev); in mei_wd_ops_start()
206 if (!dev) in mei_wd_ops_start()
209 cl = &dev->wd_cl; in mei_wd_ops_start()
211 mutex_lock(&dev->device_lock); in mei_wd_ops_start()
213 if (dev->dev_state != MEI_DEV_ENABLED) { in mei_wd_ops_start()
214 dev_dbg(dev->dev, "wd: dev_state != MEI_DEV_ENABLED dev_state = %s\n", in mei_wd_ops_start()
215 mei_dev_state_str(dev->dev_state)); in mei_wd_ops_start()
220 cl_dbg(dev, cl, "MEI Driver is not connected to Watchdog Client\n"); in mei_wd_ops_start()
224 mei_wd_set_start_timeout(dev, dev->wd_timeout); in mei_wd_ops_start()
228 mutex_unlock(&dev->device_lock); in mei_wd_ops_start()
241 struct mei_device *dev; in mei_wd_ops_stop() local
243 dev = watchdog_get_drvdata(wd_dev); in mei_wd_ops_stop()
244 if (!dev) in mei_wd_ops_stop()
247 mutex_lock(&dev->device_lock); in mei_wd_ops_stop()
248 mei_wd_stop(dev); in mei_wd_ops_stop()
249 mutex_unlock(&dev->device_lock); in mei_wd_ops_stop()
263 struct mei_device *dev; in mei_wd_ops_ping() local
267 dev = watchdog_get_drvdata(wd_dev); in mei_wd_ops_ping()
268 if (!dev) in mei_wd_ops_ping()
271 cl = &dev->wd_cl; in mei_wd_ops_ping()
273 mutex_lock(&dev->device_lock); in mei_wd_ops_ping()
276 cl_err(dev, cl, "wd: not connected.\n"); in mei_wd_ops_ping()
281 dev->wd_state = MEI_WD_RUNNING; in mei_wd_ops_ping()
288 if (ret && mei_hbuf_acquire(dev)) { in mei_wd_ops_ping()
289 dev_dbg(dev->dev, "wd: sending ping\n"); in mei_wd_ops_ping()
291 ret = mei_wd_send(dev); in mei_wd_ops_ping()
294 dev->wd_pending = false; in mei_wd_ops_ping()
296 dev->wd_pending = true; in mei_wd_ops_ping()
300 mutex_unlock(&dev->device_lock); in mei_wd_ops_ping()
315 struct mei_device *dev; in mei_wd_ops_set_timeout() local
317 dev = watchdog_get_drvdata(wd_dev); in mei_wd_ops_set_timeout()
318 if (!dev) in mei_wd_ops_set_timeout()
325 mutex_lock(&dev->device_lock); in mei_wd_ops_set_timeout()
327 dev->wd_timeout = timeout; in mei_wd_ops_set_timeout()
329 mei_wd_set_start_timeout(dev, dev->wd_timeout); in mei_wd_ops_set_timeout()
331 mutex_unlock(&dev->device_lock); in mei_wd_ops_set_timeout()
362 int mei_watchdog_register(struct mei_device *dev) in mei_watchdog_register() argument
367 amt_wd_dev.parent = dev->dev; in mei_watchdog_register()
369 mutex_unlock(&dev->device_lock); in mei_watchdog_register()
371 mutex_lock(&dev->device_lock); in mei_watchdog_register()
373 dev_err(dev->dev, "wd: unable to register watchdog device = %d.\n", in mei_watchdog_register()
378 dev_dbg(dev->dev, "wd: successfully register watchdog interface.\n"); in mei_watchdog_register()
379 watchdog_set_drvdata(&amt_wd_dev, dev); in mei_watchdog_register()
383 void mei_watchdog_unregister(struct mei_device *dev) in mei_watchdog_unregister() argument