aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sysfs.c
diff options
context:
space:
mode:
authorJeremy Compostella <jeremy.compostella@intel.com>2013-11-21 05:20:23 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-11-21 08:19:33 -0500
commitde03beedb43fa1fd26792a4e502eeacbf5a6bade (patch)
tree13f16c658e3c48d29f183f49397f39d0be8edc9d /drivers/acpi/sysfs.c
parent083ca8c4172585409170dac9955a1da8137fef49 (diff)
ACPI / sysfs: Fix incorrect ACPI tables walk in acpi_tables_sysfs_init()
When executing on an ACPI Hardware Reduced hardware, all the ACPI tables are not exposed in sysfs due to the fact that FACS is silently ignored by the kernel in the ACPI hardware reduced mode and, moreover, the acpi_tables_sysfs_init() ACPI table walk is buggy and stops too soon. The acpi_tables_sysfs_init() function should rely on the acpi_status return value from acpi_get_table_by_index() to decide whether or not to stop the iteration (the walk should only be terminated when that value is AE_BAD_PARAMETER). This way, when running in an ACPI Harware Reduced environment (where the FACS table is silently ignored by the kernel) or if some ACPI tables are not correctly memory mapped or have bad checksums, it will still walk through the remaining tables that may be correct. [rjw: Changelog] Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/sysfs.c')
-rw-r--r--drivers/acpi/sysfs.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 45f82c751225..6dbc3ca45223 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -354,8 +354,9 @@ static int acpi_tables_sysfs_init(void)
354{ 354{
355 struct acpi_table_attr *table_attr; 355 struct acpi_table_attr *table_attr;
356 struct acpi_table_header *table_header = NULL; 356 struct acpi_table_header *table_header = NULL;
357 int table_index = 0; 357 int table_index;
358 int result; 358 acpi_status status;
359 int ret;
359 360
360 tables_kobj = kobject_create_and_add("tables", acpi_kobj); 361 tables_kobj = kobject_create_and_add("tables", acpi_kobj);
361 if (!tables_kobj) 362 if (!tables_kobj)
@@ -365,33 +366,34 @@ static int acpi_tables_sysfs_init(void)
365 if (!dynamic_tables_kobj) 366 if (!dynamic_tables_kobj)
366 goto err_dynamic_tables; 367 goto err_dynamic_tables;
367 368
368 do { 369 for (table_index = 0;; table_index++) {
369 result = acpi_get_table_by_index(table_index, &table_header); 370 status = acpi_get_table_by_index(table_index, &table_header);
370 if (!result) { 371
371 table_index++; 372 if (status == AE_BAD_PARAMETER)
372 table_attr = NULL; 373 break;
373 table_attr = 374
374 kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL); 375 if (ACPI_FAILURE(status))
375 if (!table_attr) 376 continue;
376 return -ENOMEM; 377
377 378 table_attr = NULL;
378 acpi_table_attr_init(table_attr, table_header); 379 table_attr = kzalloc(sizeof(*table_attr), GFP_KERNEL);
379 result = 380 if (!table_attr)
380 sysfs_create_bin_file(tables_kobj, 381 return -ENOMEM;
381 &table_attr->attr); 382
382 if (result) { 383 acpi_table_attr_init(table_attr, table_header);
383 kfree(table_attr); 384 ret = sysfs_create_bin_file(tables_kobj, &table_attr->attr);
384 return result; 385 if (ret) {
385 } else 386 kfree(table_attr);
386 list_add_tail(&table_attr->node, 387 return ret;
387 &acpi_table_attr_list);
388 } 388 }
389 } while (!result); 389 list_add_tail(&table_attr->node, &acpi_table_attr_list);
390 }
391
390 kobject_uevent(tables_kobj, KOBJ_ADD); 392 kobject_uevent(tables_kobj, KOBJ_ADD);
391 kobject_uevent(dynamic_tables_kobj, KOBJ_ADD); 393 kobject_uevent(dynamic_tables_kobj, KOBJ_ADD);
392 result = acpi_install_table_handler(acpi_sysfs_table_handler, NULL); 394 status = acpi_install_table_handler(acpi_sysfs_table_handler, NULL);
393 395
394 return result == AE_OK ? 0 : -EINVAL; 396 return ACPI_FAILURE(status) ? -EINVAL : 0;
395err_dynamic_tables: 397err_dynamic_tables:
396 kobject_put(tables_kobj); 398 kobject_put(tables_kobj);
397err: 399err: