Lines Matching refs:dev

47 void mei_amthif_reset_params(struct mei_device *dev)  in mei_amthif_reset_params()  argument
50 dev->iamthif_current_cb = NULL; in mei_amthif_reset_params()
51 dev->iamthif_canceled = false; in mei_amthif_reset_params()
52 dev->iamthif_state = MEI_IAMTHIF_IDLE; in mei_amthif_reset_params()
53 dev->iamthif_timer = 0; in mei_amthif_reset_params()
54 dev->iamthif_stall_timer = 0; in mei_amthif_reset_params()
55 dev->iamthif_open_count = 0; in mei_amthif_reset_params()
66 int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl) in mei_amthif_host_init() argument
68 struct mei_cl *cl = &dev->iamthif_cl; in mei_amthif_host_init()
71 dev->iamthif_state = MEI_IAMTHIF_IDLE; in mei_amthif_host_init()
73 mei_cl_init(cl, dev); in mei_amthif_host_init()
77 dev_err(dev->dev, "amthif: failed cl_link %d\n", ret); in mei_amthif_host_init()
83 dev->iamthif_state = MEI_IAMTHIF_IDLE; in mei_amthif_host_init()
96 struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev, in mei_amthif_find_read_list_entry() argument
101 list_for_each_entry(cb, &dev->amthif_rd_complete_list.list, list) in mei_amthif_find_read_list_entry()
124 int mei_amthif_read(struct mei_device *dev, struct file *file, in mei_amthif_read() argument
135 dev_err(dev->dev, "bad file ext.\n"); in mei_amthif_read()
139 dev_dbg(dev->dev, "checking amthif data\n"); in mei_amthif_read()
140 cb = mei_amthif_find_read_list_entry(dev, file); in mei_amthif_read()
147 dev_dbg(dev->dev, "waiting for amthif data\n"); in mei_amthif_read()
150 mutex_unlock(&dev->device_lock); in mei_amthif_read()
152 wait_ret = wait_event_interruptible(dev->iamthif_cl.wait, in mei_amthif_read()
153 (cb = mei_amthif_find_read_list_entry(dev, file))); in mei_amthif_read()
156 mutex_lock(&dev->device_lock); in mei_amthif_read()
161 dev_dbg(dev->dev, "woke up from sleep\n"); in mei_amthif_read()
166 dev_dbg(dev->dev, "read operation failed %d\n", rets); in mei_amthif_read()
170 dev_dbg(dev->dev, "Got amthif data\n"); in mei_amthif_read()
171 dev->iamthif_timer = 0; in mei_amthif_read()
175 dev_dbg(dev->dev, "amthif timeout = %lud\n", in mei_amthif_read()
179 dev_dbg(dev->dev, "amthif Time out\n"); in mei_amthif_read()
198 dev_dbg(dev->dev, "amthif cb->buf size - %d\n", in mei_amthif_read()
200 dev_dbg(dev->dev, "amthif cb->buf_idx - %lu\n", cb->buf_idx); in mei_amthif_read()
207 dev_dbg(dev->dev, "failed to copy data to userland\n"); in mei_amthif_read()
217 dev_dbg(dev->dev, "free amthif cb memory.\n"); in mei_amthif_read()
234 struct mei_device *dev = cl->dev; in mei_amthif_read_start() local
248 list_add_tail(&cb->list, &dev->ctrl_wr_list.list); in mei_amthif_read_start()
250 dev->iamthif_state = MEI_IAMTHIF_READING; in mei_amthif_read_start()
251 dev->iamthif_file_object = cb->file_object; in mei_amthif_read_start()
252 dev->iamthif_current_cb = cb; in mei_amthif_read_start()
270 struct mei_device *dev; in mei_amthif_send_cmd() local
273 if (!cl->dev || !cb) in mei_amthif_send_cmd()
276 dev = cl->dev; in mei_amthif_send_cmd()
278 dev->iamthif_state = MEI_IAMTHIF_WRITING; in mei_amthif_send_cmd()
279 dev->iamthif_current_cb = cb; in mei_amthif_send_cmd()
280 dev->iamthif_file_object = cb->file_object; in mei_amthif_send_cmd()
281 dev->iamthif_canceled = false; in mei_amthif_send_cmd()
300 int mei_amthif_run_next_cmd(struct mei_device *dev) in mei_amthif_run_next_cmd() argument
302 struct mei_cl *cl = &dev->iamthif_cl; in mei_amthif_run_next_cmd()
305 dev->iamthif_canceled = false; in mei_amthif_run_next_cmd()
306 dev->iamthif_state = MEI_IAMTHIF_IDLE; in mei_amthif_run_next_cmd()
307 dev->iamthif_timer = 0; in mei_amthif_run_next_cmd()
308 dev->iamthif_file_object = NULL; in mei_amthif_run_next_cmd()
310 dev_dbg(dev->dev, "complete amthif cmd_list cb.\n"); in mei_amthif_run_next_cmd()
312 cb = list_first_entry_or_null(&dev->amthif_cmd_list.list, in mei_amthif_run_next_cmd()
332 struct mei_device *dev; in mei_amthif_write() local
334 if (WARN_ON(!cl || !cl->dev)) in mei_amthif_write()
340 dev = cl->dev; in mei_amthif_write()
342 list_add_tail(&cb->list, &dev->amthif_cmd_list.list); in mei_amthif_write()
343 return mei_amthif_run_next_cmd(dev); in mei_amthif_write()
358 unsigned int mei_amthif_poll(struct mei_device *dev, in mei_amthif_poll() argument
363 poll_wait(file, &dev->iamthif_cl.wait, wait); in mei_amthif_poll()
365 if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE && in mei_amthif_poll()
366 dev->iamthif_file_object == file) { in mei_amthif_poll()
369 mei_amthif_run_next_cmd(dev); in mei_amthif_poll()
415 struct mei_device *dev; in mei_amthif_irq_read_msg() local
418 dev = cl->dev; in mei_amthif_irq_read_msg()
420 if (dev->iamthif_state != MEI_IAMTHIF_READING) { in mei_amthif_irq_read_msg()
421 mei_irq_discard_msg(dev, mei_hdr); in mei_amthif_irq_read_msg()
432 dev_dbg(dev->dev, "completed amthif read.\n "); in mei_amthif_irq_read_msg()
433 dev->iamthif_current_cb = NULL; in mei_amthif_irq_read_msg()
434 dev->iamthif_stall_timer = 0; in mei_amthif_irq_read_msg()
445 void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb) in mei_amthif_complete() argument
450 dev->iamthif_stall_timer = MEI_IAMTHIF_STALL_TIMER; in mei_amthif_complete()
458 list_add_tail(&cb->list, &dev->amthif_rd_complete_list.list); in mei_amthif_complete()
459 wake_up_interruptible(&dev->iamthif_cl.wait); in mei_amthif_complete()
463 if (!dev->iamthif_canceled) { in mei_amthif_complete()
464 dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE; in mei_amthif_complete()
465 dev->iamthif_stall_timer = 0; in mei_amthif_complete()
466 list_add_tail(&cb->list, &dev->amthif_rd_complete_list.list); in mei_amthif_complete()
467 dev_dbg(dev->dev, "amthif read completed\n"); in mei_amthif_complete()
468 dev->iamthif_timer = jiffies; in mei_amthif_complete()
469 dev_dbg(dev->dev, "dev->iamthif_timer = %ld\n", in mei_amthif_complete()
470 dev->iamthif_timer); in mei_amthif_complete()
472 mei_amthif_run_next_cmd(dev); in mei_amthif_complete()
475 dev_dbg(dev->dev, "completing amthif call back.\n"); in mei_amthif_complete()
476 wake_up_interruptible(&dev->iamthif_cl.wait); in mei_amthif_complete()
492 static bool mei_clear_list(struct mei_device *dev, in mei_clear_list() argument
495 struct mei_cl *cl = &dev->iamthif_cl; in mei_clear_list()
504 if (dev->iamthif_current_cb == cb) { in mei_clear_list()
505 dev->iamthif_current_cb = NULL; in mei_clear_list()
507 mei_hbm_cl_flow_control_req(dev, cl); in mei_clear_list()
528 static bool mei_clear_lists(struct mei_device *dev, struct file *file) in mei_clear_lists() argument
533 mei_clear_list(dev, file, &dev->amthif_cmd_list.list); in mei_clear_lists()
534 if (mei_clear_list(dev, file, &dev->amthif_rd_complete_list.list)) in mei_clear_lists()
537 mei_clear_list(dev, file, &dev->ctrl_rd_list.list); in mei_clear_lists()
539 if (mei_clear_list(dev, file, &dev->ctrl_wr_list.list)) in mei_clear_lists()
542 if (mei_clear_list(dev, file, &dev->write_waiting_list.list)) in mei_clear_lists()
545 if (mei_clear_list(dev, file, &dev->write_list.list)) in mei_clear_lists()
549 if (dev->iamthif_current_cb && !removed) { in mei_clear_lists()
551 if (dev->iamthif_current_cb->file_object == file) { in mei_clear_lists()
553 mei_io_cb_free(dev->iamthif_current_cb); in mei_clear_lists()
554 dev->iamthif_current_cb = NULL; in mei_clear_lists()
569 int mei_amthif_release(struct mei_device *dev, struct file *file) in mei_amthif_release() argument
571 if (dev->iamthif_open_count > 0) in mei_amthif_release()
572 dev->iamthif_open_count--; in mei_amthif_release()
574 if (dev->iamthif_file_object == file && in mei_amthif_release()
575 dev->iamthif_state != MEI_IAMTHIF_IDLE) { in mei_amthif_release()
577 dev_dbg(dev->dev, "amthif canceled iamthif state %d\n", in mei_amthif_release()
578 dev->iamthif_state); in mei_amthif_release()
579 dev->iamthif_canceled = true; in mei_amthif_release()
580 if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE) { in mei_amthif_release()
581 dev_dbg(dev->dev, "run next amthif iamthif cb\n"); in mei_amthif_release()
582 mei_amthif_run_next_cmd(dev); in mei_amthif_release()
586 if (mei_clear_lists(dev, file)) in mei_amthif_release()
587 dev->iamthif_state = MEI_IAMTHIF_IDLE; in mei_amthif_release()