aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/system.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/system.c')
-rw-r--r--drivers/acpi/system.c64
1 files changed, 50 insertions, 14 deletions
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 391d0358a592..da51f05ef8d8 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -33,10 +33,6 @@
33 33
34#define _COMPONENT ACPI_SYSTEM_COMPONENT 34#define _COMPONENT ACPI_SYSTEM_COMPONENT
35ACPI_MODULE_NAME("system"); 35ACPI_MODULE_NAME("system");
36#ifdef MODULE_PARAM_PREFIX
37#undef MODULE_PARAM_PREFIX
38#endif
39#define MODULE_PARAM_PREFIX "acpi."
40 36
41#define ACPI_SYSTEM_CLASS "system" 37#define ACPI_SYSTEM_CLASS "system"
42#define ACPI_SYSTEM_DEVICE_NAME "System" 38#define ACPI_SYSTEM_DEVICE_NAME "System"
@@ -62,6 +58,7 @@ module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444);
62 -------------------------------------------------------------------------- */ 58 -------------------------------------------------------------------------- */
63static LIST_HEAD(acpi_table_attr_list); 59static LIST_HEAD(acpi_table_attr_list);
64static struct kobject *tables_kobj; 60static struct kobject *tables_kobj;
61static struct kobject *dynamic_tables_kobj;
65 62
66struct acpi_table_attr { 63struct acpi_table_attr {
67 struct bin_attribute attr; 64 struct bin_attribute attr;
@@ -128,6 +125,40 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
128 return; 125 return;
129} 126}
130 127
128static acpi_status
129acpi_sysfs_table_handler(u32 event, void *table, void *context)
130{
131 struct acpi_table_attr *table_attr;
132
133 switch (event) {
134 case ACPI_TABLE_EVENT_LOAD:
135 table_attr =
136 kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL);
137 if (!table_attr)
138 return AE_NO_MEMORY;
139
140 acpi_table_attr_init(table_attr, table);
141 if (sysfs_create_bin_file(dynamic_tables_kobj,
142 &table_attr->attr)) {
143 kfree(table_attr);
144 return AE_ERROR;
145 } else
146 list_add_tail(&table_attr->node,
147 &acpi_table_attr_list);
148 break;
149 case ACPI_TABLE_EVENT_UNLOAD:
150 /*
151 * we do not need to do anything right now
152 * because the table is not deleted from the
153 * global table list when unloading it.
154 */
155 break;
156 default:
157 return AE_BAD_PARAMETER;
158 }
159 return AE_OK;
160}
161
131static int acpi_system_sysfs_init(void) 162static int acpi_system_sysfs_init(void)
132{ 163{
133 struct acpi_table_attr *table_attr; 164 struct acpi_table_attr *table_attr;
@@ -137,7 +168,11 @@ static int acpi_system_sysfs_init(void)
137 168
138 tables_kobj = kobject_create_and_add("tables", acpi_kobj); 169 tables_kobj = kobject_create_and_add("tables", acpi_kobj);
139 if (!tables_kobj) 170 if (!tables_kobj)
140 return -ENOMEM; 171 goto err;
172
173 dynamic_tables_kobj = kobject_create_and_add("dynamic", tables_kobj);
174 if (!dynamic_tables_kobj)
175 goto err_dynamic_tables;
141 176
142 do { 177 do {
143 result = acpi_get_table_by_index(table_index, &table_header); 178 result = acpi_get_table_by_index(table_index, &table_header);
@@ -162,8 +197,14 @@ static int acpi_system_sysfs_init(void)
162 } 197 }
163 } while (!result); 198 } while (!result);
164 kobject_uevent(tables_kobj, KOBJ_ADD); 199 kobject_uevent(tables_kobj, KOBJ_ADD);
165 200 kobject_uevent(dynamic_tables_kobj, KOBJ_ADD);
166 return 0; 201 result = acpi_install_table_handler(acpi_sysfs_table_handler, NULL);
202
203 return result == AE_OK ? 0 : -EINVAL;
204err_dynamic_tables:
205 kobject_put(tables_kobj);
206err:
207 return -ENOMEM;
167} 208}
168 209
169/* 210/*
@@ -571,12 +612,9 @@ static int acpi_system_procfs_init(void)
571} 612}
572#endif 613#endif
573 614
574static int __init acpi_system_init(void) 615int __init acpi_system_init(void)
575{ 616{
576 int result = 0; 617 int result;
577
578 if (acpi_disabled)
579 return 0;
580 618
581 result = acpi_system_procfs_init(); 619 result = acpi_system_procfs_init();
582 if (result) 620 if (result)
@@ -586,5 +624,3 @@ static int __init acpi_system_init(void)
586 624
587 return result; 625 return result;
588} 626}
589
590subsys_initcall(acpi_system_init);