/* * input_mutex protects access to both input_dev_list and input_handler_list. * This also causes input_[un]register_device and input_[un]register_handler * be mutually exclusive which simplifies locking in drivers implementing * input handlers.
*/ static DEFINE_MUTEX(input_mutex);
/* * Pass values first through all filters and then, if event has not been * filtered out, through all open handles. This order is achieved by placing * filters at the head of the list of handles attached to the device, and * placing regular handles at the tail of the list. * * This function is called with dev->event_lock held and interrupts disabled.
*/ staticvoid input_pass_values(struct input_dev *dev, struct input_value *vals, unsignedint count)
{ struct input_handle *handle; struct input_value *v;
if (code == ABS_MT_SLOT) { /* * "Stage" the event; we'll flush it later, when we * get actual touch data.
*/ if (mt && *pval >= 0 && *pval < mt->num_slots)
mt->slot = *pval;
return INPUT_IGNORE_EVENT;
}
is_mt_event = input_is_mt_value(code);
if (!is_mt_event) {
pold = &dev->absinfo[code].value;
} elseif (mt) {
pold = &mt->slots[mt->slot].abs[code - ABS_MT_FIRST];
is_new_slot = mt->slot != dev->absinfo[ABS_MT_SLOT].value;
} else { /* * Bypass filtering for multi-touch events when * not employing slots.
*/
pold = NULL;
}
if (pold) {
*pval = input_defuzz_abs_event(*pval, *pold,
dev->absinfo[code].fuzz); if (*pold == *pval) return INPUT_IGNORE_EVENT;
staticint input_get_disposition(struct input_dev *dev, unsignedint type, unsignedint code, int *pval)
{ int disposition = INPUT_IGNORE_EVENT; int value = *pval;
/* filter-out events from inhibited devices */ if (dev->inhibited) return INPUT_IGNORE_EVENT;
switch (type) {
case EV_SYN: switch (code) { case SYN_CONFIG:
disposition = INPUT_PASS_TO_ALL; break;
case SYN_REPORT:
disposition = INPUT_PASS_TO_HANDLERS | INPUT_FLUSH; break; case SYN_MT_REPORT:
disposition = INPUT_PASS_TO_HANDLERS; break;
} break;
case EV_KEY: if (is_event_supported(code, dev->keybit, KEY_MAX)) {
/* auto-repeat bypasses state updates */ if (value == 2) {
disposition = INPUT_PASS_TO_HANDLERS; break;
}
if (disposition & INPUT_FLUSH) { if (dev->num_vals >= 2)
input_pass_values(dev, dev->vals, dev->num_vals);
dev->num_vals = 0; /* * Reset the timestamp on flush so we won't end up * with a stale one. Note we only need to reset the * monolithic one as we use its presence when deciding * whether to generate a synthetic timestamp.
*/
dev->timestamp[INPUT_CLK_MONO] = ktime_set(0, 0);
} elseif (dev->num_vals >= dev->max_vals - 2) {
dev->vals[dev->num_vals++] = input_value_sync;
input_pass_values(dev, dev->vals, dev->num_vals);
dev->num_vals = 0;
}
}
void input_handle_event(struct input_dev *dev, unsignedint type, unsignedint code, int value)
{ int disposition;
lockdep_assert_held(&dev->event_lock);
disposition = input_get_disposition(dev, type, code, &value); if (disposition != INPUT_IGNORE_EVENT) { if (type != EV_SYN)
add_input_randomness(type, code, value);
/** * input_event() - report new input event * @dev: device that generated the event * @type: type of the event * @code: event code * @value: value of the event * * This function should be used by drivers implementing various input * devices to report input events. See also input_inject_event(). * * NOTE: input_event() may be safely used right after input device was * allocated with input_allocate_device(), even before it is registered * with input_register_device(), but the event will not reach any of the * input handlers. Such early invocation of input_event() may be used * to 'seed' initial state of a switch or initial position of absolute * axis, etc.
*/ void input_event(struct input_dev *dev, unsignedint type, unsignedint code, int value)
{ if (is_event_supported(type, dev->evbit, EV_MAX)) {
guard(spinlock_irqsave)(&dev->event_lock);
input_handle_event(dev, type, code, value);
}
}
EXPORT_SYMBOL(input_event);
/** * input_inject_event() - send input event from input handler * @handle: input handle to send event through * @type: type of the event * @code: event code * @value: value of the event * * Similar to input_event() but will ignore event if device is * "grabbed" and handle injecting event is not the one that owns * the device.
*/ void input_inject_event(struct input_handle *handle, unsignedint type, unsignedint code, int value)
{ struct input_dev *dev = handle->dev; struct input_handle *grab;
if (is_event_supported(type, dev->evbit, EV_MAX)) {
guard(spinlock_irqsave)(&dev->event_lock);
guard(rcu)();
/** * input_alloc_absinfo - allocates array of input_absinfo structs * @dev: the input device emitting absolute events * * If the absinfo struct the caller asked for is already allocated, this * functions will not do anything.
*/ void input_alloc_absinfo(struct input_dev *dev)
{ if (dev->absinfo) return;
dev->absinfo = kcalloc(ABS_CNT, sizeof(*dev->absinfo), GFP_KERNEL); if (!dev->absinfo) {
dev_err(dev->dev.parent ?: &dev->dev, "%s: unable to allocate memory\n", __func__); /* * We will handle this allocation failure in * input_register_device() when we refuse to register input * device with ABS bits but without absinfo.
*/
}
}
EXPORT_SYMBOL(input_alloc_absinfo);
void input_set_abs_params(struct input_dev *dev, unsignedint axis, int min, int max, int fuzz, int flat)
{ struct input_absinfo *absinfo;
/** * input_copy_abs - Copy absinfo from one input_dev to another * @dst: Destination input device to copy the abs settings to * @dst_axis: ABS_* value selecting the destination axis * @src: Source input device to copy the abs settings from * @src_axis: ABS_* value selecting the source axis * * Set absinfo for the selected destination axis by copying it from * the specified source input device's source axis. * This is useful to e.g. setup a pen/stylus input-device for combined * touchscreen/pen hardware where the pen uses the same coordinates as * the touchscreen.
*/ void input_copy_abs(struct input_dev *dst, unsignedint dst_axis, conststruct input_dev *src, unsignedint src_axis)
{ /* src must have EV_ABS and src_axis set */ if (WARN_ON(!(test_bit(EV_ABS, src->evbit) &&
test_bit(src_axis, src->absbit)))) return;
/* * input_alloc_absinfo() may have failed for the source. Our caller is * expected to catch this when registering the input devices, which may * happen after the input_copy_abs() call.
*/ if (!src->absinfo) return;
input_set_capability(dst, EV_ABS, dst_axis); if (!dst->absinfo) return;
/** * input_grab_device - grabs device for exclusive use * @handle: input handle that wants to own the device * * When a device is grabbed by an input handle all events generated by * the device are delivered only to this handle. Also events injected * by other input handles are ignored while device is grabbed.
*/ int input_grab_device(struct input_handle *handle)
{ struct input_dev *dev = handle->dev;
scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) { if (dev->grab) return -EBUSY;
grabber = rcu_dereference_protected(dev->grab,
lockdep_is_held(&dev->mutex)); if (grabber == handle) {
rcu_assign_pointer(dev->grab, NULL); /* Make sure input_pass_values() notices that grab is gone */
synchronize_rcu();
list_for_each_entry(handle, &dev->h_list, d_node) if (handle->open && handle->handler->start)
handle->handler->start(handle);
}
}
/** * input_release_device - release previously grabbed device * @handle: input handle that owns the device * * Releases previously grabbed device so that other input handles can * start receiving input events. Upon release all handlers attached * to the device have their start() method called so they have a change * to synchronize device state with the rest of the system.
*/ void input_release_device(struct input_handle *handle)
{ struct input_dev *dev = handle->dev;
/** * input_open_device - open input device * @handle: handle through which device is being accessed * * This function should be called by input handlers when they * want to start receive events from given input device.
*/ int input_open_device(struct input_handle *handle)
{ struct input_dev *dev = handle->dev; int error;
scoped_cond_guard(mutex_intr, return -EINTR, &dev->mutex) { if (dev->going_away) return -ENODEV;
handle->open++;
if (handle->handler->passive_observer) return 0;
if (dev->users++ || dev->inhibited) { /* * Device is already opened and/or inhibited, * so we can exit immediately and report success.
*/ return 0;
}
if (dev->open) {
error = dev->open(dev); if (error) {
dev->users--;
handle->open--; /* * Make sure we are not delivering any more * events through this handle.
*/
synchronize_rcu(); return error;
}
}
if (dev->poller)
input_dev_poller_start(dev->poller);
}
/** * input_close_device - close input device * @handle: handle through which device is being accessed * * This function should be called by input handlers when they * want to stop receive events from given input device.
*/ void input_close_device(struct input_handle *handle)
{ struct input_dev *dev = handle->dev;
guard(mutex)(&dev->mutex);
__input_release_device(handle);
if (!handle->handler->passive_observer) { if (!--dev->users && !dev->inhibited) { if (dev->poller)
input_dev_poller_stop(dev->poller); if (dev->close)
dev->close(dev);
}
}
if (!--handle->open) { /* * synchronize_rcu() makes sure that input_pass_values() * completed and that no more input events are delivered * through this handle
*/
synchronize_rcu();
}
}
EXPORT_SYMBOL(input_close_device);
/* * Simulate keyup events for all keys that are marked as pressed. * The function must be called with dev->event_lock held.
*/ staticbool input_dev_release_keys(struct input_dev *dev)
{ bool need_sync = false; int code;
/* * Mark device as going away. Note that we take dev->mutex here * not to protect access to dev->going_away but rather to ensure * that there are no threads in the middle of input_open_device()
*/
scoped_guard(mutex, &dev->mutex)
dev->going_away = true;
guard(spinlock_irq)(&dev->event_lock);
/* * Simulate keyup events for all pressed keys so that handlers * are not left with "stuck" keys. The driver may continue * generate events even after we done here but they will not * reach any handlers.
*/ if (input_dev_release_keys(dev))
input_handle_event(dev, EV_SYN, SYN_REPORT, 1);
/** * input_scancode_to_scalar() - converts scancode in &struct input_keymap_entry * @ke: keymap entry containing scancode to be converted. * @scancode: pointer to the location where converted scancode should * be stored. * * This function is used to convert scancode stored in &struct keymap_entry * into scalar form understood by legacy keymap handling methods. These * methods expect scancodes to be represented as 'unsigned int'.
*/ int input_scancode_to_scalar(conststruct input_keymap_entry *ke, unsignedint *scancode)
{ switch (ke->len) { case 1:
*scancode = *((u8 *)ke->scancode); break;
case 2:
*scancode = *((u16 *)ke->scancode); break;
case 4:
*scancode = *((u32 *)ke->scancode); break;
if (*old_keycode <= KEY_MAX) {
__clear_bit(*old_keycode, dev->keybit); for (i = 0; i < dev->keycodemax; i++) { if (input_fetch_keycode(dev, i) == *old_keycode) {
__set_bit(*old_keycode, dev->keybit); /* Setting the bit twice is useless, so break */ break;
}
}
}
__set_bit(ke->keycode, dev->keybit); return 0;
}
/** * input_get_keycode - retrieve keycode currently mapped to a given scancode * @dev: input device which keymap is being queried * @ke: keymap entry * * This function should be called by anyone interested in retrieving current * keymap. Presently evdev handlers use it.
*/ int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke)
{
guard(spinlock_irqsave)(&dev->event_lock);
/** * input_set_keycode - attribute a keycode to a given scancode * @dev: input device which keymap is being updated * @ke: new keymap entry * * This function should be called by anyone needing to update current * keymap. Presently keyboard and evdev handlers use it.
*/ int input_set_keycode(struct input_dev *dev, conststruct input_keymap_entry *ke)
{ unsignedint old_keycode; int error;
if (ke->keycode > KEY_MAX) return -EINVAL;
guard(spinlock_irqsave)(&dev->event_lock);
error = dev->setkeycode(dev, ke, &old_keycode); if (error) return error;
/* Make sure KEY_RESERVED did not get enabled. */
__clear_bit(KEY_RESERVED, dev->keybit);
/* * Simulate keyup event if keycode is not present * in the keymap anymore
*/ if (old_keycode > KEY_MAX) {
dev_warn(dev->dev.parent ?: &dev->dev, "%s: got too big old keycode %#x\n",
__func__, old_keycode);
} elseif (test_bit(EV_KEY, dev->evbit) &&
!is_event_supported(old_keycode, dev->keybit, KEY_MAX) &&
__test_and_clear_bit(old_keycode, dev->key)) { /* * We have to use input_event_dispose() here directly instead * of input_handle_event() because the key we want to release * here is considered no longer supported by the device and * input_handle_event() will ignore it.
*/
input_event_dispose(dev, INPUT_PASS_TO_HANDLERS,
EV_KEY, old_keycode, 0);
input_event_dispose(dev, INPUT_PASS_TO_HANDLERS | INPUT_FLUSH,
EV_SYN, SYN_REPORT, 1);
}
return 0;
}
EXPORT_SYMBOL(input_set_keycode);
bool input_match_device_id(conststruct input_dev *dev, conststruct input_device_id *id)
{ if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) if (id->bustype != dev->id.bustype) returnfalse;
if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR) if (id->vendor != dev->id.vendor) returnfalse;
if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT) if (id->product != dev->id.product) returnfalse;
if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION) if (id->version != dev->id.version) returnfalse;
staticint input_print_modalias_bits(char *buf, int size, char name, constunsignedlong *bm, unsignedint min_bit, unsignedint max_bit)
{ int bit = min_bit; int len = 0;
/* * If we have more data than we can fit in the buffer, check * if we can trim key data to fit in the rest. We will indicate * that key data is incomplete by adding "+" sign at the end, like * this: * "k1,2,3,45,+,". * * Note that we shortest key info (if present) is "k+," so we * can only try to trim if key data is longer than that.
*/ if (full_len && size < full_len + 1 && klen > 3) {
remainder = full_len - len; /* * We can only trim if we have space for the remainder * and also for at least "k+," which is 3 more characters.
*/ if (remainder <= space - 3) { /* * We are guaranteed to have 'k' in the buffer, so * we need at least 3 additional bytes for storing * "+," in addition to the remainder.
*/ for (int i = size - 1 - remainder - 3; i >= 0; i--) { if (buf[i] == 'k' || buf[i] == ',') {
strcpy(buf + i + 1, "+,");
len = i + 3; /* Not counting '\0' */ break;
}
}
}
}
staticint input_print_modalias(char *buf, int size, conststruct input_dev *id)
{ int full_len;
/* * Printing is done in 2 passes: first one figures out total length * needed for the modalias string, second one will try to trim key * data in case when buffer is too small for the entire modalias. * If the buffer is too small regardless, it will fill as much as it * can (without trimming key data) into the buffer and leave it to * the caller to figure out what to do with the result.
*/
full_len = input_print_modalias_parts(NULL, 0, 0, id); return input_print_modalias_parts(buf, size, full_len, id);
}
/* * Input uevent interface - loading event handlers based on * device bitfields.
*/ staticint input_add_uevent_bm_var(struct kobj_uevent_env *env, constchar *name, constunsignedlong *bitmap, int max)
{ int len;
if (add_uevent_var(env, "%s", name)) return -ENOMEM;
len = input_print_bitmap(&env->buf[env->buflen - 1], sizeof(env->buf) - env->buflen,
bitmap, max, false); if (len >= (sizeof(env->buf) - env->buflen)) return -ENOMEM;
env->buflen += len; return 0;
}
/* * This is a pretty gross hack. When building uevent data the driver core * may try adding more environment variables to kobj_uevent_env without * telling us, so we have no idea how much of the buffer we can use to * avoid overflows/-ENOMEM elsewhere. To work around this let's artificially * reduce amount of memory we will use for the modalias environment variable. * * The potential additions are: * * SEQNUM=18446744073709551615 - (%llu - 28 bytes) * HOME=/ (6 bytes) * PATH=/sbin:/bin:/usr/sbin:/usr/bin (34 bytes) * * 68 bytes total. Allow extra buffer - 96 bytes
*/ #define UEVENT_ENV_EXTRA_LEN 96
staticint input_add_uevent_modalias_var(struct kobj_uevent_env *env, conststruct input_dev *dev)
{ int len;
if (add_uevent_var(env, "MODALIAS=")) return -ENOMEM;
/** * input_reset_device() - reset/restore the state of input device * @dev: input device whose state needs to be reset * * This function tries to reset the state of an opened input device and * bring internal state and state if the hardware in sync with each other. * We mark all keys as released, restore LED state, repeat rate, etc.
*/ void input_reset_device(struct input_dev *dev)
{
guard(mutex)(&dev->mutex);
guard(spinlock_irqsave)(&dev->event_lock);
input_dev_toggle(dev, true); if (input_dev_release_keys(dev))
input_handle_event(dev, EV_SYN, SYN_REPORT, 1);
}
EXPORT_SYMBOL(input_reset_device);
/* * Keys that are pressed now are unlikely to be * still pressed when we resume.
*/ if (input_dev_release_keys(input_dev))
input_handle_event(input_dev, EV_SYN, SYN_REPORT, 1);
/* Turn off LEDs and sounds, if any are active. */
input_dev_toggle(input_dev, false);
/* * Keys that are pressed now are unlikely to be * still pressed when we resume.
*/ if (input_dev_release_keys(input_dev))
input_handle_event(input_dev, EV_SYN, SYN_REPORT, 1);
/** * input_allocate_device - allocate memory for new input device * * Returns prepared struct input_dev or %NULL. * * NOTE: Use input_free_device() to free devices that have not been * registered; input_unregister_device() should be used for already * registered devices.
*/ struct input_dev *input_allocate_device(void)
{ static atomic_t input_no = ATOMIC_INIT(-1); struct input_dev *dev;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return NULL;
/* * Start with space for SYN_REPORT + 7 EV_KEY/EV_MSC events + 2 spare, * see input_estimate_events_per_packet(). We will tune the number * when we register the device.
*/
dev->max_vals = 10;
dev->vals = kcalloc(dev->max_vals, sizeof(*dev->vals), GFP_KERNEL); if (!dev->vals) {
kfree(dev); return NULL;
}
dev->dev.type = &input_dev_type;
dev->dev.class = &input_class;
device_initialize(&dev->dev); /* * From this point on we can no longer simply "kfree(dev)", we need * to use input_free_device() so that device core properly frees its * resources associated with the input device.
*/
dev_dbg(dev, "%s: dropping reference to %s\n",
__func__, dev_name(&input->dev));
input_put_device(input);
}
/** * devm_input_allocate_device - allocate managed input device * @dev: device owning the input device being created * * Returns prepared struct input_dev or %NULL. * * Managed input devices do not need to be explicitly unregistered or * freed as it will be done automatically when owner device unbinds from * its driver (or binding fails). Once managed input device is allocated, * it is ready to be set up and registered in the same fashion as regular * input device. There are no special devm_input_device_[un]register() * variants, regular ones work with both managed and unmanaged devices, * should you need them. In most cases however, managed input device need * not be explicitly unregistered or freed. * * NOTE: the owner device is set up as parent of input device and users * should not override it.
*/ struct input_dev *devm_input_allocate_device(struct device *dev)
{ struct input_dev *input; struct input_devres *devres;
devres = devres_alloc(devm_input_device_release, sizeof(*devres), GFP_KERNEL); if (!devres) return NULL;
input = input_allocate_device(); if (!input) {
devres_free(devres); return NULL;
}
/** * input_free_device - free memory occupied by input_dev structure * @dev: input device to free * * This function should only be used if input_register_device() * was not called yet or if it failed. Once device was registered * use input_unregister_device() and memory will be freed once last * reference to the device is dropped. * * Device should be allocated by input_allocate_device(). * * NOTE: If there are references to the input device then memory * will not be freed until last reference is dropped.
*/ void input_free_device(struct input_dev *dev)
{ if (dev) { if (dev->devres_managed)
WARN_ON(devres_destroy(dev->dev.parent,
devm_input_device_release,
devm_input_device_match,
dev));
input_put_device(dev);
}
}
EXPORT_SYMBOL(input_free_device);
/** * input_set_timestamp - set timestamp for input events * @dev: input device to set timestamp for * @timestamp: the time at which the event has occurred * in CLOCK_MONOTONIC * * This function is intended to provide to the input system a more * accurate time of when an event actually occurred. The driver should * call this function as soon as a timestamp is acquired ensuring * clock conversions in input_set_timestamp are done correctly. * * The system entering suspend state between timestamp acquisition and * calling input_set_timestamp can result in inaccurate conversions.
*/ void input_set_timestamp(struct input_dev *dev, ktime_t timestamp)
{
dev->timestamp[INPUT_CLK_MONO] = timestamp;
dev->timestamp[INPUT_CLK_REAL] = ktime_mono_to_real(timestamp);
dev->timestamp[INPUT_CLK_BOOT] = ktime_mono_to_any(timestamp,
TK_OFFS_BOOT);
}
EXPORT_SYMBOL(input_set_timestamp);
/** * input_get_timestamp - get timestamp for input events * @dev: input device to get timestamp from * * A valid timestamp is a timestamp of non-zero value.
*/
ktime_t *input_get_timestamp(struct input_dev *dev)
{ const ktime_t invalid_timestamp = ktime_set(0, 0);
if (!ktime_compare(dev->timestamp[INPUT_CLK_MONO], invalid_timestamp))
input_set_timestamp(dev, ktime_get());
/** * input_set_capability - mark device as capable of a certain event * @dev: device that is capable of emitting or accepting event * @type: type of the event (EV_KEY, EV_REL, etc...) * @code: event code * * In addition to setting up corresponding bit in appropriate capability * bitmap the function also adjusts dev->evbit.
*/ void input_set_capability(struct input_dev *dev, unsignedint type, unsignedint code)
{ if (type < EV_CNT && input_max_code[type] &&
code > input_max_code[type]) {
pr_err("%s: invalid code %u for type %u\n", __func__, code,
type);
dump_stack(); return;
}
switch (type) { case EV_KEY:
__set_bit(code, dev->keybit); break;
case EV_REL:
__set_bit(code, dev->relbit); break;
case EV_ABS:
input_alloc_absinfo(dev);
__set_bit(code, dev->absbit); break;
/* * Generate software autorepeat event. Note that we take * dev->event_lock here to avoid racing with input_event * which may cause keys get "stuck".
*/ staticvoid input_repeat_key(struct timer_list *t)
{ struct input_dev *dev = timer_container_of(dev, t, timer);
guard(spinlock_irqsave)(&dev->event_lock);
if (!dev->inhibited &&
test_bit(dev->repeat_key, dev->key) &&
is_event_supported(dev->repeat_key, dev->keybit, KEY_MAX)) {
/* Because of swap() above, this frees the old vals memory */
kfree(vals);
return 0;
}
/** * input_register_device - register device with input core * @dev: device to be registered * * This function registers device with input core. The device must be * allocated with input_allocate_device() and all it's capabilities * set up before registering. * If function fails the device must be freed with input_free_device(). * Once device has been successfully registered it can be unregistered * with input_unregister_device(); input_free_device() should not be * called in this case. * * Note that this function is also used to register managed input devices * (ones allocated with devm_input_allocate_device()). Such managed input * devices need not be explicitly unregistered or freed, their tear down * is controlled by the devres infrastructure. It is also worth noting * that tear down of managed input devices is internally a 2-step process: * registered managed input device is first unregistered, but stays in * memory and can still handle input_event() calls (although events will * not be delivered anywhere). The freeing of managed input device will * happen later, when devres stack is unwound to the point where device * allocation was made.
*/ int input_register_device(struct input_dev *dev)
{ struct input_devres *devres = NULL; struct input_handler *handler; constchar *path; int error;
if (test_bit(EV_ABS, dev->evbit) && !dev->absinfo) {
dev_err(&dev->dev, "Absolute device without dev->absinfo, refusing to register\n"); return -EINVAL;
}
if (dev->devres_managed) {
devres = devres_alloc(devm_input_device_unregister, sizeof(*devres), GFP_KERNEL); if (!devres) return -ENOMEM;
devres->input = dev;
}
/* Every input device generates EV_SYN/SYN_REPORT events. */
__set_bit(EV_SYN, dev->evbit);
/* KEY_RESERVED is not supposed to be transmitted to userspace. */
__clear_bit(KEY_RESERVED, dev->keybit);
/* Make sure that bitmasks not mentioned in dev->evbit are clean. */
input_cleanse_bitmasks(dev);
error = input_device_tune_vals(dev); if (error) goto err_devres_free;
/* * If delay and period are pre-set by the driver, then autorepeating * is handled by the driver itself and we don't do it in input.c.
*/ if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD])
input_enable_softrepeat(dev, 250, 33);
if (!dev->getkeycode)
dev->getkeycode = input_default_getkeycode;
if (!dev->setkeycode)
dev->setkeycode = input_default_setkeycode;
if (dev->poller)
input_dev_poller_finalize(dev->poller);
error = device_add(&dev->dev); if (error) goto err_devres_free;
/** * input_unregister_device - unregister previously registered device * @dev: device to be unregistered * * This function unregisters an input device. Once device is unregistered * the caller should not try to access it as it may get freed at any moment.
*/ void input_unregister_device(struct input_dev *dev)
{ if (dev->devres_managed) {
WARN_ON(devres_destroy(dev->dev.parent,
devm_input_device_unregister,
devm_input_device_match,
dev));
__input_unregister_device(dev); /* * We do not do input_put_device() here because it will be done * when 2nd devres fires up.
*/
} else {
__input_unregister_device(dev);
input_put_device(dev);
}
}
EXPORT_SYMBOL(input_unregister_device);
staticint input_handler_check_methods(conststruct input_handler *handler)
{ int count = 0;
if (handler->filter)
count++; if (handler->events)
count++; if (handler->event)
count++;
if (count > 1) {
pr_err("%s: only one event processing method can be defined (%s)\n",
__func__, handler->name); return -EINVAL;
}
return 0;
}
/** * input_register_handler - register a new input handler * @handler: handler to be registered * * This function registers a new input handler (interface) for input * devices in the system and attaches it to all input devices that * are compatible with the handler.
*/ int input_register_handler(struct input_handler *handler)
{ struct input_dev *dev; int error;
error = input_handler_check_methods(handler); if (error) return error;
/** * input_unregister_handler - unregisters an input handler * @handler: handler to be unregistered * * This function disconnects a handler from its input devices and * removes it from lists of known handlers.
*/ void input_unregister_handler(struct input_handler *handler)
{ struct input_handle *handle, *next;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.