From patchwork Sun Mar 7 23:37:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 83984 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 o27NZ8qg018890 for ; Sun, 7 Mar 2010 23:35:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750931Ab0CGXfG (ORCPT ); Sun, 7 Mar 2010 18:35:06 -0500 Received: from ogre.sisk.pl ([217.79.144.158]:58356 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750959Ab0CGXfF (ORCPT ); Sun, 7 Mar 2010 18:35:05 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id 1EAD410093C; Mon, 8 Mar 2010 00:09:47 +0100 (CET) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19270-07; Mon, 8 Mar 2010 00:09:32 +0100 (CET) Received: from tosh.localnet (220-bem-13.acn.waw.pl [82.210.184.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id 45AF21747FA; Mon, 8 Mar 2010 00:09:32 +0100 (CET) From: "Rafael J. Wysocki" To: "Moore, Robert" Subject: [RFC][PATCH 3/3] ACPI / ACPICA: Reduce code duplication in acpi_ev_get_gpe_event_info() Date: Mon, 8 Mar 2010 00:37:13 +0100 User-Agent: KMail/1.12.4 (Linux/2.6.33-git-rjw; KDE/4.3.5; x86_64; ; ) Cc: Len Brown , ACPI Devel Maling List , Matthew Garrett References: <201003080034.11053.rjw@sisk.pl> In-Reply-To: <201003080034.11053.rjw@sisk.pl> MIME-Version: 1.0 Message-Id: <201003080037.13241.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux 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]); Sun, 07 Mar 2010 23:35:08 +0000 (UTC) Index: linux-2.6/drivers/acpi/acpica/evgpe.c =================================================================== --- linux-2.6.orig/drivers/acpi/acpica/evgpe.c +++ linux-2.6/drivers/acpi/acpica/evgpe.c @@ -168,6 +168,33 @@ acpi_status acpi_ev_disable_gpe(struct a return_ACPI_STATUS(status); } + +/******************************************************************************* + * + * FUNCTION: acpi_ev_get_info + * + * PARAMETERS: gpe_block - GPE block to search + * gpe_number - Raw GPE number + * + * RETURN: A GPE event_info struct if found. NULL if not found + * + ******************************************************************************/ + +static struct acpi_gpe_event_info *acpi_ev_get_info( + struct acpi_gpe_block_info *gpe_block, + u32 gpe_number) +{ + u32 gpe_index, gpe_count; + + if (!gpe_block || gpe_number < gpe_block->block_base_number) + return (NULL); + + gpe_index = gpe_number - gpe_block->block_base_number; + gpe_count = gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH; + return gpe_index < gpe_count ? + (&gpe_block->event_info[gpe_index]) : (NULL); +} + /******************************************************************************* * * FUNCTION: acpi_ev_get_gpe_event_info @@ -189,7 +216,7 @@ struct acpi_gpe_event_info *acpi_ev_get_ u32 gpe_number) { union acpi_operand_object *obj_desc; - struct acpi_gpe_block_info *gpe_block; + struct acpi_gpe_event_info *gpe_info; u32 i; ACPI_FUNCTION_ENTRY(); @@ -201,18 +228,10 @@ struct acpi_gpe_event_info *acpi_ev_get_ /* Examine GPE Block 0 and 1 (These blocks are permanent) */ for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { - gpe_block = acpi_gbl_gpe_fadt_blocks[i]; - if (gpe_block) { - if ((gpe_number >= gpe_block->block_base_number) - && (gpe_number < - gpe_block->block_base_number + - (gpe_block->register_count * 8))) { - return (&gpe_block-> - event_info[gpe_number - - gpe_block-> - block_base_number]); - } - } + gpe_info = acpi_ev_get_info(acpi_gbl_gpe_fadt_blocks[i], + gpe_number); + if (gpe_info) + return (gpe_info); } /* The gpe_number was not in the range of either FADT GPE block */ @@ -228,16 +247,7 @@ struct acpi_gpe_event_info *acpi_ev_get_ return (NULL); } - gpe_block = obj_desc->device.gpe_block; - - if ((gpe_number >= gpe_block->block_base_number) && - (gpe_number < - gpe_block->block_base_number + (gpe_block->register_count * 8))) { - return (&gpe_block-> - event_info[gpe_number - gpe_block->block_base_number]); - } - - return (NULL); + return acpi_ev_get_info(obj_desc->device.gpe_block, gpe_number); } /*******************************************************************************