Lines Matching refs:fpriv
725 struct adf_file *fpriv = NULL; in adf_file_open() local
740 fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); in adf_file_open()
741 if (!fpriv) { in adf_file_open()
746 INIT_LIST_HEAD(&fpriv->head); in adf_file_open()
747 fpriv->obj = obj; in adf_file_open()
748 init_waitqueue_head(&fpriv->event_wait); in adf_file_open()
750 file->private_data = fpriv; in adf_file_open()
759 list_add_tail(&fpriv->head, &obj->file_list); in adf_file_open()
764 kfree(fpriv); in adf_file_open()
772 struct adf_file *fpriv = file->private_data; in adf_file_release() local
773 struct adf_obj *obj = fpriv->obj; in adf_file_release()
781 list_del(&fpriv->head); in adf_file_release()
784 for_each_set_bit(event_type, fpriv->event_subscriptions, in adf_file_release()
789 kfree(fpriv); in adf_file_release()
798 struct adf_file *fpriv = file->private_data; in adf_file_ioctl() local
799 struct adf_obj *obj = fpriv->obj; in adf_file_ioctl()
807 fpriv, cmd, arg); in adf_file_ioctl()
811 ret = adf_interface_ioctl(adf_obj_to_interface(obj), fpriv, cmd, in adf_file_ioctl()
816 ret = adf_device_ioctl(adf_obj_to_device(obj), fpriv, cmd, arg); in adf_file_ioctl()
823 static inline bool adf_file_event_available(struct adf_file *fpriv) in adf_file_event_available() argument
825 int head = fpriv->event_head; in adf_file_event_available()
826 int tail = fpriv->event_tail; in adf_file_event_available()
827 return CIRC_CNT(head, tail, sizeof(fpriv->event_buf)) != 0; in adf_file_event_available()
830 void adf_file_queue_event(struct adf_file *fpriv, struct adf_event *event) in adf_file_queue_event() argument
832 int head = fpriv->event_head; in adf_file_queue_event()
833 int tail = fpriv->event_tail; in adf_file_queue_event()
834 size_t space = CIRC_SPACE(head, tail, sizeof(fpriv->event_buf)); in adf_file_queue_event()
836 CIRC_SPACE_TO_END(head, tail, sizeof(fpriv->event_buf)); in adf_file_queue_event()
839 dev_dbg(&fpriv->obj->dev, in adf_file_queue_event()
846 memcpy(fpriv->event_buf + head, event, event->length); in adf_file_queue_event()
848 memcpy(fpriv->event_buf + head, event, space_to_end); in adf_file_queue_event()
849 memcpy(fpriv->event_buf, (u8 *)event + space_to_end, in adf_file_queue_event()
854 fpriv->event_head = (fpriv->event_head + event->length) & in adf_file_queue_event()
855 (sizeof(fpriv->event_buf) - 1); in adf_file_queue_event()
856 wake_up_interruptible_all(&fpriv->event_wait); in adf_file_queue_event()
859 static ssize_t adf_file_copy_to_user(struct adf_file *fpriv, in adf_file_copy_to_user() argument
868 event_buf = kmalloc(min(buffer_size, sizeof(fpriv->event_buf)), in adf_file_copy_to_user()
873 spin_lock_irqsave(&fpriv->obj->file_lock, flags); in adf_file_copy_to_user()
875 if (!adf_file_event_available(fpriv)) in adf_file_copy_to_user()
878 head = fpriv->event_head; in adf_file_copy_to_user()
879 tail = fpriv->event_tail; in adf_file_copy_to_user()
881 cnt = CIRC_CNT(head, tail, sizeof(fpriv->event_buf)); in adf_file_copy_to_user()
882 cnt_to_end = CIRC_CNT_TO_END(head, tail, sizeof(fpriv->event_buf)); in adf_file_copy_to_user()
886 memcpy(event_buf, fpriv->event_buf + tail, copy_size); in adf_file_copy_to_user()
888 memcpy(event_buf, fpriv->event_buf + tail, cnt_to_end); in adf_file_copy_to_user()
889 memcpy(event_buf + cnt_to_end, fpriv->event_buf, in adf_file_copy_to_user()
893 fpriv->event_tail = (fpriv->event_tail + copy_size) & in adf_file_copy_to_user()
894 (sizeof(fpriv->event_buf) - 1); in adf_file_copy_to_user()
897 spin_unlock_irqrestore(&fpriv->obj->file_lock, flags); in adf_file_copy_to_user()
911 struct adf_file *fpriv = filp->private_data; in adf_file_read() local
914 err = wait_event_interruptible(fpriv->event_wait, in adf_file_read()
915 adf_file_event_available(fpriv)); in adf_file_read()
919 return adf_file_copy_to_user(fpriv, buffer, count); in adf_file_read()
924 struct adf_file *fpriv = filp->private_data; in adf_file_poll() local
927 poll_wait(filp, &fpriv->event_wait, wait); in adf_file_poll()
929 if (adf_file_event_available(fpriv)) in adf_file_poll()