diff options
Diffstat (limited to 'drivers/input/serio/serio.c')
-rw-r--r-- | drivers/input/serio/serio.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index f367695e69b5..edd15db17715 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c | |||
@@ -389,6 +389,14 @@ static ssize_t serio_show_description(struct device *dev, struct device_attribut | |||
389 | return sprintf(buf, "%s\n", serio->name); | 389 | return sprintf(buf, "%s\n", serio->name); |
390 | } | 390 | } |
391 | 391 | ||
392 | static ssize_t serio_show_modalias(struct device *dev, struct device_attribute *attr, char *buf) | ||
393 | { | ||
394 | struct serio *serio = to_serio_port(dev); | ||
395 | |||
396 | return sprintf(buf, "serio:ty%02Xpr%02Xid%02Xex%02X\n", | ||
397 | serio->id.type, serio->id.proto, serio->id.id, serio->id.extra); | ||
398 | } | ||
399 | |||
392 | static ssize_t serio_show_id_type(struct device *dev, struct device_attribute *attr, char *buf) | 400 | static ssize_t serio_show_id_type(struct device *dev, struct device_attribute *attr, char *buf) |
393 | { | 401 | { |
394 | struct serio *serio = to_serio_port(dev); | 402 | struct serio *serio = to_serio_port(dev); |
@@ -487,6 +495,7 @@ static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute * | |||
487 | 495 | ||
488 | static struct device_attribute serio_device_attrs[] = { | 496 | static struct device_attribute serio_device_attrs[] = { |
489 | __ATTR(description, S_IRUGO, serio_show_description, NULL), | 497 | __ATTR(description, S_IRUGO, serio_show_description, NULL), |
498 | __ATTR(modalias, S_IRUGO, serio_show_modalias, NULL), | ||
490 | __ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver), | 499 | __ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver), |
491 | __ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode), | 500 | __ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode), |
492 | __ATTR_NULL | 501 | __ATTR_NULL |
@@ -785,36 +794,37 @@ static int serio_bus_match(struct device *dev, struct device_driver *drv) | |||
785 | 794 | ||
786 | #ifdef CONFIG_HOTPLUG | 795 | #ifdef CONFIG_HOTPLUG |
787 | 796 | ||
788 | #define PUT_ENVP(fmt, val) \ | 797 | #define SERIO_ADD_HOTPLUG_VAR(fmt, val...) \ |
789 | do { \ | 798 | do { \ |
790 | envp[i++] = buffer; \ | 799 | int err = add_hotplug_env_var(envp, num_envp, &i, \ |
791 | length += snprintf(buffer, buffer_size - length, fmt, val); \ | 800 | buffer, buffer_size, &len, \ |
792 | if (buffer_size - length <= 0 || i >= num_envp) \ | 801 | fmt, val); \ |
793 | return -ENOMEM; \ | 802 | if (err) \ |
794 | length++; \ | 803 | return err; \ |
795 | buffer += length; \ | 804 | } while (0) |
796 | } while (0) | 805 | |
797 | static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) | 806 | static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) |
798 | { | 807 | { |
799 | struct serio *serio; | 808 | struct serio *serio; |
800 | int i = 0; | 809 | int i = 0; |
801 | int length = 0; | 810 | int len = 0; |
802 | 811 | ||
803 | if (!dev) | 812 | if (!dev) |
804 | return -ENODEV; | 813 | return -ENODEV; |
805 | 814 | ||
806 | serio = to_serio_port(dev); | 815 | serio = to_serio_port(dev); |
807 | 816 | ||
808 | PUT_ENVP("SERIO_TYPE=%02x", serio->id.type); | 817 | SERIO_ADD_HOTPLUG_VAR("SERIO_TYPE=%02x", serio->id.type); |
809 | PUT_ENVP("SERIO_PROTO=%02x", serio->id.proto); | 818 | SERIO_ADD_HOTPLUG_VAR("SERIO_PROTO=%02x", serio->id.proto); |
810 | PUT_ENVP("SERIO_ID=%02x", serio->id.id); | 819 | SERIO_ADD_HOTPLUG_VAR("SERIO_ID=%02x", serio->id.id); |
811 | PUT_ENVP("SERIO_EXTRA=%02x", serio->id.extra); | 820 | SERIO_ADD_HOTPLUG_VAR("SERIO_EXTRA=%02x", serio->id.extra); |
812 | 821 | SERIO_ADD_HOTPLUG_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X", | |
822 | serio->id.type, serio->id.proto, serio->id.id, serio->id.extra); | ||
813 | envp[i] = NULL; | 823 | envp[i] = NULL; |
814 | 824 | ||
815 | return 0; | 825 | return 0; |
816 | } | 826 | } |
817 | #undef PUT_ENVP | 827 | #undef SERIO_ADD_HOTPLUG_VAR |
818 | 828 | ||
819 | #else | 829 | #else |
820 | 830 | ||