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()
58 int mei_wd_host_init(struct mei_device *dev) in mei_wd_host_init() argument
60 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 me_cl = mei_me_cl_by_uuid(dev, &mei_wd_guid); in mei_wd_host_init()
73 dev_info(dev->dev, "wd: failed to find the client\n"); in mei_wd_host_init()
84 dev_info(dev->dev, "wd: failed link client\n"); in mei_wd_host_init()
91 dev_err(dev->dev, "wd: failed to connect = %d\n", ret); in mei_wd_host_init()
96 ret = mei_watchdog_register(dev); in mei_wd_host_init()
114 int mei_wd_send(struct mei_device *dev) in mei_wd_send() argument
116 struct mei_cl *cl = &dev->wd_cl; in mei_wd_send()
126 if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE)) in mei_wd_send()
128 else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_HDR_SIZE)) in mei_wd_send()
131 dev_err(dev->dev, "wd: invalid message is to be sent, aborting\n"); in mei_wd_send()
135 ret = mei_write_message(dev, &hdr, dev->wd_data); in mei_wd_send()
137 dev_err(dev->dev, "wd: write message failed\n"); in mei_wd_send()
143 dev_err(dev->dev, "wd: flow_ctrl_reduce failed.\n"); in mei_wd_send()
161 int mei_wd_stop(struct mei_device *dev) in mei_wd_stop() argument
163 struct mei_cl *cl = &dev->wd_cl; in mei_wd_stop()
167 dev->wd_state != MEI_WD_RUNNING) in mei_wd_stop()
170 memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_STOP_MSG_SIZE); in mei_wd_stop()
172 dev->wd_state = MEI_WD_STOPPING; in mei_wd_stop()
178 if (ret && mei_hbuf_acquire(dev)) { in mei_wd_stop()
179 ret = mei_wd_send(dev); in mei_wd_stop()
182 dev->wd_pending = false; in mei_wd_stop()
184 dev->wd_pending = true; in mei_wd_stop()
187 mutex_unlock(&dev->device_lock); in mei_wd_stop()
189 ret = wait_event_timeout(dev->wait_stop_wd, in mei_wd_stop()
190 dev->wd_state == MEI_WD_IDLE, in mei_wd_stop()
192 mutex_lock(&dev->device_lock); in mei_wd_stop()
193 if (dev->wd_state != MEI_WD_IDLE) { in mei_wd_stop()
196 dev_warn(dev->dev, "wd: stop failed to complete ret=%d\n", ret); in mei_wd_stop()
199 dev_dbg(dev->dev, "wd: stop completed after %u msec\n", in mei_wd_stop()
215 struct mei_device *dev; in mei_wd_ops_start() local
219 dev = watchdog_get_drvdata(wd_dev); in mei_wd_ops_start()
220 if (!dev) in mei_wd_ops_start()
223 cl = &dev->wd_cl; in mei_wd_ops_start()
225 mutex_lock(&dev->device_lock); in mei_wd_ops_start()
227 if (dev->dev_state != MEI_DEV_ENABLED) { in mei_wd_ops_start()
228 dev_dbg(dev->dev, "wd: dev_state != MEI_DEV_ENABLED dev_state = %s\n", in mei_wd_ops_start()
229 mei_dev_state_str(dev->dev_state)); in mei_wd_ops_start()
234 cl_dbg(dev, cl, "MEI Driver is not connected to Watchdog Client\n"); in mei_wd_ops_start()
238 mei_wd_set_start_timeout(dev, dev->wd_timeout); in mei_wd_ops_start()
242 mutex_unlock(&dev->device_lock); in mei_wd_ops_start()
255 struct mei_device *dev; in mei_wd_ops_stop() local
257 dev = watchdog_get_drvdata(wd_dev); in mei_wd_ops_stop()
258 if (!dev) in mei_wd_ops_stop()
261 mutex_lock(&dev->device_lock); in mei_wd_ops_stop()
262 mei_wd_stop(dev); in mei_wd_ops_stop()
263 mutex_unlock(&dev->device_lock); in mei_wd_ops_stop()
277 struct mei_device *dev; in mei_wd_ops_ping() local
281 dev = watchdog_get_drvdata(wd_dev); in mei_wd_ops_ping()
282 if (!dev) in mei_wd_ops_ping()
285 cl = &dev->wd_cl; in mei_wd_ops_ping()
287 mutex_lock(&dev->device_lock); in mei_wd_ops_ping()
290 cl_err(dev, cl, "wd: not connected.\n"); in mei_wd_ops_ping()
295 dev->wd_state = MEI_WD_RUNNING; in mei_wd_ops_ping()
302 if (ret && mei_hbuf_acquire(dev)) { in mei_wd_ops_ping()
303 dev_dbg(dev->dev, "wd: sending ping\n"); in mei_wd_ops_ping()
305 ret = mei_wd_send(dev); in mei_wd_ops_ping()
308 dev->wd_pending = false; in mei_wd_ops_ping()
310 dev->wd_pending = true; in mei_wd_ops_ping()
314 mutex_unlock(&dev->device_lock); in mei_wd_ops_ping()
329 struct mei_device *dev; in mei_wd_ops_set_timeout() local
331 dev = watchdog_get_drvdata(wd_dev); in mei_wd_ops_set_timeout()
332 if (!dev) in mei_wd_ops_set_timeout()
339 mutex_lock(&dev->device_lock); in mei_wd_ops_set_timeout()
341 dev->wd_timeout = timeout; in mei_wd_ops_set_timeout()
343 mei_wd_set_start_timeout(dev, dev->wd_timeout); in mei_wd_ops_set_timeout()
345 mutex_unlock(&dev->device_lock); in mei_wd_ops_set_timeout()
376 int mei_watchdog_register(struct mei_device *dev) in mei_watchdog_register() argument
382 mutex_unlock(&dev->device_lock); in mei_watchdog_register()
384 mutex_lock(&dev->device_lock); in mei_watchdog_register()
386 dev_err(dev->dev, "wd: unable to register watchdog device = %d.\n", in mei_watchdog_register()
391 dev_dbg(dev->dev, "wd: successfully register watchdog interface.\n"); in mei_watchdog_register()
392 watchdog_set_drvdata(&amt_wd_dev, dev); in mei_watchdog_register()
396 void mei_watchdog_unregister(struct mei_device *dev) in mei_watchdog_unregister() argument