Lines Matching refs:cl

48 	struct mei_cl *cl;  in mei_open()  local
63 cl = mei_cl_alloc_linked(dev); in mei_open()
64 if (IS_ERR(cl)) { in mei_open()
65 err = PTR_ERR(cl); in mei_open()
69 cl->fp = file; in mei_open()
70 file->private_data = cl; in mei_open()
88 static void mei_cl_vtag_remove_by_fp(const struct mei_cl *cl, in mei_cl_vtag_remove_by_fp() argument
93 list_for_each_entry_safe(vtag_l, next, &cl->vtag_map, list) { in mei_cl_vtag_remove_by_fp()
112 struct mei_cl *cl = file->private_data; in mei_release() local
116 if (WARN_ON(!cl || !cl->dev)) in mei_release()
119 dev = cl->dev; in mei_release()
123 mei_cl_vtag_remove_by_fp(cl, file); in mei_release()
125 if (!list_empty(&cl->vtag_map)) { in mei_release()
126 cl_dbg(dev, cl, "not the last vtag\n"); in mei_release()
127 mei_cl_flush_queues(cl, file); in mei_release()
132 rets = mei_cl_disconnect(cl); in mei_release()
137 if (!list_empty(&cl->vtag_map)) { in mei_release()
138 cl_dbg(dev, cl, "not the last vtag after disconnect\n"); in mei_release()
139 mei_cl_flush_queues(cl, file); in mei_release()
143 mei_cl_flush_queues(cl, NULL); in mei_release()
144 cl_dbg(dev, cl, "removing\n"); in mei_release()
146 mei_cl_unlink(cl); in mei_release()
147 kfree(cl); in mei_release()
170 struct mei_cl *cl = file->private_data; in mei_read() local
176 if (WARN_ON(!cl || !cl->dev)) in mei_read()
179 dev = cl->dev; in mei_read()
198 cb = mei_cl_read_cb(cl, file); in mei_read()
205 rets = mei_cl_read_start(cl, length, file); in mei_read()
207 cl_dbg(dev, cl, "mei start read failure status = %zd\n", rets); in mei_read()
217 if (wait_event_interruptible(cl->rx_wait, in mei_read()
218 mei_cl_read_cb(cl, file) || in mei_read()
219 !mei_cl_is_connected(cl))) { in mei_read()
226 if (!mei_cl_is_connected(cl)) { in mei_read()
231 cb = mei_cl_read_cb(cl, file); in mei_read()
241 cl_dbg(dev, cl, "read operation failed %zd\n", rets); in mei_read()
245 cl_dbg(dev, cl, "buf.size = %zu buf.idx = %zu offset = %lld\n", in mei_read()
269 mei_cl_del_rd_completed(cl, cb); in mei_read()
273 cl_dbg(dev, cl, "end mei read rets = %zd\n", rets); in mei_read()
286 static u8 mei_cl_vtag_by_fp(const struct mei_cl *cl, const struct file *fp) in mei_cl_vtag_by_fp() argument
293 list_for_each_entry(cl_vtag, &cl->vtag_map, list) in mei_cl_vtag_by_fp()
312 struct mei_cl *cl = file->private_data; in mei_write() local
317 if (WARN_ON(!cl || !cl->dev)) in mei_write()
320 dev = cl->dev; in mei_write()
329 if (!mei_cl_is_connected(cl)) { in mei_write()
330 cl_err(dev, cl, "is not connected"); in mei_write()
335 if (!mei_me_cl_is_active(cl->me_cl)) { in mei_write()
340 if (length > mei_cl_mtu(cl)) { in mei_write()
350 while (cl->tx_cb_queued >= dev->tx_queue_limit) { in mei_write()
356 rets = wait_event_interruptible(cl->tx_wait, in mei_write()
357 cl->writing_state == MEI_WRITE_COMPLETE || in mei_write()
358 (!mei_cl_is_connected(cl))); in mei_write()
365 if (!mei_cl_is_connected(cl)) { in mei_write()
371 cb = mei_cl_alloc_cb(cl, length, MEI_FOP_WRITE, file); in mei_write()
376 cb->vtag = mei_cl_vtag_by_fp(cl, file); in mei_write()
386 rets = mei_cl_write(cl, cb); in mei_write()
409 struct mei_cl *cl; in mei_ioctl_connect_client() local
412 cl = file->private_data; in mei_ioctl_connect_client()
413 dev = cl->dev; in mei_ioctl_connect_client()
415 if (cl->state != MEI_FILE_INITIALIZING && in mei_ioctl_connect_client()
416 cl->state != MEI_FILE_DISCONNECTED) in mei_ioctl_connect_client()
451 rets = mei_cl_connect(cl, me_cl, file); in mei_ioctl_connect_client()
509 struct mei_cl *cl; in mei_ioctl_connect_vtag() local
513 cl = file->private_data; in mei_ioctl_connect_vtag()
514 dev = cl->dev; in mei_ioctl_connect_vtag()
518 switch (cl->state) { in mei_ioctl_connect_vtag()
520 if (mei_cl_vtag_by_fp(cl, file) != vtag) { in mei_ioctl_connect_vtag()
527 if (!IS_ERR(mei_cl_fp_by_vtag(cl, vtag))) { in mei_ioctl_connect_vtag()
533 if (pos == cl) in mei_ioctl_connect_vtag()
548 mei_cl_unlink(cl); in mei_ioctl_connect_vtag()
549 kfree(cl); in mei_ioctl_connect_vtag()
551 cl = pos; in mei_ioctl_connect_vtag()
559 list_add_tail(&cl_vtag->list, &cl->vtag_map); in mei_ioctl_connect_vtag()
565 while (cl->state != MEI_FILE_INITIALIZING && in mei_ioctl_connect_vtag()
566 cl->state != MEI_FILE_DISCONNECTED && in mei_ioctl_connect_vtag()
567 cl->state != MEI_FILE_CONNECTED) { in mei_ioctl_connect_vtag()
569 wait_event_timeout(cl->wait, in mei_ioctl_connect_vtag()
570 (cl->state == MEI_FILE_CONNECTED || in mei_ioctl_connect_vtag()
571 cl->state == MEI_FILE_DISCONNECTED || in mei_ioctl_connect_vtag()
572 cl->state == MEI_FILE_DISCONNECT_REQUIRED || in mei_ioctl_connect_vtag()
573 cl->state == MEI_FILE_DISCONNECT_REPLY), in mei_ioctl_connect_vtag()
578 if (!mei_cl_is_connected(cl)) in mei_ioctl_connect_vtag()
581 client->max_msg_length = cl->me_cl->props.max_msg_length; in mei_ioctl_connect_vtag()
582 client->protocol_version = cl->me_cl->props.protocol_version; in mei_ioctl_connect_vtag()
598 struct mei_cl *cl = file->private_data; in mei_ioctl_client_notify_request() local
604 return mei_cl_notify_request(cl, file, (u8)request); in mei_ioctl_client_notify_request()
617 struct mei_cl *cl = file->private_data; in mei_ioctl_client_notify_get() local
622 rets = mei_cl_notify_get(cl, block, &notify_ev); in mei_ioctl_client_notify_get()
642 struct mei_cl *cl = file->private_data; in mei_ioctl() local
652 if (WARN_ON(!cl || !cl->dev)) in mei_ioctl()
655 dev = cl->dev; in mei_ioctl()
784 struct mei_cl *cl = file->private_data; in mei_poll() local
789 if (WARN_ON(!cl || !cl->dev)) in mei_poll()
792 dev = cl->dev; in mei_poll()
796 notify_en = cl->notify_en && (req_events & EPOLLPRI); in mei_poll()
799 !mei_cl_is_connected(cl)) { in mei_poll()
805 poll_wait(file, &cl->ev_wait, wait); in mei_poll()
806 if (cl->notify_ev) in mei_poll()
811 poll_wait(file, &cl->rx_wait, wait); in mei_poll()
813 if (mei_cl_read_cb(cl, file)) in mei_poll()
816 mei_cl_read_start(cl, mei_cl_mtu(cl), file); in mei_poll()
820 poll_wait(file, &cl->tx_wait, wait); in mei_poll()
821 if (cl->tx_cb_queued < dev->tx_queue_limit) in mei_poll()
837 static bool mei_cl_is_write_queued(struct mei_cl *cl) in mei_cl_is_write_queued() argument
839 struct mei_device *dev = cl->dev; in mei_cl_is_write_queued()
843 if (cb->cl == cl) in mei_cl_is_write_queued()
846 if (cb->cl == cl) in mei_cl_is_write_queued()
863 struct mei_cl *cl = fp->private_data; in mei_fsync() local
867 if (WARN_ON(!cl || !cl->dev)) in mei_fsync()
870 dev = cl->dev; in mei_fsync()
874 if (dev->dev_state != MEI_DEV_ENABLED || !mei_cl_is_connected(cl)) { in mei_fsync()
879 while (mei_cl_is_write_queued(cl)) { in mei_fsync()
881 rets = wait_event_interruptible(cl->tx_wait, in mei_fsync()
882 cl->writing_state == MEI_WRITE_COMPLETE || in mei_fsync()
883 !mei_cl_is_connected(cl)); in mei_fsync()
890 if (!mei_cl_is_connected(cl)) { in mei_fsync()
915 struct mei_cl *cl = file->private_data; in mei_fasync() local
917 if (!mei_cl_is_connected(cl)) in mei_fasync()
920 return fasync_helper(fd, file, band, &cl->ev_async); in mei_fasync()