diff options
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r-- | drivers/input/input.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index 2d37b394e384..ef5824c8846b 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -528,10 +528,49 @@ INPUT_DEV_STRING_ATTR_SHOW(name); | |||
528 | INPUT_DEV_STRING_ATTR_SHOW(phys); | 528 | INPUT_DEV_STRING_ATTR_SHOW(phys); |
529 | INPUT_DEV_STRING_ATTR_SHOW(uniq); | 529 | INPUT_DEV_STRING_ATTR_SHOW(uniq); |
530 | 530 | ||
531 | static 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 | |||
543 | static 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 | } | ||
567 | static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); | ||
568 | |||
531 | static struct attribute *input_dev_attrs[] = { | 569 | static struct attribute *input_dev_attrs[] = { |
532 | &class_device_attr_name.attr, | 570 | &class_device_attr_name.attr, |
533 | &class_device_attr_phys.attr, | 571 | &class_device_attr_phys.attr, |
534 | &class_device_attr_uniq.attr, | 572 | &class_device_attr_uniq.attr, |
573 | &class_device_attr_modalias.attr, | ||
535 | NULL | 574 | NULL |
536 | }; | 575 | }; |
537 | 576 | ||