oops. there is still one case that this patch doesn't cover. if the Load instruction is in the _INI method which means that the table is loaded before the gbl table handler is registered, the current code will recognize it as a static table. :( I'm not able to fix this issue without changing a lot of ACPICA code. A temporary fix is removing the "_dynamic" suffix. Peter says that "Since it is only additional information I would prefer keeping it and live with the occasional false positive (of almost static tables)." what do you think? thanks, rui On Mon, 2008-10-13 at 02:10 -0600, Zhang, Rui wrote: > Some ACPI tables are loaded at runtime. > create sysfs I/F for these dynamic tables in /sys/firmware/acpi/tables/. > > Signed-off-by: Zhang Rui <rui.zhang@xxxxxxxxx> > --- > drivers/acpi/system.c | 56 ++++++++++++++++++++++++++++++++++++++++---------- > 1 file changed, 45 insertions(+), 11 deletions(-) > > Index: linux-acpi-2.6/drivers/acpi/system.c > =================================================================== > --- linux-acpi-2.6.orig/drivers/acpi/system.c > +++ linux-acpi-2.6/drivers/acpi/system.c > @@ -100,7 +100,6 @@ static ssize_t acpi_table_show(struct ko > static void acpi_table_attr_init(struct acpi_table_attr *table_attr, > struct acpi_table_header *table_header) > { > - struct acpi_table_header *header = NULL; > struct acpi_table_attr *attr = NULL; > > memcpy(table_attr->name, table_header->signature, ACPI_NAME_SIZE); > @@ -113,15 +112,9 @@ static void acpi_table_attr_init(struct > } > table_attr->instance++; > > - if (table_attr->instance > 1 || (table_attr->instance == 1 && > - !acpi_get_table(table_header-> > - signature, 2, > - &header))) > + if (table_attr->instance > 1) > sprintf(table_attr->name + 4, "%d", table_attr->instance); > > - if (table_attr->flag) > - strncat(table_attr->name, "_inactive", > - ACPI_TABLE_NAME_MAX - strlen(table_attr->name)); > table_attr->attr.size = 0; > table_attr->attr.read = acpi_table_show; > table_attr->attr.attr.name = table_attr->name; > @@ -131,6 +124,42 @@ static void acpi_table_attr_init(struct > return; > } > > +static acpi_status > +acpi_sysfs_table_handler(u32 event, void *table, void *context) > +{ > + struct acpi_table_attr *table_attr = NULL; > + > + switch (event) { > + case ACPI_TABLE_EVENT_LOAD: > + table_attr = > + kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL); > + if (!table_attr) > + return AE_NO_MEMORY; > + > + acpi_table_attr_init(table_attr, table); > + strncat(table_attr->name, "_dynamic", > + ACPI_TABLE_NAME_MAX - strlen(table_attr->name)); > + > + if (sysfs_create_bin_file(tables_kobj, &table_attr->attr)) { > + kfree(table_attr); > + return AE_ERROR; > + } else > + list_add_tail(&table_attr->node, > + &acpi_table_attr_list); > + break; > + case ACPI_TABLE_EVENT_UNLOAD: > + /* > + * we do not need to do anything right now > + * because the table is not deleted from the > + * global table list when unloading it. > + */ > + break; > + default: > + return AE_BAD_PARAMETER; > + } > + return AE_OK; > +} > + > static int acpi_system_sysfs_init(void) > { > struct acpi_table_attr *table_attr; > @@ -162,12 +191,16 @@ static int acpi_system_sysfs_init(void) > if (!table_attr) > return -ENOMEM; > > - if (!active_tables) { > + if (!active_tables) > table_attr->flag = ACPI_TABLE_INACTIVE; > - table_attr->table_index = table_index; > - } > + > + table_attr->table_index = table_index; > table_index++; > acpi_table_attr_init(table_attr, table_header); > + if (!active_tables) > + strncat(table_attr->name, "_inactive", > + ACPI_TABLE_NAME_MAX - > + strlen(table_attr->name)); > > result = > sysfs_create_bin_file(tables_kobj, > @@ -189,6 +222,7 @@ static int acpi_system_sysfs_init(void) > } > } while (!result); > kobject_uevent(tables_kobj, KOBJ_ADD); > + acpi_gbl_table_handler = acpi_sysfs_table_handler; > > return 0; > } > > -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html