Lines Matching refs:cl
48 struct mei_cl *cl; in mei_open() local
65 cl = mei_cl_alloc_linked(dev); in mei_open()
66 if (IS_ERR(cl)) { in mei_open()
67 err = PTR_ERR(cl); in mei_open()
71 cl->fp = file; in mei_open()
72 file->private_data = cl; in mei_open()
90 static void mei_cl_vtag_remove_by_fp(const struct mei_cl *cl, in mei_cl_vtag_remove_by_fp() argument
95 list_for_each_entry_safe(vtag_l, next, &cl->vtag_map, list) { in mei_cl_vtag_remove_by_fp()
114 struct mei_cl *cl = file->private_data; in mei_release() local
118 if (WARN_ON(!cl || !cl->dev)) in mei_release()
121 dev = cl->dev; in mei_release()
125 mei_cl_vtag_remove_by_fp(cl, file); in mei_release()
127 if (!list_empty(&cl->vtag_map)) { in mei_release()
128 cl_dbg(dev, cl, "not the last vtag\n"); in mei_release()
129 mei_cl_flush_queues(cl, file); in mei_release()
134 rets = mei_cl_disconnect(cl); in mei_release()
139 if (!list_empty(&cl->vtag_map)) { in mei_release()
140 cl_dbg(dev, cl, "not the last vtag after disconnect\n"); in mei_release()
141 mei_cl_flush_queues(cl, file); in mei_release()
145 mei_cl_flush_queues(cl, NULL); in mei_release()
146 cl_dbg(dev, cl, "removing\n"); in mei_release()
148 mei_cl_unlink(cl); in mei_release()
149 kfree(cl); in mei_release()
172 struct mei_cl *cl = file->private_data; in mei_read() local
178 if (WARN_ON(!cl || !cl->dev)) in mei_read()
181 dev = cl->dev; in mei_read()
200 cb = mei_cl_read_cb(cl, file); in mei_read()
207 rets = mei_cl_read_start(cl, length, file); in mei_read()
209 cl_dbg(dev, cl, "mei start read failure status = %zd\n", rets); in mei_read()
219 if (wait_event_interruptible(cl->rx_wait, in mei_read()
220 mei_cl_read_cb(cl, file) || in mei_read()
221 !mei_cl_is_connected(cl))) { in mei_read()
228 if (!mei_cl_is_connected(cl)) { in mei_read()
233 cb = mei_cl_read_cb(cl, file); in mei_read()
243 cl_dbg(dev, cl, "read operation failed %zd\n", rets); in mei_read()
247 cl_dbg(dev, cl, "buf.size = %zu buf.idx = %zu offset = %lld\n", in mei_read()
271 mei_cl_del_rd_completed(cl, cb); in mei_read()
275 cl_dbg(dev, cl, "end mei read rets = %zd\n", rets); in mei_read()
288 static u8 mei_cl_vtag_by_fp(const struct mei_cl *cl, const struct file *fp) in mei_cl_vtag_by_fp() argument
295 list_for_each_entry(cl_vtag, &cl->vtag_map, list) in mei_cl_vtag_by_fp()
314 struct mei_cl *cl = file->private_data; in mei_write() local
319 if (WARN_ON(!cl || !cl->dev)) in mei_write()
322 dev = cl->dev; in mei_write()
331 if (!mei_cl_is_connected(cl)) { in mei_write()
332 cl_err(dev, cl, "is not connected"); in mei_write()
337 if (!mei_me_cl_is_active(cl->me_cl)) { in mei_write()
342 if (length > mei_cl_mtu(cl)) { in mei_write()
352 while (cl->tx_cb_queued >= dev->tx_queue_limit) { in mei_write()
358 rets = wait_event_interruptible(cl->tx_wait, in mei_write()
359 cl->writing_state == MEI_WRITE_COMPLETE || in mei_write()
360 (!mei_cl_is_connected(cl))); in mei_write()
367 if (!mei_cl_is_connected(cl)) { in mei_write()
373 cb = mei_cl_alloc_cb(cl, length, MEI_FOP_WRITE, file); in mei_write()
378 cb->vtag = mei_cl_vtag_by_fp(cl, file); in mei_write()
388 rets = mei_cl_write(cl, cb); in mei_write()
411 struct mei_cl *cl; in mei_ioctl_connect_client() local
414 cl = file->private_data; in mei_ioctl_connect_client()
415 dev = cl->dev; in mei_ioctl_connect_client()
417 if (cl->state != MEI_FILE_INITIALIZING && in mei_ioctl_connect_client()
418 cl->state != MEI_FILE_DISCONNECTED) in mei_ioctl_connect_client()
453 rets = mei_cl_connect(cl, me_cl, file); in mei_ioctl_connect_client()
511 struct mei_cl *cl; in mei_ioctl_connect_vtag() local
515 cl = file->private_data; in mei_ioctl_connect_vtag()
516 dev = cl->dev; in mei_ioctl_connect_vtag()
520 switch (cl->state) { in mei_ioctl_connect_vtag()
522 if (mei_cl_vtag_by_fp(cl, file) != vtag) { in mei_ioctl_connect_vtag()
529 if (!IS_ERR(mei_cl_fp_by_vtag(cl, vtag))) { in mei_ioctl_connect_vtag()
535 if (pos == cl) in mei_ioctl_connect_vtag()
550 mei_cl_unlink(cl); in mei_ioctl_connect_vtag()
551 kfree(cl); in mei_ioctl_connect_vtag()
553 cl = pos; in mei_ioctl_connect_vtag()
561 list_add_tail(&cl_vtag->list, &cl->vtag_map); in mei_ioctl_connect_vtag()
567 while (cl->state != MEI_FILE_INITIALIZING && in mei_ioctl_connect_vtag()
568 cl->state != MEI_FILE_DISCONNECTED && in mei_ioctl_connect_vtag()
569 cl->state != MEI_FILE_CONNECTED) { in mei_ioctl_connect_vtag()
571 wait_event_timeout(cl->wait, in mei_ioctl_connect_vtag()
572 (cl->state == MEI_FILE_CONNECTED || in mei_ioctl_connect_vtag()
573 cl->state == MEI_FILE_DISCONNECTED || in mei_ioctl_connect_vtag()
574 cl->state == MEI_FILE_DISCONNECT_REQUIRED || in mei_ioctl_connect_vtag()
575 cl->state == MEI_FILE_DISCONNECT_REPLY), in mei_ioctl_connect_vtag()
580 if (!mei_cl_is_connected(cl)) in mei_ioctl_connect_vtag()
583 client->max_msg_length = cl->me_cl->props.max_msg_length; in mei_ioctl_connect_vtag()
584 client->protocol_version = cl->me_cl->props.protocol_version; in mei_ioctl_connect_vtag()
600 struct mei_cl *cl = file->private_data; in mei_ioctl_client_notify_request() local
606 return mei_cl_notify_request(cl, file, (u8)request); in mei_ioctl_client_notify_request()
619 struct mei_cl *cl = file->private_data; in mei_ioctl_client_notify_get() local
624 rets = mei_cl_notify_get(cl, block, ¬ify_ev); in mei_ioctl_client_notify_get()
644 struct mei_cl *cl = file->private_data; in mei_ioctl() local
654 if (WARN_ON(!cl || !cl->dev)) in mei_ioctl()
657 dev = cl->dev; in mei_ioctl()
786 struct mei_cl *cl = file->private_data; in mei_poll() local
791 if (WARN_ON(!cl || !cl->dev)) in mei_poll()
794 dev = cl->dev; in mei_poll()
798 notify_en = cl->notify_en && (req_events & EPOLLPRI); in mei_poll()
801 !mei_cl_is_connected(cl)) { in mei_poll()
807 poll_wait(file, &cl->ev_wait, wait); in mei_poll()
808 if (cl->notify_ev) in mei_poll()
813 poll_wait(file, &cl->rx_wait, wait); in mei_poll()
815 if (mei_cl_read_cb(cl, file)) in mei_poll()
818 mei_cl_read_start(cl, mei_cl_mtu(cl), file); in mei_poll()
822 poll_wait(file, &cl->tx_wait, wait); in mei_poll()
823 if (cl->tx_cb_queued < dev->tx_queue_limit) in mei_poll()
839 static bool mei_cl_is_write_queued(struct mei_cl *cl) in mei_cl_is_write_queued() argument
841 struct mei_device *dev = cl->dev; in mei_cl_is_write_queued()
845 if (cb->cl == cl) in mei_cl_is_write_queued()
848 if (cb->cl == cl) in mei_cl_is_write_queued()
865 struct mei_cl *cl = fp->private_data; in mei_fsync() local
869 if (WARN_ON(!cl || !cl->dev)) in mei_fsync()
872 dev = cl->dev; in mei_fsync()
876 if (dev->dev_state != MEI_DEV_ENABLED || !mei_cl_is_connected(cl)) { in mei_fsync()
881 while (mei_cl_is_write_queued(cl)) { in mei_fsync()
883 rets = wait_event_interruptible(cl->tx_wait, in mei_fsync()
884 cl->writing_state == MEI_WRITE_COMPLETE || in mei_fsync()
885 !mei_cl_is_connected(cl)); in mei_fsync()
892 if (!mei_cl_is_connected(cl)) { in mei_fsync()
917 struct mei_cl *cl = file->private_data; in mei_fasync() local
919 if (!mei_cl_is_connected(cl)) in mei_fasync()
922 return fasync_helper(fd, file, band, &cl->ev_async); in mei_fasync()