Lines Matching refs:dev

42 static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)
44 dev_dbg(dev->dev, "wd: set timeout=%d.\n", timeout);
45 memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE);
46 memcpy(dev->wd_data + MEI_WD_HDR_SIZE, &timeout, sizeof(u16));
52 * @dev: the device structure
58 int mei_wd_host_init(struct mei_device *dev)
60 struct mei_cl *cl = &dev->wd_cl;
64 mei_cl_init(cl, dev);
66 dev->wd_timeout = MEI_WD_DEFAULT_TIMEOUT;
67 dev->wd_state = MEI_WD_IDLE;
71 me_cl = mei_me_cl_by_uuid(dev, &mei_wd_guid);
73 dev_info(dev->dev, "wd: failed to find the client\n");
83 dev_info(dev->dev, "wd: failed link client\n");
90 dev_err(dev->dev, "wd: failed to connect = %d\n", ret);
95 ret = mei_watchdog_register(dev);
106 * @dev: the device structure
113 int mei_wd_send(struct mei_device *dev)
115 struct mei_cl *cl = &dev->wd_cl;
125 if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE))
127 else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_HDR_SIZE))
130 dev_err(dev->dev, "wd: invalid message is to be sent, aborting\n");
134 ret = mei_write_message(dev, &hdr, dev->wd_data);
136 dev_err(dev->dev, "wd: write message failed\n");
142 dev_err(dev->dev, "wd: flow_ctrl_reduce failed.\n");
152 * @dev: the device structure
160 int mei_wd_stop(struct mei_device *dev)
164 if (dev->wd_cl.state != MEI_FILE_CONNECTED ||
165 dev->wd_state != MEI_WD_RUNNING)
168 memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_STOP_MSG_SIZE);
170 dev->wd_state = MEI_WD_STOPPING;
172 ret = mei_cl_flow_ctrl_creds(&dev->wd_cl);
176 if (ret && mei_hbuf_acquire(dev)) {
177 ret = mei_wd_send(dev);
180 dev->wd_pending = false;
182 dev->wd_pending = true;
185 mutex_unlock(&dev->device_lock);
187 ret = wait_event_timeout(dev->wait_stop_wd,
188 dev->wd_state == MEI_WD_IDLE,
190 mutex_lock(&dev->device_lock);
191 if (dev->wd_state != MEI_WD_IDLE) {
194 dev_warn(dev->dev, "wd: stop failed to complete ret=%d\n", ret);
197 dev_dbg(dev->dev, "wd: stop completed after %u msec\n",
214 struct mei_device *dev;
216 dev = watchdog_get_drvdata(wd_dev);
217 if (!dev)
220 mutex_lock(&dev->device_lock);
222 if (dev->dev_state != MEI_DEV_ENABLED) {
223 dev_dbg(dev->dev, "wd: dev_state != MEI_DEV_ENABLED dev_state = %s\n",
224 mei_dev_state_str(dev->dev_state));
228 if (dev->wd_cl.state != MEI_FILE_CONNECTED) {
229 dev_dbg(dev->dev, "MEI Driver is not connected to Watchdog Client\n");
233 mei_wd_set_start_timeout(dev, dev->wd_timeout);
237 mutex_unlock(&dev->device_lock);
250 struct mei_device *dev;
252 dev = watchdog_get_drvdata(wd_dev);
253 if (!dev)
256 mutex_lock(&dev->device_lock);
257 mei_wd_stop(dev);
258 mutex_unlock(&dev->device_lock);
272 struct mei_device *dev;
275 dev = watchdog_get_drvdata(wd_dev);
276 if (!dev)
279 mutex_lock(&dev->device_lock);
281 if (dev->wd_cl.state != MEI_FILE_CONNECTED) {
282 dev_err(dev->dev, "wd: not connected.\n");
287 dev->wd_state = MEI_WD_RUNNING;
289 ret = mei_cl_flow_ctrl_creds(&dev->wd_cl);
293 if (ret && mei_hbuf_acquire(dev)) {
295 dev_dbg(dev->dev, "wd: sending ping\n");
297 ret = mei_wd_send(dev);
300 dev->wd_pending = false;
302 dev->wd_pending = true;
306 mutex_unlock(&dev->device_lock);
321 struct mei_device *dev;
323 dev = watchdog_get_drvdata(wd_dev);
324 if (!dev)
331 mutex_lock(&dev->device_lock);
333 dev->wd_timeout = timeout;
335 mei_wd_set_start_timeout(dev, dev->wd_timeout);
337 mutex_unlock(&dev->device_lock);
368 int mei_watchdog_register(struct mei_device *dev)
374 mutex_unlock(&dev->device_lock);
376 mutex_lock(&dev->device_lock);
378 dev_err(dev->dev, "wd: unable to register watchdog device = %d.\n",
383 dev_dbg(dev->dev, "wd: successfully register watchdog interface.\n");
384 watchdog_set_drvdata(&amt_wd_dev, dev);
388 void mei_watchdog_unregister(struct mei_device *dev)