From patchwork Thu Nov 21 15:40:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 3219431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9C6309F26C for ; Thu, 21 Nov 2013 15:42:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 865F92038E for ; Thu, 21 Nov 2013 15:42:20 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 38AAA202EB for ; Thu, 21 Nov 2013 15:42:19 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VjWNt-0005Vs-HJ; Thu, 21 Nov 2013 15:41:38 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VjWNk-0006Tv-Dw; Thu, 21 Nov 2013 15:41:28 +0000 Received: from mail-pb0-x229.google.com ([2607:f8b0:400e:c01::229]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VjWNN-0006Pj-BF for linux-arm-kernel@lists.infradead.org; Thu, 21 Nov 2013 15:41:06 +0000 Received: by mail-pb0-f41.google.com with SMTP id jt11so11737727pbb.14 for ; Thu, 21 Nov 2013 07:40:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b7LmoKD8nBmhoNmQIhS4DYOJOKMzh8hrpu7EuvWW6Qc=; b=g986VVXFYL8s3aPSvJidZ7aZXdeKsvZO3rZHXm9l8ZzZZfUV9yM5/43+F664SyUeEL pLwoukSf3JjCfJHrVVGRg7YrGn7BV6Shce/GnWD6YEw6qs5ZoYcFjRxRTVM3U7zr5y1B Z4HOaU1inAzUxBFT6KG8QfbxsD2NnR24Dt7dFUb39FS2xhNUAU306nmHFoDz7ATyFcGW m7Y2R0j2U85HYJsUCV1zGxkSxVVBn96gQkUmRWUn4EoQyApz2FhKUebx7huYpPlWHhUV I8dHmnIee3Q0BX3T29aLk2YtYUOzTmw9vzozwKpYbydsHitTzZjUXdkRD09qpr/cZ2Uw 800A== X-Received: by 10.68.196.227 with SMTP id ip3mr6798923pbc.163.1385048443650; Thu, 21 Nov 2013 07:40:43 -0800 (PST) Received: from fangorn.rup.mentorg.com (nat-min.mentorg.com. [139.181.32.34]) by mx.google.com with ESMTPSA id g6sm44422162pat.2.2013.11.21.07.40.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Nov 2013 07:40:43 -0800 (PST) From: Dmitry Eremin-Solenikov To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/6] arm: sa1100: h3600: refactor LCD GPIO handling Date: Thu, 21 Nov 2013 19:40:10 +0400 Message-Id: <1385048414-9812-3-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1385048414-9812-1-git-send-email-dbaryshkov@gmail.com> References: <1385048414-9812-1-git-send-email-dbaryshkov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131121_104105_538587_A7ACCA41 X-CRM114-Status: GOOD ( 12.17 ) X-Spam-Score: -2.0 (--) Cc: Linus Walleij , Russell King , Dmitry Artamonow X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use gpio_request_array to request all GPIOs at once. Also don't call gpio_free. There is little point freeing LCD gpios once they are requested. Instead guard them with bool variable. Signed-off-by: Dmitry Eremin-Solenikov Acked-by: Linus Walleij --- arch/arm/mach-sa1100/h3600.c | 48 ++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c index b8dc5bd..559c2a0 100644 --- a/arch/arm/mach-sa1100/h3600.c +++ b/arch/arm/mach-sa1100/h3600.c @@ -28,35 +28,39 @@ /* * helper for sa1100fb */ +static struct gpio h3600_lcd_gpio[] = { + { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD power" }, + { H3600_EGPIO_LCD_PCI, GPIOF_OUT_INIT_LOW, "LCD control" }, + { H3600_EGPIO_LCD_5V_ON, GPIOF_OUT_INIT_LOW, "LCD 5v" }, + { H3600_EGPIO_LVDD_ON, GPIOF_OUT_INIT_LOW, "LCD 9v/-6.5v" }, +}; + +static bool h3600_lcd_request(void) +{ + static bool h3600_lcd_ok; + int rc; + + if (h3600_lcd_ok) + return true; + + rc = gpio_request_array(h3600_lcd_gpio, ARRAY_SIZE(h3600_lcd_gpio)); + if (rc) + pr_err("%s: can't request GPIOs\n", __func__); + else + h3600_lcd_ok = true; + + return h3600_lcd_ok; +} + static void h3600_lcd_power(int enable) { - if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power")) { - pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__); - goto err1; - } - if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control")) { - pr_err("%s: can't request H3XXX_EGPIO_LCD_PCI\n", __func__); - goto err2; - } - if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v")) { - pr_err("%s: can't request H3XXX_EGPIO_LCD_5V_ON\n", __func__); - goto err3; - } - if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v")) { - pr_err("%s: can't request H3600_EGPIO_LVDD_ON\n", __func__); - goto err4; - } + if (!h3600_lcd_request()) + return; gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable); gpio_direction_output(H3600_EGPIO_LCD_PCI, enable); gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable); gpio_direction_output(H3600_EGPIO_LVDD_ON, enable); - - gpio_free(H3600_EGPIO_LVDD_ON); -err4: gpio_free(H3600_EGPIO_LCD_5V_ON); -err3: gpio_free(H3600_EGPIO_LCD_PCI); -err2: gpio_free(H3XXX_EGPIO_LCD_ON); -err1: return; } static const struct sa1100fb_rgb h3600_rgb_16 = {