Lines Matching refs:fh
27 struct cec_fh *fh = filp->private_data; in cec_devnode_data() local
29 return &fh->adap->devnode; in cec_devnode_data()
37 struct cec_fh *fh = filp->private_data; in cec_poll() local
38 struct cec_adapter *adap = fh->adap; in cec_poll()
41 poll_wait(filp, &fh->wait, poll); in cec_poll()
48 if (fh->queued_msgs) in cec_poll()
50 if (fh->total_queued_events) in cec_poll()
57 const struct cec_fh *fh) in cec_is_busy() argument
59 bool valid_initiator = adap->cec_initiator && adap->cec_initiator == fh; in cec_is_busy()
60 bool valid_follower = adap->cec_follower && adap->cec_follower == fh; in cec_is_busy()
72 fh->mode_initiator == CEC_MODE_NO_INITIATOR; in cec_is_busy()
121 static long cec_adap_s_phys_addr(struct cec_adapter *adap, struct cec_fh *fh, in cec_adap_s_phys_addr() argument
136 if (cec_is_busy(adap, fh)) in cec_adap_s_phys_addr()
161 static long cec_adap_s_log_addrs(struct cec_adapter *adap, struct cec_fh *fh, in cec_adap_s_log_addrs() argument
177 !cec_is_busy(adap, fh)) { in cec_adap_s_log_addrs()
190 static long cec_transmit(struct cec_adapter *adap, struct cec_fh *fh, in cec_transmit() argument
206 else if (cec_is_busy(adap, fh)) in cec_transmit()
209 err = cec_transmit_msg_fh(adap, &msg, fh, block); in cec_transmit()
219 static int cec_receive_msg(struct cec_fh *fh, struct cec_msg *msg, bool block) in cec_receive_msg() argument
225 mutex_lock(&fh->lock); in cec_receive_msg()
227 if (fh->queued_msgs) { in cec_receive_msg()
230 list_first_entry(&fh->msgs, in cec_receive_msg()
236 fh->queued_msgs--; in cec_receive_msg()
237 mutex_unlock(&fh->lock); in cec_receive_msg()
244 mutex_unlock(&fh->lock); in cec_receive_msg()
252 res = wait_event_interruptible_timeout(fh->wait, in cec_receive_msg()
253 fh->queued_msgs, in cec_receive_msg()
261 res = wait_event_interruptible(fh->wait, in cec_receive_msg()
262 fh->queued_msgs); in cec_receive_msg()
269 static long cec_receive(struct cec_adapter *adap, struct cec_fh *fh, in cec_receive() argument
278 err = cec_receive_msg(fh, &msg, block); in cec_receive()
287 static long cec_dqevent(struct cec_adapter *adap, struct cec_fh *fh, in cec_dqevent() argument
296 mutex_lock(&fh->lock); in cec_dqevent()
297 while (!fh->total_queued_events && block) { in cec_dqevent()
298 mutex_unlock(&fh->lock); in cec_dqevent()
299 err = wait_event_interruptible(fh->wait, in cec_dqevent()
300 fh->total_queued_events); in cec_dqevent()
303 mutex_lock(&fh->lock); in cec_dqevent()
309 list_first_entry_or_null(&fh->events[i], in cec_dqevent()
329 fh->queued_events[ev_idx]--; in cec_dqevent()
330 fh->total_queued_events--; in cec_dqevent()
333 mutex_unlock(&fh->lock); in cec_dqevent()
337 static long cec_g_mode(struct cec_adapter *adap, struct cec_fh *fh, in cec_g_mode() argument
340 u32 mode = fh->mode_initiator | fh->mode_follower; in cec_g_mode()
347 static long cec_s_mode(struct cec_adapter *adap, struct cec_fh *fh, in cec_s_mode() argument
411 adap->cec_follower && adap->cec_follower != fh) in cec_s_mode()
418 adap->cec_initiator && adap->cec_initiator != fh) in cec_s_mode()
422 bool old_mon_all = fh->mode_follower == CEC_MODE_MONITOR_ALL; in cec_s_mode()
434 bool old_mon_pin = fh->mode_follower == CEC_MODE_MONITOR_PIN; in cec_s_mode()
451 if (fh->mode_follower == CEC_MODE_FOLLOWER) in cec_s_mode()
462 cec_queue_event_fh(fh, &ev, 0); in cec_s_mode()
468 adap->cec_follower = fh; in cec_s_mode()
469 } else if (adap->cec_follower == fh) { in cec_s_mode()
474 adap->cec_initiator = fh; in cec_s_mode()
475 else if (adap->cec_initiator == fh) in cec_s_mode()
477 fh->mode_initiator = mode_initiator; in cec_s_mode()
478 fh->mode_follower = mode_follower; in cec_s_mode()
485 struct cec_fh *fh = filp->private_data; in cec_ioctl() local
486 struct cec_adapter *adap = fh->adap; in cec_ioctl()
501 return cec_adap_s_phys_addr(adap, fh, block, parg); in cec_ioctl()
507 return cec_adap_s_log_addrs(adap, fh, block, parg); in cec_ioctl()
510 return cec_transmit(adap, fh, block, parg); in cec_ioctl()
513 return cec_receive(adap, fh, block, parg); in cec_ioctl()
516 return cec_dqevent(adap, fh, block, parg); in cec_ioctl()
519 return cec_g_mode(adap, fh, parg); in cec_ioctl()
522 return cec_s_mode(adap, fh, parg); in cec_ioctl()
534 struct cec_fh *fh = kzalloc(sizeof(*fh), GFP_KERNEL); in cec_open() local
546 if (!fh) in cec_open()
549 INIT_LIST_HEAD(&fh->msgs); in cec_open()
550 INIT_LIST_HEAD(&fh->xfer_list); in cec_open()
552 INIT_LIST_HEAD(&fh->events[i]); in cec_open()
553 mutex_init(&fh->lock); in cec_open()
554 init_waitqueue_head(&fh->wait); in cec_open()
556 fh->mode_initiator = CEC_MODE_INITIATOR; in cec_open()
557 fh->adap = adap; in cec_open()
561 kfree(fh); in cec_open()
572 kfree(fh); in cec_open()
576 filp->private_data = fh; in cec_open()
581 cec_queue_event_fh(fh, &ev, 0); in cec_open()
588 cec_queue_event_fh(fh, &ev, 0); in cec_open()
596 cec_queue_event_fh(fh, &ev, 0); in cec_open()
601 list_add(&fh->list, &devnode->fhs); in cec_open()
612 struct cec_fh *fh = filp->private_data; in cec_release() local
616 if (adap->cec_initiator == fh) in cec_release()
618 if (adap->cec_follower == fh) { in cec_release()
622 if (fh->mode_follower == CEC_MODE_FOLLOWER) in cec_release()
624 if (fh->mode_follower == CEC_MODE_MONITOR_PIN) in cec_release()
626 if (fh->mode_follower == CEC_MODE_MONITOR_ALL) in cec_release()
631 list_del(&fh->list); in cec_release()
640 while (!list_empty(&fh->xfer_list)) { in cec_release()
642 list_first_entry(&fh->xfer_list, struct cec_data, xfer_list); in cec_release()
645 data->fh = NULL; in cec_release()
649 while (!list_empty(&fh->msgs)) { in cec_release()
651 list_first_entry(&fh->msgs, struct cec_msg_entry, list); in cec_release()
657 while (!list_empty(&fh->events[i])) { in cec_release()
659 list_first_entry(&fh->events[i], in cec_release()
666 kfree(fh); in cec_release()