From patchwork Wed Jul 13 13:54:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun Kanti DebBarma X-Patchwork-Id: 972022 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6DDtF0v003000 for ; Wed, 13 Jul 2011 13:55:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754710Ab1GMNzO (ORCPT ); Wed, 13 Jul 2011 09:55:14 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:35153 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754696Ab1GMNzN (ORCPT ); Wed, 13 Jul 2011 09:55:13 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id p6DDt3Zv010042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Jul 2011 08:55:06 -0500 Received: from dbde70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id p6DDt3Zf001766; Wed, 13 Jul 2011 19:25:03 +0530 (IST) Received: from dbdp31.itg.ti.com (172.24.170.98) by DBDE70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 8.3.106.1; Wed, 13 Jul 2011 19:25:03 +0530 Received: from localhost.localdomain ([172.24.190.106]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p6DDsKD3020505; Wed, 13 Jul 2011 19:25:00 +0530 (IST) From: Tarun Kanti DebBarma To: CC: , , , , Tarun Kanti DebBarma Subject: [PATCH v4 19/20] gpio/omap: optimize suspend and resume functions Date: Wed, 13 Jul 2011 19:24:18 +0530 Message-ID: <1310565259-31267-20-git-send-email-tarun.kanti@ti.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1310565259-31267-1-git-send-email-tarun.kanti@ti.com> References: <1310565259-31267-1-git-send-email-tarun.kanti@ti.com> MIME-Version: 1.0 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]); Wed, 13 Jul 2011 13:55:17 +0000 (UTC) There is no need to operate on all the banks every time the function is called. Just operate on the current bank passed by the framework. Signed-off-by: Tarun Kanti DebBarma --- drivers/gpio/gpio-omap.c | 53 +++++++++++++++++++++------------------------ 1 files changed, 25 insertions(+), 28 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 3f1b992..47e5e20 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -1062,6 +1062,8 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev) goto err_free; } + platform_set_drvdata(pdev, bank); + pm_runtime_enable(bank->dev); pm_runtime_irq_safe(bank->dev); if (IS_ERR_VALUE(pm_runtime_get_sync(bank->dev) < 0)) { @@ -1094,26 +1096,23 @@ err_exit: static int omap_gpio_suspend(struct device *dev) { - struct gpio_bank *bank; - - pm_runtime_get_sync(dev); + struct platform_device *pdev = to_platform_device(dev); + struct gpio_bank *bank = platform_get_drvdata(pdev); + void __iomem *base = bank->base; + void __iomem *wake_status; + unsigned long flags; - list_for_each_entry(bank, &omap_gpio_list, node) { - void __iomem *base = bank->base; - void __iomem *wake_status; - unsigned long flags; + if (!bank->regs->wkup_status || !bank->suspend_wakeup) + return 0; - if (!bank->regs->wkup_status) - return 0; + wake_status = bank->base + bank->regs->wkup_status; - wake_status = bank->base + bank->regs->wkup_status; + pm_runtime_get_sync(dev); - spin_lock_irqsave(&bank->lock, flags); - bank->saved_wakeup = __raw_readl(wake_status); - _gpio_rmw(base, bank->regs->wkup_status, - bank->suspend_wakeup, 1); - spin_unlock_irqrestore(&bank->lock, flags); - } + spin_lock_irqsave(&bank->lock, flags); + bank->saved_wakeup = __raw_readl(wake_status); + _gpio_rmw(base, bank->regs->wkup_status, bank->suspend_wakeup, 1); + spin_unlock_irqrestore(&bank->lock, flags); pm_runtime_put_sync(dev); @@ -1122,21 +1121,19 @@ static int omap_gpio_suspend(struct device *dev) static int omap_gpio_resume(struct device *dev) { - struct gpio_bank *bank; + struct platform_device *pdev = to_platform_device(dev); + struct gpio_bank *bank = platform_get_drvdata(pdev); + void __iomem *base = bank->base; + unsigned long flags; - pm_runtime_get_sync(dev); + if (!bank->regs->wkup_status || !bank->saved_wakeup) + return 0; - list_for_each_entry(bank, &omap_gpio_list, node) { - void __iomem *base = bank->base; - unsigned long flags; - - if (!bank->regs->wkup_status) - return 0; + pm_runtime_get_sync(dev); - spin_lock_irqsave(&bank->lock, flags); - _gpio_rmw(base, bank->regs->wkup_status, bank->saved_wakeup, 1); - spin_unlock_irqrestore(&bank->lock, flags); - } + spin_lock_irqsave(&bank->lock, flags); + _gpio_rmw(base, bank->regs->wkup_status, bank->saved_wakeup, 1); + spin_unlock_irqrestore(&bank->lock, flags); pm_runtime_put_sync(dev);