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()
167 static long cec_adap_s_log_addrs(struct cec_adapter *adap, struct cec_fh *fh, in cec_adap_s_log_addrs() argument
183 !cec_is_busy(adap, fh)) { in cec_adap_s_log_addrs()
211 static long cec_transmit(struct cec_adapter *adap, struct cec_fh *fh, in cec_transmit() argument
227 else if (cec_is_busy(adap, fh)) in cec_transmit()
230 err = cec_transmit_msg_fh(adap, &msg, fh, block); in cec_transmit()
240 static int cec_receive_msg(struct cec_fh *fh, struct cec_msg *msg, bool block) in cec_receive_msg() argument
246 mutex_lock(&fh->lock); in cec_receive_msg()
248 if (fh->queued_msgs) { in cec_receive_msg()
251 list_first_entry(&fh->msgs, in cec_receive_msg()
257 fh->queued_msgs--; in cec_receive_msg()
258 mutex_unlock(&fh->lock); in cec_receive_msg()
265 mutex_unlock(&fh->lock); in cec_receive_msg()
273 res = wait_event_interruptible_timeout(fh->wait, in cec_receive_msg()
274 fh->queued_msgs, in cec_receive_msg()
282 res = wait_event_interruptible(fh->wait, in cec_receive_msg()
283 fh->queued_msgs); in cec_receive_msg()
290 static long cec_receive(struct cec_adapter *adap, struct cec_fh *fh, in cec_receive() argument
299 err = cec_receive_msg(fh, &msg, block); in cec_receive()
308 static long cec_dqevent(struct cec_adapter *adap, struct cec_fh *fh, in cec_dqevent() argument
317 mutex_lock(&fh->lock); in cec_dqevent()
318 while (!fh->total_queued_events && block) { in cec_dqevent()
319 mutex_unlock(&fh->lock); in cec_dqevent()
320 err = wait_event_interruptible(fh->wait, in cec_dqevent()
321 fh->total_queued_events); in cec_dqevent()
324 mutex_lock(&fh->lock); in cec_dqevent()
330 list_first_entry_or_null(&fh->events[i], in cec_dqevent()
350 fh->queued_events[ev_idx]--; in cec_dqevent()
351 fh->total_queued_events--; in cec_dqevent()
354 mutex_unlock(&fh->lock); in cec_dqevent()
358 static long cec_g_mode(struct cec_adapter *adap, struct cec_fh *fh, in cec_g_mode() argument
361 u32 mode = fh->mode_initiator | fh->mode_follower; in cec_g_mode()
368 static long cec_s_mode(struct cec_adapter *adap, struct cec_fh *fh, in cec_s_mode() argument
432 adap->cec_follower && adap->cec_follower != fh) in cec_s_mode()
439 adap->cec_initiator && adap->cec_initiator != fh) in cec_s_mode()
443 bool old_mon_all = fh->mode_follower == CEC_MODE_MONITOR_ALL; in cec_s_mode()
455 bool old_mon_pin = fh->mode_follower == CEC_MODE_MONITOR_PIN; in cec_s_mode()
472 if (fh->mode_follower == CEC_MODE_FOLLOWER) in cec_s_mode()
483 cec_queue_event_fh(fh, &ev, 0); in cec_s_mode()
489 adap->cec_follower = fh; in cec_s_mode()
490 } else if (adap->cec_follower == fh) { in cec_s_mode()
495 adap->cec_initiator = fh; in cec_s_mode()
496 else if (adap->cec_initiator == fh) in cec_s_mode()
498 fh->mode_initiator = mode_initiator; in cec_s_mode()
499 fh->mode_follower = mode_follower; in cec_s_mode()
506 struct cec_fh *fh = filp->private_data; in cec_ioctl() local
507 struct cec_adapter *adap = fh->adap; in cec_ioctl()
522 return cec_adap_s_phys_addr(adap, fh, block, parg); in cec_ioctl()
528 return cec_adap_s_log_addrs(adap, fh, block, parg); in cec_ioctl()
534 return cec_transmit(adap, fh, block, parg); in cec_ioctl()
537 return cec_receive(adap, fh, block, parg); in cec_ioctl()
540 return cec_dqevent(adap, fh, block, parg); in cec_ioctl()
543 return cec_g_mode(adap, fh, parg); in cec_ioctl()
546 return cec_s_mode(adap, fh, parg); in cec_ioctl()
558 struct cec_fh *fh = kzalloc(sizeof(*fh), GFP_KERNEL); in cec_open() local
570 if (!fh) in cec_open()
573 INIT_LIST_HEAD(&fh->msgs); in cec_open()
574 INIT_LIST_HEAD(&fh->xfer_list); in cec_open()
576 INIT_LIST_HEAD(&fh->events[i]); in cec_open()
577 mutex_init(&fh->lock); in cec_open()
578 init_waitqueue_head(&fh->wait); in cec_open()
580 fh->mode_initiator = CEC_MODE_INITIATOR; in cec_open()
581 fh->adap = adap; in cec_open()
585 kfree(fh); in cec_open()
589 filp->private_data = fh; in cec_open()
596 cec_queue_event_fh(fh, &ev, 0); in cec_open()
604 cec_queue_event_fh(fh, &ev, 0); in cec_open()
613 cec_queue_event_fh(fh, &ev, 0); in cec_open()
620 list_add(&fh->list, &devnode->fhs); in cec_open()
632 struct cec_fh *fh = filp->private_data; in cec_release() local
636 if (adap->cec_initiator == fh) in cec_release()
638 if (adap->cec_follower == fh) { in cec_release()
642 if (fh->mode_follower == CEC_MODE_FOLLOWER) in cec_release()
644 if (fh->mode_follower == CEC_MODE_MONITOR_PIN) in cec_release()
646 if (fh->mode_follower == CEC_MODE_MONITOR_ALL) in cec_release()
652 list_del(&fh->list); in cec_release()
658 while (!list_empty(&fh->xfer_list)) { in cec_release()
660 list_first_entry(&fh->xfer_list, struct cec_data, xfer_list); in cec_release()
663 data->fh = NULL; in cec_release()
667 while (!list_empty(&fh->msgs)) { in cec_release()
669 list_first_entry(&fh->msgs, struct cec_msg_entry, list); in cec_release()
675 while (!list_empty(&fh->events[i])) { in cec_release()
677 list_first_entry(&fh->events[i], in cec_release()
684 kfree(fh); in cec_release()