diff options
Diffstat (limited to 'drivers/acpi/sysfs.c')
-rw-r--r-- | drivers/acpi/sysfs.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index fcae5fa2e1b3..05306a59aedc 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
@@ -677,10 +677,9 @@ void acpi_irq_stats_init(void) | |||
677 | else | 677 | else |
678 | sprintf(buffer, "bug%02X", i); | 678 | sprintf(buffer, "bug%02X", i); |
679 | 679 | ||
680 | name = kzalloc(strlen(buffer) + 1, GFP_KERNEL); | 680 | name = kstrdup(buffer, GFP_KERNEL); |
681 | if (name == NULL) | 681 | if (name == NULL) |
682 | goto fail; | 682 | goto fail; |
683 | strncpy(name, buffer, strlen(buffer) + 1); | ||
684 | 683 | ||
685 | sysfs_attr_init(&counter_attrs[i].attr); | 684 | sysfs_attr_init(&counter_attrs[i].attr); |
686 | counter_attrs[i].attr.name = name; | 685 | counter_attrs[i].attr.name = name; |
@@ -780,6 +779,33 @@ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, | |||
780 | pr_err(PREFIX "Unable to add hotplug profile '%s'\n", name); | 779 | pr_err(PREFIX "Unable to add hotplug profile '%s'\n", name); |
781 | } | 780 | } |
782 | 781 | ||
782 | static ssize_t force_remove_show(struct kobject *kobj, | ||
783 | struct kobj_attribute *attr, char *buf) | ||
784 | { | ||
785 | return sprintf(buf, "%d\n", !!acpi_force_hot_remove); | ||
786 | } | ||
787 | |||
788 | static ssize_t force_remove_store(struct kobject *kobj, | ||
789 | struct kobj_attribute *attr, | ||
790 | const char *buf, size_t size) | ||
791 | { | ||
792 | bool val; | ||
793 | int ret; | ||
794 | |||
795 | ret = strtobool(buf, &val); | ||
796 | if (ret < 0) | ||
797 | return ret; | ||
798 | |||
799 | lock_device_hotplug(); | ||
800 | acpi_force_hot_remove = val; | ||
801 | unlock_device_hotplug(); | ||
802 | return size; | ||
803 | } | ||
804 | |||
805 | static const struct kobj_attribute force_remove_attr = | ||
806 | __ATTR(force_remove, S_IRUGO | S_IWUSR, force_remove_show, | ||
807 | force_remove_store); | ||
808 | |||
783 | int __init acpi_sysfs_init(void) | 809 | int __init acpi_sysfs_init(void) |
784 | { | 810 | { |
785 | int result; | 811 | int result; |
@@ -789,6 +815,10 @@ int __init acpi_sysfs_init(void) | |||
789 | return result; | 815 | return result; |
790 | 816 | ||
791 | hotplug_kobj = kobject_create_and_add("hotplug", acpi_kobj); | 817 | hotplug_kobj = kobject_create_and_add("hotplug", acpi_kobj); |
818 | result = sysfs_create_file(hotplug_kobj, &force_remove_attr.attr); | ||
819 | if (result) | ||
820 | return result; | ||
821 | |||
792 | result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr); | 822 | result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr); |
793 | return result; | 823 | return result; |
794 | } | 824 | } |