From patchwork Thu Feb 26 03:27:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 8878 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1Q3REb6013728 for ; Thu, 26 Feb 2009 03:27:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752914AbZBZD1P (ORCPT ); Wed, 25 Feb 2009 22:27:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752954AbZBZD1P (ORCPT ); Wed, 25 Feb 2009 22:27:15 -0500 Received: from mga11.intel.com ([192.55.52.93]:39312 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752914AbZBZD1O (ORCPT ); Wed, 25 Feb 2009 22:27:14 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 25 Feb 2009 19:25:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,268,1233561600"; d="scan'208";a="668606437" Received: from rzhang-dt.sh.intel.com (HELO [10.239.36.213]) ([10.239.36.213]) by fmsmga001.fm.intel.com with ESMTP; 25 Feb 2009 19:31:02 -0800 Subject: [PATCH] ACPI: introduce sysfs I/F for dynamic tables From: Zhang Rui To: Len Brown Cc: linux-acpi , "Zhang, Rui" Date: Thu, 26 Feb 2009 11:27:23 +0800 Message-Id: <1235618843.32297.140.camel@rzhang-dt> Mime-Version: 1.0 X-Mailer: Evolution 2.22.1 (2.22.1-2.fc9) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- drivers/acpi/system.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/acpi/system.c =================================================================== --- linux-2.6.orig/drivers/acpi/system.c +++ linux-2.6/drivers/acpi/system.c @@ -62,6 +62,7 @@ module_param_call(acpica_version, NULL, -------------------------------------------------------------------------- */ static LIST_HEAD(acpi_table_attr_list); static struct kobject *tables_kobj; +static struct kobject *dynamic_tables_kobj; struct acpi_table_attr { struct bin_attribute attr; @@ -128,6 +129,40 @@ 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; + + 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); + if (sysfs_create_bin_file(dynamic_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; @@ -137,7 +172,11 @@ static int acpi_system_sysfs_init(void) tables_kobj = kobject_create_and_add("tables", acpi_kobj); if (!tables_kobj) - return -ENOMEM; + goto err; + + dynamic_tables_kobj = kobject_create_and_add("dynamic", tables_kobj); + if (!dynamic_tables_kobj) + goto err_dynamic_tables; do { result = acpi_get_table_by_index(table_index, &table_header); @@ -162,8 +201,14 @@ static int acpi_system_sysfs_init(void) } } while (!result); kobject_uevent(tables_kobj, KOBJ_ADD); + kobject_uevent(dynamic_tables_kobj, KOBJ_ADD); + result = acpi_install_table_handler(acpi_sysfs_table_handler, NULL); - return 0; + return result == AE_OK ? 0 : -EINVAL; +err_dynamic_tables: + kobject_put(tables_kobj); +err: + return -ENOMEM; } /*