Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753403Ab3CEIGd (ORCPT ); Tue, 5 Mar 2013 03:06:33 -0500 Received: from zoneX.GCU-Squad.org ([194.213.125.0]:48984 "EHLO services.gcu-squad.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753290Ab3CEIGc (ORCPT ); Tue, 5 Mar 2013 03:06:32 -0500 Date: Tue, 5 Mar 2013 09:06:20 +0100 From: Jean Delvare To: Peter Tyser Cc: LKML , Grant Likely , Linus Walleij Subject: [PATCH 1/2] gpio-ich: Check for pin availability at request time Message-ID: <20130305090620.2c9f1ff5@endymion.delvare> X-Mailer: Claws Mail 3.7.10 (GTK+ 2.24.7; x86_64-suse-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1804 Lines: 56 Stop checking for pin availability in get functions. These functions can be called repeatedly, so checking every time is bad for performance. Instead, check at pin request time. This only happens once, and we can let the caller know of the unavailability much earlier. Signed-off-by: Jean Delvare Cc: Peter Tyser Cc: Grant Likely Cc: Linus Walleij --- drivers/gpio/gpio-ich.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- linux-3.7.orig/drivers/gpio/gpio-ich.c 2013-03-05 08:36:40.940199905 +0100 +++ linux-3.7/drivers/gpio/gpio-ich.c 2013-03-05 08:36:51.047437884 +0100 @@ -169,9 +169,6 @@ static int ichx_gpio_direction_output(st static int ichx_gpio_get(struct gpio_chip *chip, unsigned nr) { - if (!ichx_gpio_check_available(chip, nr)) - return -ENXIO; - return ichx_read_bit(GPIO_LVL, nr); } @@ -180,9 +177,6 @@ static int ich6_gpio_get(struct gpio_chi unsigned long flags; u32 data; - if (!ichx_gpio_check_available(chip, nr)) - return -ENXIO; - /* * GPI 0 - 15 need to be read from the power management registers on * a ICH6/3100 bridge. @@ -207,6 +201,9 @@ static int ich6_gpio_get(struct gpio_chi static int ichx_gpio_request(struct gpio_chip *chip, unsigned nr) { + if (!ichx_gpio_check_available(chip, nr)) + return -ENXIO; + /* * Note we assume the BIOS properly set a bridge's USE value. Some * chips (eg Intel 3100) have bogus USE values though, so first see if -- Jean Delvare -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/