diff options
Diffstat (limited to 'drivers/acpi/sysfs.c')
| -rw-r--r-- | drivers/acpi/sysfs.c | 78 | 
1 files changed, 39 insertions, 39 deletions
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 05306a59aed..38cb9782d4b 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -5,15 +5,13 @@  #include <linux/init.h>  #include <linux/kernel.h>  #include <linux/moduleparam.h> -#include <acpi/acpi_drivers.h> +#include <linux/acpi.h>  #include "internal.h"  #define _COMPONENT		ACPI_SYSTEM_COMPONENT  ACPI_MODULE_NAME("sysfs"); -#define PREFIX "ACPI: " -  #ifdef CONFIG_ACPI_DEBUG  /*   * ACPI debug sysfs I/F, including: @@ -226,7 +224,7 @@ module_param_call(trace_state, param_set_trace_state, param_get_trace_state,  /* /sys/modules/acpi/parameters/aml_debug_output */  module_param_named(aml_debug_output, acpi_gbl_enable_aml_debug_object, -		   bool, 0644); +		   byte, 0644);  MODULE_PARM_DESC(aml_debug_output,  		 "To enable/disable the ACPI Debug Object output."); @@ -309,7 +307,7 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr,  		sprintf(table_attr->name + ACPI_NAME_SIZE, "%d",  			table_attr->instance); -	table_attr->attr.size = 0; +	table_attr->attr.size = table_header->length;  	table_attr->attr.read = acpi_table_show;  	table_attr->attr.attr.name = table_attr->name;  	table_attr->attr.attr.mode = 0400; @@ -354,8 +352,9 @@ static int acpi_tables_sysfs_init(void)  {  	struct acpi_table_attr *table_attr;  	struct acpi_table_header *table_header = NULL; -	int table_index = 0; -	int result; +	int table_index; +	acpi_status status; +	int ret;  	tables_kobj = kobject_create_and_add("tables", acpi_kobj);  	if (!tables_kobj) @@ -365,33 +364,34 @@ static int acpi_tables_sysfs_init(void)  	if (!dynamic_tables_kobj)  		goto err_dynamic_tables; -	do { -		result = acpi_get_table_by_index(table_index, &table_header); -		if (!result) { -			table_index++; -			table_attr = NULL; -			table_attr = -			    kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL); -			if (!table_attr) -				return -ENOMEM; - -			acpi_table_attr_init(table_attr, table_header); -			result = -			    sysfs_create_bin_file(tables_kobj, -						  &table_attr->attr); -			if (result) { -				kfree(table_attr); -				return result; -			} else -				list_add_tail(&table_attr->node, -					      &acpi_table_attr_list); +	for (table_index = 0;; table_index++) { +		status = acpi_get_table_by_index(table_index, &table_header); + +		if (status == AE_BAD_PARAMETER) +			break; + +		if (ACPI_FAILURE(status)) +			continue; + +		table_attr = NULL; +		table_attr = kzalloc(sizeof(*table_attr), GFP_KERNEL); +		if (!table_attr) +			return -ENOMEM; + +		acpi_table_attr_init(table_attr, table_header); +		ret = sysfs_create_bin_file(tables_kobj, &table_attr->attr); +		if (ret) { +			kfree(table_attr); +			return ret;  		} -	} while (!result); +		list_add_tail(&table_attr->node, &acpi_table_attr_list); +	} +  	kobject_uevent(tables_kobj, KOBJ_ADD);  	kobject_uevent(dynamic_tables_kobj, KOBJ_ADD); -	result = acpi_install_table_handler(acpi_sysfs_table_handler, NULL); +	status = acpi_install_table_handler(acpi_sysfs_table_handler, NULL); -	return result == AE_OK ? 0 : -EINVAL; +	return ACPI_FAILURE(status) ? -EINVAL : 0;  err_dynamic_tables:  	kobject_put(tables_kobj);  err: @@ -564,6 +564,7 @@ static ssize_t counter_set(struct kobject *kobj,  	acpi_event_status status;  	acpi_handle handle;  	int result = 0; +	unsigned long tmp;  	if (index == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI) {  		int i; @@ -596,8 +597,10 @@ static ssize_t counter_set(struct kobject *kobj,  		else if (!strcmp(buf, "clear\n") &&  			 (status & ACPI_EVENT_FLAG_SET))  			result = acpi_clear_gpe(handle, index); +		else if (!kstrtoul(buf, 0, &tmp)) +			all_counters[index].count = tmp;  		else -			all_counters[index].count = strtoul(buf, NULL, 0); +			result = -EINVAL;  	} else if (index < num_gpes + ACPI_NUM_FIXED_EVENTS) {  		int event = index - num_gpes;  		if (!strcmp(buf, "disable\n") && @@ -609,8 +612,10 @@ static ssize_t counter_set(struct kobject *kobj,  		else if (!strcmp(buf, "clear\n") &&  			 (status & ACPI_EVENT_FLAG_SET))  			result = acpi_clear_event(event); +		else if (!kstrtoul(buf, 0, &tmp)) +			all_counters[index].count = tmp;  		else -			all_counters[index].count = strtoul(buf, NULL, 0); +			result = -EINVAL;  	} else  		all_counters[index].count = strtoul(buf, NULL, 0); @@ -762,13 +767,8 @@ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,  	if (!hotplug_kobj)  		goto err_out; -	kobject_init(&hotplug->kobj, &acpi_hotplug_profile_ktype); -	error = kobject_set_name(&hotplug->kobj, "%s", name); -	if (error) -		goto err_out; - -	hotplug->kobj.parent = hotplug_kobj; -	error = kobject_add(&hotplug->kobj, hotplug_kobj, NULL); +	error = kobject_init_and_add(&hotplug->kobj, +		&acpi_hotplug_profile_ktype, hotplug_kobj, "%s", name);  	if (error)  		goto err_out;  | 
