/* * The input core * * Copyright (c) 1999-2002 Vojtech Pavlik */ /* * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */ #include <linux/init.h>#include <linux/sched.h>#include <linux/smp_lock.h>#include <linux/input.h>#include <linux/module.h>#include <linux/random.h>#include <linux/major.h>#include <linux/proc_fs.h>#include <linux/seq_file.h>#include <linux/interrupt.h>#include <linux/poll.h>#include <linux/device.h>#include <linux/mutex.h> MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");MODULE_DESCRIPTION("Input core");MODULE_LICENSE("GPL"); #define INPUT_DEVICES 256 static LIST_HEAD(input_dev_list);static LIST_HEAD(input_handler_list); static struct input_handler *input_table[8]; /** * input_event() - report new input event * @handle: 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 * See also input_inject_event() */void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value){ struct input_handle *handle; if (type > EV_MAX || !test_bit(type, dev->evbit)) return; add_input_randomness(type, code, value); switch (type) { case EV_SYN: switch (code) { case SYN_CONFIG: if (dev->event) dev->event(dev, type, code, value); break; case SYN_REPORT: if (dev->sync) return; dev->sync = 1; break; } break; case EV_KEY: if (code > KEY_MAX || !test_bit(code, dev->keybit) || !!test_bit(code, dev->key) == value) return; if (value == 2) break; change_bit(code, dev->key); if (test_bit(EV_REP, dev->evbit) && dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] && dev->timer.data && value) { dev->repeat_key = code; mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_DELAY])); } break; case EV_SW: if (code > SW_MAX || !test_bit(code, dev->swbit) || !!test_bit(code, dev->sw) == value) return; change_bit(code, dev->sw); break; case EV_ABS: if (code > ABS_MAX || !test_bit(code, dev->absbit)) return; if (dev->absfuzz[code]) { if ((value > dev->abs[code] - (dev->absfuzz[code] >> 1)) && (value < dev->abs[code] + (dev->absfuzz[code] >> 1))) return; if ((value > dev->abs[code] - dev->absfuzz[code]) && (value < dev->abs[code] + dev->absfuzz[code])) value = (dev->abs[code] * 3 + value) >> 2; if ((value > dev->abs[code] - (dev->absfuzz[code] << 1)) && (value < dev->abs[code] + (dev->absfuzz[code] << 1))) value = (dev->abs[code] + value) >> 1; } if (dev->abs[code] == value) return; dev->abs[code] = value; break; case EV_REL: if (code > REL_MAX || !test_bit(code, dev->relbit) || (value == 0)) return; break; case EV_MSC: if (code > MSC_MAX || !test_bit(code, dev->mscbit)) return; if (dev->event) dev->event(dev, type, code, value); break; case EV_LED: if (code > LED_MAX || !test_bit(code, dev->ledbit) || !!test_bit(code, dev->led) == value) return; change_bit(code, dev->led); if (dev->event) dev->event(dev, type, code, value); break; case EV_SND: if (code > SND_MAX || !test_bit(code, dev->sndbit)) return; if (!!test_bit(code, dev->snd) != !!value) change_bit(code, dev->snd); if (dev->event) dev->event(dev, type, code, value); break; case EV_REP: if (code > REP_MAX || value < 0 || dev->rep[code] == value) return; dev->rep[code] = value; if (dev->event) dev->event(dev, type, code, value); break; case EV_FF: if (dev->event) dev->event(dev, type, code, value); break; } if (type != EV_SYN) dev->sync = 0; if (dev->grab) dev->grab->handler->event(dev->grab, type, code, value); else list_for_each_entry(handle, &dev->h_list, d_node) if (handle->open) handle->handler->event(handle, 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, unsigned int type, unsigned int code, int value){ if (!handle->dev->grab || handle->dev->grab == handle) input_event(handle->dev, type, code, value);}EXPORT_SYMBOL(input_inject_event); static void input_repeat_key(unsigned long data){ struct input_dev *dev = (void *) data; if (!test_bit(dev->repeat_key, dev->key)) return; input_event(dev, EV_KEY, dev->repeat_key, 2); input_sync(dev); if (dev->rep[REP_PERIOD]) mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_PERIOD]));} int input_grab_device(struct input_handle *handle){ if (handle->dev->grab) return -EBUSY; handle->dev->grab = handle; return 0;}EXPORT_SYMBOL(input_grab_device); void input_release_device(struct input_handle *handle){ struct input_dev *dev = handle->dev; if (dev->grab == handle) { dev->grab = NULL; list_for_each_entry(handle, &dev->h_list, d_node) if (handle->handler->start) handle->handler->start(handle); }}EXPORT_SYMBOL(input_release_device); int input_open_device(struct input_handle *handle){ struct input_dev *dev = handle->dev; int err; err = mutex_lock_interruptible(&dev->mutex); if (err) return err; handle->open++; if (!dev->users++ && dev->open) err = dev->open(dev); if (err) handle->open--; mutex_unlock(&dev->mutex); return err;}EXPORT_SYMBOL(input_open_device); int input_flush_device(struct input_handle* handle, struct file* file){ if (handle->dev->flush) return handle->dev->flush(handle->dev, file); return 0;}EXPORT_SYMBOL(input_flush_device); void input_close_device(struct input_handle *handle){ struct input_dev *dev = handle->dev; input_release_device(handle); mutex_lock(&dev->mutex); if (!--dev->users && dev->close) dev->close(dev); handle->open--; mutex_unlock(&dev->mutex);}EXPORT_SYMBOL(input_close_device); static void input_link_handle(struct input_handle *handle){ list_add_tail(&handle->d_node, &handle->dev->h_list); list_add_tail(&handle->h_node, &handle->handler->h_list);} #define MATCH_BIT(bit, max) \ for (i = 0; i < NBITS(max); i++) \ if ((id->bit[i] & dev->bit[i]) != id->bit[i]) \ break; \ if (i != NBITS(max)) \ continue; static struct input_device_id *input_match_device(struct input_device_id *id, struct input_dev *dev){ int i; for (; id->flags || id->driver_info; id++) { if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) if (id->bustype != dev->id.bustype) continue; if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR) if (id->vendor != dev->id.vendor) continue; if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT) if (id->product != dev->id.product) continue; if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION) if (id->version != dev->id.version) continue; MATCH_BIT(evbit, EV_MAX); MATCH_BIT(keybit, KEY_MAX); MATCH_BIT(relbit, REL_MAX); MATCH_BIT(absbit, ABS_MAX); MATCH_BIT(mscbit, MSC_MAX); MATCH_BIT(ledbit, LED_MAX); MATCH_BIT(sndbit, SND_MAX); MATCH_BIT(ffbit, FF_MAX); MATCH_BIT(swbit, SW_MAX); return id; } return NULL;} #ifdef CONFIG_PROC_FS static struct proc_dir_entry *proc_bus_input_dir;static DECLARE_WAIT_QUEUE_HEAD(input_devices_poll_wait);static int input_devices_state; static inline void input_wakeup_procfs_readers(void){ input_devices_state++; wake_up(&input_devices_poll_wait);} static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait){ int state = input_devices_state; poll_wait(file, &input_devices_poll_wait, wait); if (state != input_devices_state) return POLLIN | POLLRDNORM; return 0;} static struct list_head *list_get_nth_element(struct list_head *list, loff_t *pos){ struct list_head *node; loff_t i = 0; list_for_each(node, list) if (i++ == *pos) return node; return NULL;} static struct list_head *list_get_next_element(struct list_head *list, struct list_head *element, loff_t *pos){ if (element->next == list) return NULL; ++(*pos); return element->next;} static void *input_devices_seq_start(struct seq_file *seq, loff_t *pos){ /* acquire lock here ... Yes, we do need locking, I knowi, I know... */ return list_get_nth_element(&input_dev_list, pos);} static void *input_devices_seq_next(struct seq_file *seq, void *v, loff_t *pos){ return list_get_next_element(&input_dev_list, v, pos);} static void input_devices_seq_stop(struct seq_file *seq, void *v){ /* release lock here */} static void input_seq_print_bitmap(struct seq_file *seq, const char *name, unsigned long *bitmap, int max){ int i; for (i = NBITS(max) - 1; i > 0; i--) if (bitmap[i]) break; seq_printf(seq, "B: %s=", name); for (; i >= 0; i--) seq_printf(seq, "%lx%s", bitmap[i], i > 0 ? " " : ""); seq_putc(seq, '\n');} static int input_devices_seq_show(struct seq_file *seq, void *v){ struct input_dev *dev = container_of(v, struct input_dev, node); const char *path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL); struct input_handle *handle; seq_printf(seq, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n", dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version); seq_printf(seq, "N: Name=\"%s\"\n", dev->name ? dev->name : ""); seq_printf(seq, "P: Phys=%s\n", dev->phys ? dev->phys : ""); seq_printf(seq, "S: Sysfs=%s\n", path ? path : ""); seq_printf(seq, "H: Handlers="); list_for_each_entry(handle, &dev->h_list, d_node) seq_printf(seq, "%s ", handle->name); seq_putc(seq, '\n'); input_seq_print_bitmap(seq, "EV", dev->evbit, EV_MAX); if (test_bit(EV_KEY, dev->evbit)) input_seq_print_bitmap(seq, "KEY", dev->keybit, KEY_MAX); if (test_bit(EV_REL, dev->evbit)) input_seq_print_bitmap(seq, "REL", dev->relbit, REL_MAX); if (test_bit(EV_ABS, dev->evbit)) input_seq_print_bitmap(seq, "ABS", dev->absbit, ABS_MAX); if (test_bit(EV_MSC, dev->evbit)) input_seq_print_bitmap(seq, "MSC", dev->mscbit, MSC_MAX); if (test_bit(EV_LED, dev->evbit)) input_seq_print_bitmap(seq, "LED", dev->ledbit, LED_MAX); if (test_bit(EV_SND, dev->evbit)) input_seq_print_bitmap(seq, "SND", dev->sndbit, SND_MAX); if (test_bit(EV_FF, dev->evbit)) input_seq_print_bitmap(seq, "FF", dev->ffbit, FF_MAX); if (test_bit(EV_SW, dev->evbit)) input_seq_print_bitmap(seq, "SW", dev->swbit, SW_MAX); seq_putc(seq, '\n'); kfree(path); return 0;} static struct seq_operations input_devices_seq_ops = { .start = input_devices_seq_start, .next = input_devices_seq_next, .stop = input_devices_seq_stop, .show = input_devices_seq_show,}; static int input_proc_devices_open(struct inode *inode, struct file *file){ return seq_open(file, &input_devices_seq_ops);} static struct file_operations input_devices_fileops = { .owner = THIS_MODULE, .open = input_proc_devices_open, .poll = input_proc_devices_poll, .read = seq_read, .llseek = seq_lseek, .release = seq_release,}; static void *input_handlers_seq_start(struct seq_file *seq, loff_t *pos){ /* acquire lock here ... Yes, we do need locking, I knowi, I know... */ seq->private = (void *)(unsigned long)*pos; return list_get_nth_element(&input_handler_list, pos);} static void *input_handlers_seq_next(struct seq_file *seq, void *v, loff_t *pos){ seq->private = (void *)(unsigned long)(*pos + 1); return list_get_next_element(&input_handler_list, v, pos);}Lines 1–500 of 1160. Load more
/* * The input core * * Copyright (c) 1999-2002 Vojtech Pavlik */ /* * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */ #include <linux/init.h> #include <linux/sched.h> #include <linux/smp_lock.h> #include <linux/input.h> #include <linux/module.h> #include <linux/random.h> #include <linux/major.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> #include <linux/interrupt.h> #include <linux/poll.h> #include <linux/device.h> #include <linux/mutex.h> MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); MODULE_DESCRIPTION("Input core"); MODULE_LICENSE("GPL"); #define INPUT_DEVICES 256 static LIST_HEAD(input_dev_list); static LIST_HEAD(input_handler_list); static struct input_handler *input_table[8]; /** * input_event() - report new input event * @handle: 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 * See also input_inject_event() */ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { struct input_handle *handle; if (type > EV_MAX || !test_bit(type, dev->evbit)) return; add_input_randomness(type, code, value); switch (type) { case EV_SYN: switch (code) { case SYN_CONFIG: if (dev->event) dev->event(dev, type, code, value); break; case SYN_REPORT: if (dev->sync) return; dev->sync = 1; break; } break; case EV_KEY: if (code > KEY_MAX || !test_bit(code, dev->keybit) || !!test_bit(code, dev->key) == value) return; if (value == 2) break; change_bit(code, dev->key); if (test_bit(EV_REP, dev->evbit) && dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] && dev->timer.data && value) { dev->repeat_key = code; mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_DELAY])); } break; case EV_SW: if (code > SW_MAX || !test_bit(code, dev->swbit) || !!test_bit(code, dev->sw) == value) return; change_bit(code, dev->sw); break; case EV_ABS: if (code > ABS_MAX || !test_bit(code, dev->absbit)) return; if (dev->absfuzz[code]) { if ((value > dev->abs[code] - (dev->absfuzz[code] >> 1)) && (value < dev->abs[code] + (dev->absfuzz[code] >> 1))) return; if ((value > dev->abs[code] - dev->absfuzz[code]) && (value < dev->abs[code] + dev->absfuzz[code])) value = (dev->abs[code] * 3 + value) >> 2; if ((value > dev->abs[code] - (dev->absfuzz[code] << 1)) && (value < dev->abs[code] + (dev->absfuzz[code] << 1))) value = (dev->abs[code] + value) >> 1; } if (dev->abs[code] == value) return; dev->abs[code] = value; break; case EV_REL: if (code > REL_MAX || !test_bit(code, dev->relbit) || (value == 0)) return; break; case EV_MSC: if (code > MSC_MAX || !test_bit(code, dev->mscbit)) return; if (dev->event) dev->event(dev, type, code, value); break; case EV_LED: if (code > LED_MAX || !test_bit(code, dev->ledbit) || !!test_bit(code, dev->led) == value) return; change_bit(code, dev->led); if (dev->event) dev->event(dev, type, code, value); break; case EV_SND: if (code > SND_MAX || !test_bit(code, dev->sndbit)) return; if (!!test_bit(code, dev->snd) != !!value) change_bit(code, dev->snd); if (dev->event) dev->event(dev, type, code, value); break; case EV_REP: if (code > REP_MAX || value < 0 || dev->rep[code] == value) return; dev->rep[code] = value; if (dev->event) dev->event(dev, type, code, value); break; case EV_FF: if (dev->event) dev->event(dev, type, code, value); break; } if (type != EV_SYN) dev->sync = 0; if (dev->grab) dev->grab->handler->event(dev->grab, type, code, value); else list_for_each_entry(handle, &dev->h_list, d_node) if (handle->open) handle->handler->event(handle, 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, unsigned int type, unsigned int code, int value) { if (!handle->dev->grab || handle->dev->grab == handle) input_event(handle->dev, type, code, value); } EXPORT_SYMBOL(input_inject_event); static void input_repeat_key(unsigned long data) { struct input_dev *dev = (void *) data; if (!test_bit(dev->repeat_key, dev->key)) return; input_event(dev, EV_KEY, dev->repeat_key, 2); input_sync(dev); if (dev->rep[REP_PERIOD]) mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_PERIOD])); } int input_grab_device(struct input_handle *handle) { if (handle->dev->grab) return -EBUSY; handle->dev->grab = handle; return 0; } EXPORT_SYMBOL(input_grab_device); void input_release_device(struct input_handle *handle) { struct input_dev *dev = handle->dev; if (dev->grab == handle) { dev->grab = NULL; list_for_each_entry(handle, &dev->h_list, d_node) if (handle->handler->start) handle->handler->start(handle); } } EXPORT_SYMBOL(input_release_device); int input_open_device(struct input_handle *handle) { struct input_dev *dev = handle->dev; int err; err = mutex_lock_interruptible(&dev->mutex); if (err) return err; handle->open++; if (!dev->users++ && dev->open) err = dev->open(dev); if (err) handle->open--; mutex_unlock(&dev->mutex); return err; } EXPORT_SYMBOL(input_open_device); int input_flush_device(struct input_handle* handle, struct file* file) { if (handle->dev->flush) return handle->dev->flush(handle->dev, file); return 0; } EXPORT_SYMBOL(input_flush_device); void input_close_device(struct input_handle *handle) { struct input_dev *dev = handle->dev; input_release_device(handle); mutex_lock(&dev->mutex); if (!--dev->users && dev->close) dev->close(dev); handle->open--; mutex_unlock(&dev->mutex); } EXPORT_SYMBOL(input_close_device); static void input_link_handle(struct input_handle *handle) { list_add_tail(&handle->d_node, &handle->dev->h_list); list_add_tail(&handle->h_node, &handle->handler->h_list); } #define MATCH_BIT(bit, max) \ for (i = 0; i < NBITS(max); i++) \ if ((id->bit[i] & dev->bit[i]) != id->bit[i]) \ break; \ if (i != NBITS(max)) \ continue; static struct input_device_id *input_match_device(struct input_device_id *id, struct input_dev *dev) { int i; for (; id->flags || id->driver_info; id++) { if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) if (id->bustype != dev->id.bustype) continue; if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR) if (id->vendor != dev->id.vendor) continue; if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT) if (id->product != dev->id.product) continue; if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION) if (id->version != dev->id.version) continue; MATCH_BIT(evbit, EV_MAX); MATCH_BIT(keybit, KEY_MAX); MATCH_BIT(relbit, REL_MAX); MATCH_BIT(absbit, ABS_MAX); MATCH_BIT(mscbit, MSC_MAX); MATCH_BIT(ledbit, LED_MAX); MATCH_BIT(sndbit, SND_MAX); MATCH_BIT(ffbit, FF_MAX); MATCH_BIT(swbit, SW_MAX); return id; } return NULL; } #ifdef CONFIG_PROC_FS static struct proc_dir_entry *proc_bus_input_dir; static DECLARE_WAIT_QUEUE_HEAD(input_devices_poll_wait); static int input_devices_state; static inline void input_wakeup_procfs_readers(void) { input_devices_state++; wake_up(&input_devices_poll_wait); } static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait) { int state = input_devices_state; poll_wait(file, &input_devices_poll_wait, wait); if (state != input_devices_state) return POLLIN | POLLRDNORM; return 0; } static struct list_head *list_get_nth_element(struct list_head *list, loff_t *pos) { struct list_head *node; loff_t i = 0; list_for_each(node, list) if (i++ == *pos) return node; return NULL; } static struct list_head *list_get_next_element(struct list_head *list, struct list_head *element, loff_t *pos) { if (element->next == list) return NULL; ++(*pos); return element->next; } static void *input_devices_seq_start(struct seq_file *seq, loff_t *pos) { /* acquire lock here ... Yes, we do need locking, I knowi, I know... */ return list_get_nth_element(&input_dev_list, pos); } static void *input_devices_seq_next(struct seq_file *seq, void *v, loff_t *pos) { return list_get_next_element(&input_dev_list, v, pos); } static void input_devices_seq_stop(struct seq_file *seq, void *v) { /* release lock here */ } static void input_seq_print_bitmap(struct seq_file *seq, const char *name, unsigned long *bitmap, int max) { int i; for (i = NBITS(max) - 1; i > 0; i--) if (bitmap[i]) break; seq_printf(seq, "B: %s=", name); for (; i >= 0; i--) seq_printf(seq, "%lx%s", bitmap[i], i > 0 ? " " : ""); seq_putc(seq, '\n'); } static int input_devices_seq_show(struct seq_file *seq, void *v) { struct input_dev *dev = container_of(v, struct input_dev, node); const char *path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL); struct input_handle *handle; seq_printf(seq, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n", dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version); seq_printf(seq, "N: Name=\"%s\"\n", dev->name ? dev->name : ""); seq_printf(seq, "P: Phys=%s\n", dev->phys ? dev->phys : ""); seq_printf(seq, "S: Sysfs=%s\n", path ? path : ""); seq_printf(seq, "H: Handlers="); list_for_each_entry(handle, &dev->h_list, d_node) seq_printf(seq, "%s ", handle->name); seq_putc(seq, '\n'); input_seq_print_bitmap(seq, "EV", dev->evbit, EV_MAX); if (test_bit(EV_KEY, dev->evbit)) input_seq_print_bitmap(seq, "KEY", dev->keybit, KEY_MAX); if (test_bit(EV_REL, dev->evbit)) input_seq_print_bitmap(seq, "REL", dev->relbit, REL_MAX); if (test_bit(EV_ABS, dev->evbit)) input_seq_print_bitmap(seq, "ABS", dev->absbit, ABS_MAX); if (test_bit(EV_MSC, dev->evbit)) input_seq_print_bitmap(seq, "MSC", dev->mscbit, MSC_MAX); if (test_bit(EV_LED, dev->evbit)) input_seq_print_bitmap(seq, "LED", dev->ledbit, LED_MAX); if (test_bit(EV_SND, dev->evbit)) input_seq_print_bitmap(seq, "SND", dev->sndbit, SND_MAX); if (test_bit(EV_FF, dev->evbit)) input_seq_print_bitmap(seq, "FF", dev->ffbit, FF_MAX); if (test_bit(EV_SW, dev->evbit)) input_seq_print_bitmap(seq, "SW", dev->swbit, SW_MAX); seq_putc(seq, '\n'); kfree(path); return 0; } static struct seq_operations input_devices_seq_ops = { .start = input_devices_seq_start, .next = input_devices_seq_next, .stop = input_devices_seq_stop, .show = input_devices_seq_show, }; static int input_proc_devices_open(struct inode *inode, struct file *file) { return seq_open(file, &input_devices_seq_ops); } static struct file_operations input_devices_fileops = { .owner = THIS_MODULE, .open = input_proc_devices_open, .poll = input_proc_devices_poll, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; static void *input_handlers_seq_start(struct seq_file *seq, loff_t *pos) { /* acquire lock here ... Yes, we do need locking, I knowi, I know... */ seq->private = (void *)(unsigned long)*pos; return list_get_nth_element(&input_handler_list, pos); } static void *input_handlers_seq_next(struct seq_file *seq, void *v, loff_t *pos) { seq->private = (void *)(unsigned long)(*pos + 1); return list_get_next_element(&input_handler_list, v, pos); }