From patchwork Fri May 20 15:14:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 804022 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4KFFohS021511 for ; Fri, 20 May 2011 15:15:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933815Ab1ETPPs (ORCPT ); Fri, 20 May 2011 11:15:48 -0400 Received: from na3sys009aog102.obsmtp.com ([74.125.149.69]:36093 "EHLO na3sys009aog102.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933413Ab1ETPPr (ORCPT ); Fri, 20 May 2011 11:15:47 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]) (using TLSv1) by na3sys009aob102.postini.com ([74.125.148.12]) with SMTP ID DSNKTdaFn4QGPgSPe0WaHDP/UOhGkIUtSmZ9@postini.com; Fri, 20 May 2011 08:15:46 PDT Received: by mail-wy0-f174.google.com with SMTP id 21so4119290wya.33 for ; Fri, 20 May 2011 08:15:43 -0700 (PDT) Received: by 10.227.178.203 with SMTP id bn11mr512034wbb.51.1305904543016; Fri, 20 May 2011 08:15:43 -0700 (PDT) Received: from localhost ([192.91.60.233]) by mx.google.com with ESMTPS id o23sm2353073wbc.27.2011.05.20.08.15.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 May 2011 08:15:42 -0700 (PDT) From: Kevin Hilman To: linux-omap@vger.kernel.org, Grant Likely , Linus Walleij Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH 12/14] GPIO: OMAP: cleanup _set_gpio_wakeup(), remove ifdefs Date: Fri, 20 May 2011 17:14:55 +0200 Message-Id: <1305904497-26013-13-git-send-email-khilman@ti.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1305904497-26013-1-git-send-email-khilman@ti.com> References: <1305904497-26013-1-git-send-email-khilman@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 20 May 2011 15:15:50 +0000 (UTC) Make _set_gpio_wakeup() generic by removing ifdefs. Code for the various SoCs/bank-methods was already the same, except for the non-wakeup GPIO checking. But that flag is set on a per-SoC basis, so can be used for all SoCs. While here, use dev_err() and remove GPIO bank calculation assumption based on subtracting bank pointers. Signed-off-by: Kevin Hilman --- drivers/gpio/gpio_omap.c | 50 ++++++++++++++------------------------------- 1 files changed, 16 insertions(+), 34 deletions(-) diff --git a/drivers/gpio/gpio_omap.c b/drivers/gpio/gpio_omap.c index 8f4ae55..b5e2e94 100644 --- a/drivers/gpio/gpio_omap.c +++ b/drivers/gpio/gpio_omap.c @@ -533,42 +533,24 @@ static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int ena */ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable) { - unsigned long uninitialized_var(flags); + u32 gpio_bit = GPIO_BIT(bank, gpio); + unsigned long flags; - switch (bank->method) { -#ifdef CONFIG_ARCH_OMAP16XX - case METHOD_MPUIO: - case METHOD_GPIO_1610: - spin_lock_irqsave(&bank->lock, flags); - if (enable) - bank->suspend_wakeup |= (1 << gpio); - else - bank->suspend_wakeup &= ~(1 << gpio); - spin_unlock_irqrestore(&bank->lock, flags); - return 0; -#endif -#ifdef CONFIG_ARCH_OMAP2PLUS - case METHOD_GPIO_24XX: - case METHOD_GPIO_44XX: - if (bank->non_wakeup_gpios & (1 << gpio)) { - printk(KERN_ERR "Unable to modify wakeup on " - "non-wakeup GPIO%d\n", - (bank - gpio_bank) * bank->width + gpio); - return -EINVAL; - } - spin_lock_irqsave(&bank->lock, flags); - if (enable) - bank->suspend_wakeup |= (1 << gpio); - else - bank->suspend_wakeup &= ~(1 << gpio); - spin_unlock_irqrestore(&bank->lock, flags); - return 0; -#endif - default: - printk(KERN_ERR "Can't enable GPIO wakeup for method %i\n", - bank->method); + if (bank->non_wakeup_gpios & gpio_bit) { + dev_err(bank->dev, + "Unable to modify wakeup on non-wakeup GPIO%d\n", gpio); return -EINVAL; } + + spin_lock_irqsave(&bank->lock, flags); + if (enable) + bank->suspend_wakeup |= gpio_bit; + else + bank->suspend_wakeup &= ~gpio_bit; + + spin_unlock_irqrestore(&bank->lock, flags); + + return 0; } static void _reset_gpio(struct gpio_bank *bank, int gpio) @@ -587,7 +569,7 @@ static int gpio_wake_enable(struct irq_data *d, unsigned int enable) int retval; bank = irq_data_get_irq_chip_data(d); - retval = _set_gpio_wakeup(bank, GPIO_INDEX(bank, gpio), enable); + retval = _set_gpio_wakeup(bank, gpio, enable); return retval; }