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()
65 int mei_amthif_host_init(struct mei_device *dev) in mei_amthif_host_init() argument
67 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()
75 me_cl = mei_me_cl_by_uuid(dev, &mei_amthif_guid); in mei_amthif_host_init()
77 dev_info(dev->dev, "amthif: failed to find the client"); in mei_amthif_host_init()
86 dev->iamthif_mtu = me_cl->props.max_msg_length; in mei_amthif_host_init()
87 dev_dbg(dev->dev, "IAMTHIF_MTU = %d\n", dev->iamthif_mtu); in mei_amthif_host_init()
92 dev_err(dev->dev, "amthif: failed cl_link %d\n", ret); in mei_amthif_host_init()
98 dev->iamthif_state = MEI_IAMTHIF_IDLE; in mei_amthif_host_init()
113 struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev, in mei_amthif_find_read_list_entry() argument
118 list_for_each_entry(cb, &dev->amthif_rd_complete_list.list, list) in mei_amthif_find_read_list_entry()
141 int mei_amthif_read(struct mei_device *dev, struct file *file, in mei_amthif_read() argument
152 dev_err(dev->dev, "bad file ext.\n"); in mei_amthif_read()
156 dev_dbg(dev->dev, "checking amthif data\n"); in mei_amthif_read()
157 cb = mei_amthif_find_read_list_entry(dev, file); in mei_amthif_read()
164 dev_dbg(dev->dev, "waiting for amthif data\n"); in mei_amthif_read()
167 mutex_unlock(&dev->device_lock); in mei_amthif_read()
169 wait_ret = wait_event_interruptible(dev->iamthif_cl.wait, in mei_amthif_read()
170 (cb = mei_amthif_find_read_list_entry(dev, file))); in mei_amthif_read()
173 mutex_lock(&dev->device_lock); in mei_amthif_read()
178 dev_dbg(dev->dev, "woke up from sleep\n"); in mei_amthif_read()
183 dev_dbg(dev->dev, "read operation failed %d\n", rets); in mei_amthif_read()
187 dev_dbg(dev->dev, "Got amthif data\n"); in mei_amthif_read()
188 dev->iamthif_timer = 0; in mei_amthif_read()
192 dev_dbg(dev->dev, "amthif timeout = %lud\n", in mei_amthif_read()
196 dev_dbg(dev->dev, "amthif Time out\n"); in mei_amthif_read()
215 dev_dbg(dev->dev, "amthif cb->buf size - %d\n", in mei_amthif_read()
217 dev_dbg(dev->dev, "amthif cb->buf_idx - %lu\n", cb->buf_idx); in mei_amthif_read()
224 dev_dbg(dev->dev, "failed to copy data to userland\n"); in mei_amthif_read()
234 dev_dbg(dev->dev, "free amthif cb memory.\n"); in mei_amthif_read()
251 struct mei_device *dev = cl->dev; in mei_amthif_read_start() local
253 size_t length = dev->iamthif_mtu; in mei_amthif_read_start()
266 list_add_tail(&cb->list, &dev->ctrl_wr_list.list); in mei_amthif_read_start()
268 dev->iamthif_state = MEI_IAMTHIF_READING; in mei_amthif_read_start()
269 dev->iamthif_file_object = cb->file_object; in mei_amthif_read_start()
270 dev->iamthif_current_cb = cb; in mei_amthif_read_start()
288 struct mei_device *dev; in mei_amthif_send_cmd() local
291 if (!cl->dev || !cb) in mei_amthif_send_cmd()
294 dev = cl->dev; in mei_amthif_send_cmd()
296 dev->iamthif_state = MEI_IAMTHIF_WRITING; in mei_amthif_send_cmd()
297 dev->iamthif_current_cb = cb; in mei_amthif_send_cmd()
298 dev->iamthif_file_object = cb->file_object; in mei_amthif_send_cmd()
299 dev->iamthif_canceled = false; in mei_amthif_send_cmd()
318 int mei_amthif_run_next_cmd(struct mei_device *dev) in mei_amthif_run_next_cmd() argument
320 struct mei_cl *cl = &dev->iamthif_cl; in mei_amthif_run_next_cmd()
323 dev->iamthif_canceled = false; in mei_amthif_run_next_cmd()
324 dev->iamthif_state = MEI_IAMTHIF_IDLE; in mei_amthif_run_next_cmd()
325 dev->iamthif_timer = 0; in mei_amthif_run_next_cmd()
326 dev->iamthif_file_object = NULL; in mei_amthif_run_next_cmd()
328 dev_dbg(dev->dev, "complete amthif cmd_list cb.\n"); in mei_amthif_run_next_cmd()
330 cb = list_first_entry_or_null(&dev->amthif_cmd_list.list, in mei_amthif_run_next_cmd()
350 struct mei_device *dev; in mei_amthif_write() local
352 if (WARN_ON(!cl || !cl->dev)) in mei_amthif_write()
358 dev = cl->dev; in mei_amthif_write()
360 list_add_tail(&cb->list, &dev->amthif_cmd_list.list); in mei_amthif_write()
361 return mei_amthif_run_next_cmd(dev); in mei_amthif_write()
376 unsigned int mei_amthif_poll(struct mei_device *dev, in mei_amthif_poll() argument
381 poll_wait(file, &dev->iamthif_cl.wait, wait); in mei_amthif_poll()
383 if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE && in mei_amthif_poll()
384 dev->iamthif_file_object == file) { in mei_amthif_poll()
387 mei_amthif_run_next_cmd(dev); in mei_amthif_poll()
433 struct mei_device *dev; in mei_amthif_irq_read_msg() local
436 dev = cl->dev; in mei_amthif_irq_read_msg()
438 if (dev->iamthif_state != MEI_IAMTHIF_READING) in mei_amthif_irq_read_msg()
448 dev_dbg(dev->dev, "completed amthif read.\n "); in mei_amthif_irq_read_msg()
449 dev->iamthif_current_cb = NULL; in mei_amthif_irq_read_msg()
450 dev->iamthif_stall_timer = 0; in mei_amthif_irq_read_msg()
461 void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb) in mei_amthif_complete() argument
466 dev->iamthif_stall_timer = MEI_IAMTHIF_STALL_TIMER; in mei_amthif_complete()
474 list_add_tail(&cb->list, &dev->amthif_rd_complete_list.list); in mei_amthif_complete()
475 wake_up_interruptible(&dev->iamthif_cl.wait); in mei_amthif_complete()
479 if (dev->iamthif_canceled != 1) { in mei_amthif_complete()
480 dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE; in mei_amthif_complete()
481 dev->iamthif_stall_timer = 0; in mei_amthif_complete()
482 list_add_tail(&cb->list, &dev->amthif_rd_complete_list.list); in mei_amthif_complete()
483 dev_dbg(dev->dev, "amthif read completed\n"); in mei_amthif_complete()
484 dev->iamthif_timer = jiffies; in mei_amthif_complete()
485 dev_dbg(dev->dev, "dev->iamthif_timer = %ld\n", in mei_amthif_complete()
486 dev->iamthif_timer); in mei_amthif_complete()
488 mei_amthif_run_next_cmd(dev); in mei_amthif_complete()
491 dev_dbg(dev->dev, "completing amthif call back.\n"); in mei_amthif_complete()
492 wake_up_interruptible(&dev->iamthif_cl.wait); in mei_amthif_complete()
508 static bool mei_clear_list(struct mei_device *dev, in mei_clear_list() argument
511 struct mei_cl *cl = &dev->iamthif_cl; in mei_clear_list()
520 if (dev->iamthif_current_cb == cb) { in mei_clear_list()
521 dev->iamthif_current_cb = NULL; in mei_clear_list()
523 mei_hbm_cl_flow_control_req(dev, cl); in mei_clear_list()
544 static bool mei_clear_lists(struct mei_device *dev, struct file *file) in mei_clear_lists() argument
549 mei_clear_list(dev, file, &dev->amthif_cmd_list.list); in mei_clear_lists()
550 if (mei_clear_list(dev, file, &dev->amthif_rd_complete_list.list)) in mei_clear_lists()
553 mei_clear_list(dev, file, &dev->ctrl_rd_list.list); in mei_clear_lists()
555 if (mei_clear_list(dev, file, &dev->ctrl_wr_list.list)) in mei_clear_lists()
558 if (mei_clear_list(dev, file, &dev->write_waiting_list.list)) in mei_clear_lists()
561 if (mei_clear_list(dev, file, &dev->write_list.list)) in mei_clear_lists()
565 if (dev->iamthif_current_cb && !removed) { in mei_clear_lists()
567 if (dev->iamthif_current_cb->file_object == file) { in mei_clear_lists()
569 mei_io_cb_free(dev->iamthif_current_cb); in mei_clear_lists()
570 dev->iamthif_current_cb = NULL; in mei_clear_lists()
585 int mei_amthif_release(struct mei_device *dev, struct file *file) in mei_amthif_release() argument
587 if (dev->iamthif_open_count > 0) in mei_amthif_release()
588 dev->iamthif_open_count--; in mei_amthif_release()
590 if (dev->iamthif_file_object == file && in mei_amthif_release()
591 dev->iamthif_state != MEI_IAMTHIF_IDLE) { in mei_amthif_release()
593 dev_dbg(dev->dev, "amthif canceled iamthif state %d\n", in mei_amthif_release()
594 dev->iamthif_state); in mei_amthif_release()
595 dev->iamthif_canceled = true; in mei_amthif_release()
596 if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE) { in mei_amthif_release()
597 dev_dbg(dev->dev, "run next amthif iamthif cb\n"); in mei_amthif_release()
598 mei_amthif_run_next_cmd(dev); in mei_amthif_release()
602 if (mei_clear_lists(dev, file)) in mei_amthif_release()
603 dev->iamthif_state = MEI_IAMTHIF_IDLE; in mei_amthif_release()