aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2009-02-25 22:27:23 -0500
committerLen Brown <len.brown@intel.com>2009-02-26 01:03:15 -0500
commit4658e4ef9d252c26630268b20ceab78b3952db41 (patch)
tree7dc5bc5f546de3e311eb7752d0e7917e0c88076c /drivers/acpi
parentc15d8a6499d04e5d2cac07f8120f207bb275f60f (diff)
ACPI: introduce sysfs I/F for dynamic tables
SSDT tables may be loaded at runtime. create sysfs I/F for these dynamic tables in /sys/firmware/acpi/tables/dynamic/. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/system.c51
1 files changed, 48 insertions, 3 deletions
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 391d0358a592..c8859047acfe 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -62,6 +62,7 @@ module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444);
62 -------------------------------------------------------------------------- */ 62 -------------------------------------------------------------------------- */
63static LIST_HEAD(acpi_table_attr_list); 63static LIST_HEAD(acpi_table_attr_list);
64static struct kobject *tables_kobj; 64static struct kobject *tables_kobj;
65static struct kobject *dynamic_tables_kobj;
65 66
66struct acpi_table_attr { 67struct acpi_table_attr {
67 struct bin_attribute attr; 68 struct bin_attribute attr;
@@ -128,6 +129,40 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
128 return; 129 return;
129} 130}
130 131
132static acpi_status
133acpi_sysfs_table_handler(u32 event, void *table, void *context)
134{
135 struct acpi_table_attr *table_attr;
136
137 switch (event) {
138 case ACPI_TABLE_EVENT_LOAD:
139 table_attr =
140 kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL);
141 if (!table_attr)
142 return AE_NO_MEMORY;
143
144 acpi_table_attr_init(table_attr, table);
145 if (sysfs_create_bin_file(dynamic_tables_kobj,
146 &table_attr->attr)) {
147 kfree(table_attr);
148 return AE_ERROR;
149 } else
150 list_add_tail(&table_attr->node,
151 &acpi_table_attr_list);
152 break;
153 case ACPI_TABLE_EVENT_UNLOAD:
154 /*
155 * we do not need to do anything right now
156 * because the table is not deleted from the
157 * global table list when unloading it.
158 */
159 break;
160 default:
161 return AE_BAD_PARAMETER;
162 }
163 return AE_OK;
164}
165
131static int acpi_system_sysfs_init(void) 166static int acpi_system_sysfs_init(void)
132{ 167{
133 struct acpi_table_attr *table_attr; 168 struct acpi_table_attr *table_attr;
@@ -137,7 +172,11 @@ static int acpi_system_sysfs_init(void)
137 172
138 tables_kobj = kobject_create_and_add("tables", acpi_kobj); 173 tables_kobj = kobject_create_and_add("tables", acpi_kobj);
139 if (!tables_kobj) 174 if (!tables_kobj)
140 return -ENOMEM; 175 goto err;
176
177 dynamic_tables_kobj = kobject_create_and_add("dynamic", tables_kobj);
178 if (!dynamic_tables_kobj)
179 goto err_dynamic_tables;
141 180
142 do { 181 do {
143 result = acpi_get_table_by_index(table_index, &table_header); 182 result = acpi_get_table_by_index(table_index, &table_header);
@@ -162,8 +201,14 @@ static int acpi_system_sysfs_init(void)
162 } 201 }
163 } while (!result); 202 } while (!result);
164 kobject_uevent(tables_kobj, KOBJ_ADD); 203 kobject_uevent(tables_kobj, KOBJ_ADD);
165 204 kobject_uevent(dynamic_tables_kobj, KOBJ_ADD);
166 return 0; 205 result = acpi_install_table_handler(acpi_sysfs_table_handler, NULL);
206
207 return result == AE_OK ? 0 : -EINVAL;
208err_dynamic_tables:
209 kobject_put(tables_kobj);
210err:
211 return -ENOMEM;
167} 212}
168 213
169/* 214/*