From patchwork Mon May 3 20:02:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 96549 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o43JxEG5025550 for ; Mon, 3 May 2010 19:59:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756254Ab0ECT74 (ORCPT ); Mon, 3 May 2010 15:59:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12855 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756381Ab0ECT7z (ORCPT ); Mon, 3 May 2010 15:59:55 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o43Jxj5W010738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 3 May 2010 15:59:45 -0400 Received: from cavan.codon.org.uk (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o43JxiAe004867 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Mon, 3 May 2010 15:59:45 -0400 Received: from lan-nat-pool-bos.redhat.com ([66.187.234.200] helo=localhost.localdomain) by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1O91no-0004Pj-C6; Mon, 03 May 2010 20:59:40 +0100 From: Matthew Garrett To: linux-acpi@vger.kernel.org Cc: ibm-acpi@hmh.eng.br, ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, Matthew Garrett Subject: [PATCH 1/2] acpi: Provide interface for driver notification on method call Date: Mon, 3 May 2010 16:02:59 -0400 Message-Id: <1272916980-11835-1-git-send-email-mjg@redhat.com> X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 66.187.234.200 X-SA-Exim-Mail-From: mjg@redhat.com X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 03 May 2010 19:59:57 +0000 (UTC) diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h index cde18ea..b46b23c 100644 --- a/drivers/acpi/acpica/acobject.h +++ b/drivers/acpi/acpica/acobject.h @@ -188,6 +188,8 @@ struct acpi_object_method { u32 aml_length; u8 thread_count; acpi_owner_id owner_id; + acpi_osd_exec_callback notify; + void *context; }; /****************************************************************************** diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c index 7210392..a453cda 100644 --- a/drivers/acpi/acpica/dsmethod.c +++ b/drivers/acpi/acpica/dsmethod.c @@ -420,6 +420,11 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, } } + if (obj_desc->method.notify) { + acpi_os_execute(OSL_NOTIFY_HANDLER, obj_desc->method.notify, + obj_desc->method.context); + } + return_ACPI_STATUS(status); cleanup: diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c index b407579..af81832 100644 --- a/drivers/acpi/acpica/evxface.c +++ b/drivers/acpi/acpica/evxface.c @@ -653,6 +653,109 @@ ACPI_EXPORT_SYMBOL(acpi_remove_notify_handler) /******************************************************************************* * + * FUNCTION: acpi_install_method_handler + * + * PARAMETERS: Oathname - The method for which notifies will be handled + * Handler - Address of the handler + * Context - Value passed to the handler on each call + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for notifies on ACPI method execution + * + ******************************************************************************/ + +acpi_status +acpi_install_method_handler (acpi_handle handle, acpi_method_handler handler, + void *context) +{ + struct acpi_namespace_node *node; + union acpi_operand_object *method; + acpi_status status; + + if (!handle || !handler) + return_ACPI_STATUS(AE_BAD_PARAMETER); + + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE(status)) + return_ACPI_STATUS(status); + + node = acpi_ns_validate_handle(handle); + + if (!node) { + status = AE_BAD_PARAMETER; + goto unlock_and_exit; + } + + method = acpi_ns_get_attached_object(node); + + if (method->method.notify) { + status = AE_ALREADY_EXISTS; + goto unlock_and_exit; + } + + method->method.notify = handler; + method->method.context = context; + +unlock_and_exit: + acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); +} +ACPI_EXPORT_SYMBOL(acpi_install_method_handler) + +/******************************************************************************* + * + * FUNCTION: acpi_remove_method_handler + * + * PARAMETERS: Pathname - The method for which notifies will be handled + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a handler for notifies on ACPI method execution + * + ******************************************************************************/ + +acpi_status +acpi_remove_method_handler (acpi_handle handle, acpi_method_handler handler) +{ + struct acpi_namespace_node *node; + union acpi_operand_object *method; + acpi_status status; + + if (!handle || !handler) + return_ACPI_STATUS(AE_BAD_PARAMETER); + + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) + return_ACPI_STATUS(status); + + node = acpi_ns_validate_handle(handle); + + if (!node) { + status = AE_BAD_PARAMETER; + goto unlock_and_exit; + } + + method = acpi_ns_get_attached_object(node); + + if (method->method.notify != handler) { + status = AE_BAD_PARAMETER; + goto unlock_and_exit; + } + + method->method.notify = NULL; + method->method.context = NULL; + +unlock_and_exit: + acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(status); +} +ACPI_EXPORT_SYMBOL(acpi_remove_method_handler) + +/******************************************************************************* + * * FUNCTION: acpi_install_gpe_handler * * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 4447a04..21e7646 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -240,6 +240,13 @@ acpi_remove_notify_handler(acpi_handle device, u32 handler_type, acpi_notify_handler handler); acpi_status +acpi_install_method_handler(acpi_handle handle, acpi_method_handler handler, + void *context); + +acpi_status +acpi_remove_method_handler(acpi_handle handle, acpi_method_handler handler); + +acpi_status acpi_install_address_space_handler(acpi_handle device, acpi_adr_space_type space_id, acpi_adr_space_handler handler, diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 3f08e64..bf2fcf8 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -916,6 +916,8 @@ void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context); typedef void (*acpi_object_handler) (acpi_handle object, void *data); +typedef void (*acpi_method_handler) (void *context); + typedef acpi_status(*acpi_init_handler) (acpi_handle object, u32 function); #define ACPI_INIT_DEVICE_INI 1