aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r--drivers/input/input.c54
1 files changed, 46 insertions, 8 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index bdd2a7fc268d..ef5824c8846b 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -18,7 +18,6 @@
18#include <linux/random.h> 18#include <linux/random.h>
19#include <linux/major.h> 19#include <linux/major.h>
20#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
21#include <linux/kobject_uevent.h>
22#include <linux/interrupt.h> 21#include <linux/interrupt.h>
23#include <linux/poll.h> 22#include <linux/poll.h>
24#include <linux/device.h> 23#include <linux/device.h>
@@ -529,10 +528,49 @@ INPUT_DEV_STRING_ATTR_SHOW(name);
529INPUT_DEV_STRING_ATTR_SHOW(phys); 528INPUT_DEV_STRING_ATTR_SHOW(phys);
530INPUT_DEV_STRING_ATTR_SHOW(uniq); 529INPUT_DEV_STRING_ATTR_SHOW(uniq);
531 530
531static int print_modalias_bits(char *buf, char prefix, unsigned long *arr,
532 unsigned int min, unsigned int max)
533{
534 int len, i;
535
536 len = sprintf(buf, "%c", prefix);
537 for (i = min; i < max; i++)
538 if (arr[LONG(i)] & BIT(i))
539 len += sprintf(buf+len, "%X,", i);
540 return len;
541}
542
543static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf)
544{
545 struct input_dev *id = to_input_dev(dev);
546 ssize_t len = 0;
547
548 len += sprintf(buf+len, "input:b%04Xv%04Xp%04Xe%04X-",
549 id->id.bustype,
550 id->id.vendor,
551 id->id.product,
552 id->id.version);
553
554 len += print_modalias_bits(buf+len, 'e', id->evbit, 0, EV_MAX);
555 len += print_modalias_bits(buf+len, 'k', id->keybit,
556 KEY_MIN_INTERESTING, KEY_MAX);
557 len += print_modalias_bits(buf+len, 'r', id->relbit, 0, REL_MAX);
558 len += print_modalias_bits(buf+len, 'a', id->absbit, 0, ABS_MAX);
559 len += print_modalias_bits(buf+len, 'm', id->mscbit, 0, MSC_MAX);
560 len += print_modalias_bits(buf+len, 'l', id->ledbit, 0, LED_MAX);
561 len += print_modalias_bits(buf+len, 's', id->sndbit, 0, SND_MAX);
562 len += print_modalias_bits(buf+len, 'f', id->ffbit, 0, FF_MAX);
563 len += print_modalias_bits(buf+len, 'w', id->swbit, 0, SW_MAX);
564 len += sprintf(buf+len, "\n");
565 return len;
566}
567static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
568
532static struct attribute *input_dev_attrs[] = { 569static struct attribute *input_dev_attrs[] = {
533 &class_device_attr_name.attr, 570 &class_device_attr_name.attr,
534 &class_device_attr_phys.attr, 571 &class_device_attr_phys.attr,
535 &class_device_attr_uniq.attr, 572 &class_device_attr_uniq.attr,
573 &class_device_attr_modalias.attr,
536 NULL 574 NULL
537}; 575};
538 576
@@ -611,10 +649,10 @@ static void input_dev_release(struct class_device *class_dev)
611} 649}
612 650
613/* 651/*
614 * Input hotplugging interface - loading event handlers based on 652 * Input uevent interface - loading event handlers based on
615 * device bitfields. 653 * device bitfields.
616 */ 654 */
617static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index, 655static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
618 char *buffer, int buffer_size, int *cur_len, 656 char *buffer, int buffer_size, int *cur_len,
619 const char *name, unsigned long *bitmap, int max) 657 const char *name, unsigned long *bitmap, int max)
620{ 658{
@@ -639,7 +677,7 @@ static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index,
639 677
640#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \ 678#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \
641 do { \ 679 do { \
642 int err = add_hotplug_env_var(envp, num_envp, &i, \ 680 int err = add_uevent_var(envp, num_envp, &i, \
643 buffer, buffer_size, &len, \ 681 buffer, buffer_size, &len, \
644 fmt, val); \ 682 fmt, val); \
645 if (err) \ 683 if (err) \
@@ -648,15 +686,15 @@ static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index,
648 686
649#define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \ 687#define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \
650 do { \ 688 do { \
651 int err = input_add_hotplug_bm_var(envp, num_envp, &i, \ 689 int err = input_add_uevent_bm_var(envp, num_envp, &i, \
652 buffer, buffer_size, &len, \ 690 buffer, buffer_size, &len, \
653 name, bm, max); \ 691 name, bm, max); \
654 if (err) \ 692 if (err) \
655 return err; \ 693 return err; \
656 } while (0) 694 } while (0)
657 695
658static int input_dev_hotplug(struct class_device *cdev, char **envp, 696static int input_dev_uevent(struct class_device *cdev, char **envp,
659 int num_envp, char *buffer, int buffer_size) 697 int num_envp, char *buffer, int buffer_size)
660{ 698{
661 struct input_dev *dev = to_input_dev(cdev); 699 struct input_dev *dev = to_input_dev(cdev);
662 int i = 0; 700 int i = 0;
@@ -698,7 +736,7 @@ static int input_dev_hotplug(struct class_device *cdev, char **envp,
698struct class input_class = { 736struct class input_class = {
699 .name = "input", 737 .name = "input",
700 .release = input_dev_release, 738 .release = input_dev_release,
701 .hotplug = input_dev_hotplug, 739 .uevent = input_dev_uevent,
702}; 740};
703 741
704struct input_dev *input_allocate_device(void) 742struct input_dev *input_allocate_device(void)