From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: [PATCH 6/12] ACPI: Add support for new refcounted GPE API to drivers Date: Sun, 27 Dec 2009 21:03:54 +0100 Message-ID: <200912272103.54675.rjw@sisk.pl> References: <200912272057.10443.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <200912272057.10443.rjw@sisk.pl> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org To: Jesse Barnes Cc: Linux PCI , LKML , ACPI Devel Maling List , Francois Romieu , pm list , Matthew Garrett List-Id: linux-acpi@vger.kernel.org From: Matthew Garrett Add GPE refcounting support to ACPI drivers that need it. This will currently do little until the core is changed over to use the new behaviour. Signed-off-by: Matthew Garrett Signed-off-by; Rafael J. Wysocki --- drivers/acpi/button.c | 12 ++++++++++++ drivers/acpi/button.c | 12 ++++++++++++ drivers/acpi/ec.c | 4 +++- drivers/acpi/wakeup.c | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) Index: linux-2.6/drivers/acpi/button.c =================================================================== --- linux-2.6.orig/drivers/acpi/button.c +++ linux-2.6/drivers/acpi/button.c @@ -427,6 +427,10 @@ static int acpi_button_add(struct acpi_d ACPI_GPE_TYPE_WAKE_RUN); acpi_enable_gpe(device->wakeup.gpe_device, device->wakeup.gpe_number); + acpi_ref_runtime_gpe(device->wakeup.gpe_device, + device->wakeup.gpe_number); + acpi_ref_wakeup_gpe(device->wakeup.gpe_device, + device->wakeup.gpe_number); device->wakeup.state.enabled = 1; } @@ -446,6 +450,14 @@ static int acpi_button_remove(struct acp { struct acpi_button *button = acpi_driver_data(device); + if (device->wakeup.flags.valid) { + acpi_unref_runtime_gpe(device->wakeup.gpe_device, + device->wakeup.gpe_number); + acpi_unref_wakeup_gpe(device->wakeup.gpe_device, + device->wakeup.gpe_number); + device->wakeup.state.enabled = 0; + } + acpi_button_remove_fs(device); input_unregister_device(button->input); kfree(button); Index: linux-2.6/drivers/acpi/ec.c =================================================================== --- linux-2.6.orig/drivers/acpi/ec.c +++ linux-2.6/drivers/acpi/ec.c @@ -755,7 +755,7 @@ static int ec_install_handlers(struct ac if (ACPI_FAILURE(status)) return -ENODEV; acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); - acpi_enable_gpe(NULL, ec->gpe); + acpi_ref_runtime_gpe(NULL, ec->gpe); status = acpi_install_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, @@ -772,6 +772,7 @@ static int ec_install_handlers(struct ac } else { acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler); + acpi_unref_runtime_gpe(NULL, ec->gpe); return -ENODEV; } } @@ -782,6 +783,7 @@ static int ec_install_handlers(struct ac static void ec_remove_handlers(struct acpi_ec *ec) { + acpi_unref_runtime_gpe(NULL, ec->gpe); if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) pr_err(PREFIX "failed to remove space handler\n"); Index: linux-2.6/drivers/acpi/wakeup.c =================================================================== --- linux-2.6.orig/drivers/acpi/wakeup.c +++ linux-2.6/drivers/acpi/wakeup.c @@ -81,6 +81,8 @@ void acpi_enable_wakeup_device(u8 sleep_ if (!dev->wakeup.flags.run_wake) acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); + acpi_ref_wakeup_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } } @@ -121,6 +123,8 @@ void acpi_disable_wakeup_device(u8 sleep acpi_clear_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number, ACPI_NOT_ISR); } + acpi_unref_wakeup_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } } @@ -141,6 +145,8 @@ int __init acpi_wakeup_device_init(void) ACPI_GPE_TYPE_WAKE_RUN); acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); + acpi_ref_wakeup_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number); dev->wakeup.state.enabled = 1; } mutex_unlock(&acpi_device_lock); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751483AbZL0UNs (ORCPT ); Sun, 27 Dec 2009 15:13:48 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751447AbZL0UNo (ORCPT ); Sun, 27 Dec 2009 15:13:44 -0500 Received: from ogre.sisk.pl ([217.79.144.158]:60450 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751271AbZL0ULs (ORCPT ); Sun, 27 Dec 2009 15:11:48 -0500 From: "Rafael J. Wysocki" To: Jesse Barnes Subject: [PATCH 6/12] ACPI: Add support for new refcounted GPE API to drivers Date: Sun, 27 Dec 2009 21:03:54 +0100 User-Agent: KMail/1.12.3 (Linux/2.6.33-rc2-tst; KDE/4.3.3; x86_64; ; ) Cc: Matthew Garrett , Len Brown , LKML , pm list , Alan Stern , ACPI Devel Maling List , Linux PCI , Oliver Neukum , Bjorn Helgaas , Shaohua Li , Francois Romieu References: <200912272057.10443.rjw@sisk.pl> In-Reply-To: <200912272057.10443.rjw@sisk.pl> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912272103.54675.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Garrett Add GPE refcounting support to ACPI drivers that need it. This will currently do little until the core is changed over to use the new behaviour. Signed-off-by: Matthew Garrett Signed-off-by; Rafael J. Wysocki --- drivers/acpi/button.c | 12 ++++++++++++ drivers/acpi/button.c | 12 ++++++++++++ drivers/acpi/ec.c | 4 +++- drivers/acpi/wakeup.c | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) Index: linux-2.6/drivers/acpi/button.c =================================================================== --- linux-2.6.orig/drivers/acpi/button.c +++ linux-2.6/drivers/acpi/button.c @@ -427,6 +427,10 @@ static int acpi_button_add(struct acpi_d ACPI_GPE_TYPE_WAKE_RUN); acpi_enable_gpe(device->wakeup.gpe_device, device->wakeup.gpe_number); + acpi_ref_runtime_gpe(device->wakeup.gpe_device, + device->wakeup.gpe_number); + acpi_ref_wakeup_gpe(device->wakeup.gpe_device, + device->wakeup.gpe_number); device->wakeup.state.enabled = 1; } @@ -446,6 +450,14 @@ static int acpi_button_remove(struct acp { struct acpi_button *button = acpi_driver_data(device); + if (device->wakeup.flags.valid) { + acpi_unref_runtime_gpe(device->wakeup.gpe_device, + device->wakeup.gpe_number); + acpi_unref_wakeup_gpe(device->wakeup.gpe_device, + device->wakeup.gpe_number); + device->wakeup.state.enabled = 0; + } + acpi_button_remove_fs(device); input_unregister_device(button->input); kfree(button); Index: linux-2.6/drivers/acpi/ec.c =================================================================== --- linux-2.6.orig/drivers/acpi/ec.c +++ linux-2.6/drivers/acpi/ec.c @@ -755,7 +755,7 @@ static int ec_install_handlers(struct ac if (ACPI_FAILURE(status)) return -ENODEV; acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); - acpi_enable_gpe(NULL, ec->gpe); + acpi_ref_runtime_gpe(NULL, ec->gpe); status = acpi_install_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, @@ -772,6 +772,7 @@ static int ec_install_handlers(struct ac } else { acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler); + acpi_unref_runtime_gpe(NULL, ec->gpe); return -ENODEV; } } @@ -782,6 +783,7 @@ static int ec_install_handlers(struct ac static void ec_remove_handlers(struct acpi_ec *ec) { + acpi_unref_runtime_gpe(NULL, ec->gpe); if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) pr_err(PREFIX "failed to remove space handler\n"); Index: linux-2.6/drivers/acpi/wakeup.c =================================================================== --- linux-2.6.orig/drivers/acpi/wakeup.c +++ linux-2.6/drivers/acpi/wakeup.c @@ -81,6 +81,8 @@ void acpi_enable_wakeup_device(u8 sleep_ if (!dev->wakeup.flags.run_wake) acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); + acpi_ref_wakeup_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } } @@ -121,6 +123,8 @@ void acpi_disable_wakeup_device(u8 sleep acpi_clear_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number, ACPI_NOT_ISR); } + acpi_unref_wakeup_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number); } } @@ -141,6 +145,8 @@ int __init acpi_wakeup_device_init(void) ACPI_GPE_TYPE_WAKE_RUN); acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); + acpi_ref_wakeup_gpe(dev->wakeup.gpe_device, + dev->wakeup.gpe_number); dev->wakeup.state.enabled = 1; } mutex_unlock(&acpi_device_lock);