Lines Matching +full:input +full:- +full:only

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Support for polling mode for input devices.
7 #include <linux/input.h>
13 #include "input-poller.h"
22 struct input_dev *input; member
30 delay = msecs_to_jiffies(poller->poll_interval); in input_dev_poller_queue_work()
34 queue_delayed_work(system_freezable_wq, &poller->work, delay); in input_dev_poller_queue_work()
42 poller->poll(poller->input); in input_dev_poller_work()
48 if (!poller->poll_interval) in input_dev_poller_finalize()
49 poller->poll_interval = 500; in input_dev_poller_finalize()
50 if (!poller->poll_interval_max) in input_dev_poller_finalize()
51 poller->poll_interval_max = poller->poll_interval; in input_dev_poller_finalize()
56 /* Only start polling if polling is enabled */ in input_dev_poller_start()
57 if (poller->poll_interval > 0) { in input_dev_poller_start()
58 poller->poll(poller->input); in input_dev_poller_start()
65 cancel_delayed_work_sync(&poller->work); in input_dev_poller_stop()
77 * printed backtrace as knowing what instance of input in input_setup_polling()
80 dev_err(dev->dev.parent ?: &dev->dev, in input_setup_polling()
82 return -ENOMEM; in input_setup_polling()
85 INIT_DELAYED_WORK(&poller->work, input_dev_poller_work); in input_setup_polling()
86 poller->input = dev; in input_setup_polling()
87 poller->poll = poll_fn; in input_setup_polling()
89 dev->poller = poller; in input_setup_polling()
96 if (!dev->poller) { in input_dev_ensure_poller()
97 dev_err(dev->dev.parent ?: &dev->dev, in input_dev_ensure_poller()
108 dev->poller->poll_interval = interval; in input_set_poll_interval()
115 dev->poller->poll_interval_min = interval; in input_set_min_poll_interval()
122 dev->poller->poll_interval_max = interval; in input_set_max_poll_interval()
128 if (!dev->poller) in input_get_poll_interval()
129 return -EINVAL; in input_get_poll_interval()
131 return dev->poller->poll_interval; in input_get_poll_interval()
141 struct input_dev *input = to_input_dev(dev); in input_dev_get_poll_interval() local
143 return sprintf(buf, "%d\n", input->poller->poll_interval); in input_dev_get_poll_interval()
150 struct input_dev *input = to_input_dev(dev); in input_dev_set_poll_interval() local
151 struct input_dev_poller *poller = input->poller; in input_dev_set_poll_interval()
159 if (interval < poller->poll_interval_min) in input_dev_set_poll_interval()
160 return -EINVAL; in input_dev_set_poll_interval()
162 if (interval > poller->poll_interval_max) in input_dev_set_poll_interval()
163 return -EINVAL; in input_dev_set_poll_interval()
165 mutex_lock(&input->mutex); in input_dev_set_poll_interval()
167 poller->poll_interval = interval; in input_dev_set_poll_interval()
169 if (input_device_enabled(input)) { in input_dev_set_poll_interval()
170 cancel_delayed_work_sync(&poller->work); in input_dev_set_poll_interval()
171 if (poller->poll_interval > 0) in input_dev_set_poll_interval()
175 mutex_unlock(&input->mutex); in input_dev_set_poll_interval()
186 struct input_dev *input = to_input_dev(dev); in input_dev_get_poll_max() local
188 return sprintf(buf, "%d\n", input->poller->poll_interval_max); in input_dev_get_poll_max()
196 struct input_dev *input = to_input_dev(dev); in input_dev_get_poll_min() local
198 return sprintf(buf, "%d\n", input->poller->poll_interval_min); in input_dev_get_poll_min()
207 struct input_dev *input = to_input_dev(dev); in input_poller_attrs_visible() local
209 return input->poller ? attr->mode : 0; in input_poller_attrs_visible()