Lines Matching full:lr

692 	struct linereq *lr = container_of(nb, struct linereq,  in linereq_unregistered_notify()  local
695 wake_up_poll(&lr->wait, EPOLLIN | EPOLLERR); in linereq_unregistered_notify()
700 static void linereq_put_event(struct linereq *lr, in linereq_put_event() argument
705 scoped_guard(spinlock, &lr->wait.lock) { in linereq_put_event()
706 if (kfifo_is_full(&lr->events)) { in linereq_put_event()
708 kfifo_skip(&lr->events); in linereq_put_event()
710 kfifo_in(&lr->events, le, 1); in linereq_put_event()
713 wake_up_poll(&lr->wait, EPOLLIN); in linereq_put_event()
759 struct linereq *lr; in process_hw_ts_thread() local
768 lr = line->req; in process_hw_ts_thread()
796 le.seqno = (lr->num_lines == 1) ? le.line_seqno : line->req_seqno; in process_hw_ts_thread()
799 linereq_put_event(lr, &le); in process_hw_ts_thread()
807 struct linereq *lr; in process_hw_ts() local
816 lr = line->req; in process_hw_ts()
829 if (lr->num_lines != 1) in process_hw_ts()
831 &lr->seqno); in process_hw_ts()
878 struct linereq *lr = line->req; in edge_irq_thread() local
893 if (lr->num_lines != 1) in edge_irq_thread()
894 line->req_seqno = atomic_inc_return(&lr->seqno); in edge_irq_thread()
913 le.seqno = (lr->num_lines == 1) ? le.line_seqno : line->req_seqno; in edge_irq_thread()
916 linereq_put_event(lr, &le); in edge_irq_thread()
924 struct linereq *lr = line->req; in edge_irq_handler() local
932 if (lr->num_lines != 1) in edge_irq_handler()
933 line->req_seqno = atomic_inc_return(&lr->seqno); in edge_irq_handler()
972 struct linereq *lr; in debounce_work_func() local
1010 lr = line->req; in debounce_work_func()
1021 le.seqno = (lr->num_lines == 1) ? in debounce_work_func()
1022 le.line_seqno : atomic_add_return(diff_seqno, &lr->seqno); in debounce_work_func()
1028 le.seqno = (lr->num_lines == 1) ? in debounce_work_func()
1029 le.line_seqno : atomic_inc_return(&lr->seqno); in debounce_work_func()
1034 linereq_put_event(lr, &le); in debounce_work_func()
1385 static long linereq_get_values(struct linereq *lr, void __user *ip) in linereq_get_values() argument
1406 for (num_get = 0, i = 0; i < lr->num_lines; i++) { in linereq_get_values()
1410 descs = &lr->lines[i].desc; in linereq_get_values()
1422 for (didx = 0, i = 0; i < lr->num_lines; i++) { in linereq_get_values()
1424 descs[didx] = lr->lines[i].desc; in linereq_get_values()
1438 for (didx = 0, i = 0; i < lr->num_lines; i++) { in linereq_get_values()
1441 if (lr->lines[i].sw_debounced) in linereq_get_values()
1442 val = debounced_value(&lr->lines[i]); in linereq_get_values()
1457 static long linereq_set_values(struct linereq *lr, void __user *ip) in linereq_set_values() argument
1468 guard(mutex)(&lr->config_mutex); in linereq_set_values()
1479 for (num_set = 0, i = 0; i < lr->num_lines; i++) { in linereq_set_values()
1482 if (!test_bit(FLAG_IS_OUT, &lr->lines[i].desc->flags)) in linereq_set_values()
1489 descs = &lr->lines[i].desc; in linereq_set_values()
1500 for (didx = 0, i = 0; i < lr->num_lines; i++) { in linereq_set_values()
1502 descs[didx] = lr->lines[i].desc; in linereq_set_values()
1515 static long linereq_set_config(struct linereq *lr, void __user *ip) in linereq_set_config() argument
1527 ret = gpio_v2_line_config_validate(&lc, lr->num_lines); in linereq_set_config()
1531 guard(mutex)(&lr->config_mutex); in linereq_set_config()
1533 for (i = 0; i < lr->num_lines; i++) { in linereq_set_config()
1534 line = &lr->lines[i]; in linereq_set_config()
1535 desc = lr->lines[i].desc; in linereq_set_config()
1572 struct linereq *lr = file->private_data; in linereq_ioctl() local
1575 guard(srcu)(&lr->gdev->srcu); in linereq_ioctl()
1577 if (!rcu_access_pointer(lr->gdev->chip)) in linereq_ioctl()
1582 return linereq_get_values(lr, ip); in linereq_ioctl()
1584 return linereq_set_values(lr, ip); in linereq_ioctl()
1586 return linereq_set_config(lr, ip); in linereq_ioctl()
1603 struct linereq *lr = file->private_data; in linereq_poll() local
1606 guard(srcu)(&lr->gdev->srcu); in linereq_poll()
1608 if (!rcu_access_pointer(lr->gdev->chip)) in linereq_poll()
1611 poll_wait(file, &lr->wait, wait); in linereq_poll()
1613 if (!kfifo_is_empty_spinlocked_noirqsave(&lr->events, in linereq_poll()
1614 &lr->wait.lock)) in linereq_poll()
1623 struct linereq *lr = file->private_data; in linereq_read() local
1628 guard(srcu)(&lr->gdev->srcu); in linereq_read()
1630 if (!rcu_access_pointer(lr->gdev->chip)) in linereq_read()
1637 scoped_guard(spinlock, &lr->wait.lock) { in linereq_read()
1638 if (kfifo_is_empty(&lr->events)) { in linereq_read()
1645 ret = wait_event_interruptible_locked(lr->wait, in linereq_read()
1646 !kfifo_is_empty(&lr->events)); in linereq_read()
1651 if (kfifo_out(&lr->events, &le, 1) != 1) { in linereq_read()
1670 static void linereq_free(struct linereq *lr) in linereq_free() argument
1675 if (lr->device_unregistered_nb.notifier_call) in linereq_free()
1676 blocking_notifier_chain_unregister(&lr->gdev->device_notifier, in linereq_free()
1677 &lr->device_unregistered_nb); in linereq_free()
1679 for (i = 0; i < lr->num_lines; i++) { in linereq_free()
1680 line = &lr->lines[i]; in linereq_free()
1689 kfifo_free(&lr->events); in linereq_free()
1690 kfree(lr->label); in linereq_free()
1691 gpio_device_put(lr->gdev); in linereq_free()
1692 kvfree(lr); in linereq_free()
1697 struct linereq *lr = file->private_data; in linereq_release() local
1699 linereq_free(lr); in linereq_release()
1706 struct linereq *lr = file->private_data; in linereq_show_fdinfo() local
1707 struct device *dev = &lr->gdev->dev; in linereq_show_fdinfo()
1712 for (i = 0; i < lr->num_lines; i++) in linereq_show_fdinfo()
1714 gpio_chip_hwgpio(lr->lines[i].desc)); in linereq_show_fdinfo()
1737 struct linereq *lr; in linereq_create() local
1757 lr = kvzalloc(struct_size(lr, lines, ulr.num_lines), GFP_KERNEL); in linereq_create()
1758 if (!lr) in linereq_create()
1760 lr->num_lines = ulr.num_lines; in linereq_create()
1762 lr->gdev = gpio_device_get(gdev); in linereq_create()
1765 lr->lines[i].req = lr; in linereq_create()
1766 WRITE_ONCE(lr->lines[i].sw_debounced, 0); in linereq_create()
1767 INIT_DELAYED_WORK(&lr->lines[i].work, debounce_work_func); in linereq_create()
1772 lr->label = kstrndup(ulr.consumer, sizeof(ulr.consumer) - 1, in linereq_create()
1774 if (!lr->label) { in linereq_create()
1780 mutex_init(&lr->config_mutex); in linereq_create()
1781 init_waitqueue_head(&lr->wait); in linereq_create()
1782 INIT_KFIFO(lr->events); in linereq_create()
1783 lr->event_buffer_size = ulr.event_buffer_size; in linereq_create()
1784 if (lr->event_buffer_size == 0) in linereq_create()
1785 lr->event_buffer_size = ulr.num_lines * 16; in linereq_create()
1786 else if (lr->event_buffer_size > GPIO_V2_LINES_MAX * 16) in linereq_create()
1787 lr->event_buffer_size = GPIO_V2_LINES_MAX * 16; in linereq_create()
1789 atomic_set(&lr->seqno, 0); in linereq_create()
1801 ret = gpiod_request_user(desc, lr->label); in linereq_create()
1805 lr->lines[i].desc = desc; in linereq_create()
1829 ret = edge_detector_setup(&lr->lines[i], lc, i, in linereq_create()
1835 lr->lines[i].edflags = edflags; in linereq_create()
1843 lr->device_unregistered_nb.notifier_call = linereq_unregistered_notify; in linereq_create()
1845 &lr->device_unregistered_nb); in linereq_create()
1855 file = anon_inode_getfile("gpio-line", &line_fileops, lr, in linereq_create()
1876 lr->num_lines); in linereq_create()
1883 linereq_free(lr); in linereq_create()