From patchwork Fri Mar 6 19:26:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Grygorii.Strashko@linaro.org" X-Patchwork-Id: 45495 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 97CD7214A0 for ; Fri, 6 Mar 2015 19:27:21 +0000 (UTC) Received: by wesu56 with SMTP id u56sf45507088wes.1 for ; Fri, 06 Mar 2015 11:27:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=rVDPKEjG+lAbZGi+qhBYzYT3Vtvs2jcR9ABhEEFvyFQ=; b=U/XmtSsG5YehWLKA9+HJ3q6u1EEuAZs+bDYK6TqXXo1YGcGkdEBBL0dxELfo0iVQ9a KaDrgUmEwrlkXrAlaL7tYCC/1+qHj3FUCTjMJUTuXorky4dmX4bg8linLyuf1ee0+XnZ dLTqDRPajwuE+24omELDL82bVlIoJr8hw2PrS2YUSgDPGQmIx2e/rXAYXIvIiojISOI2 dQiiC2CoMyYwuowGKM0BSNoQyT0LPH+RKhUJGPJ8E7iucViY3f97i6FIHssvNmbh0Ls0 2vx4PYUKFNIwFBNKpm9MsitRDsOXlQwwAaNhRaQIK+tOW/6xlCRLcBO/9lUaukP5tHM4 eJMA== X-Gm-Message-State: ALoCoQk5THkJDx8IIxQ/oRFTkxCNskYASRNZCi05/WSRW79wzmhjlUtR6niJes0/wXnblH4VKMUP X-Received: by 10.180.11.34 with SMTP id n2mr3020761wib.2.1425670040828; Fri, 06 Mar 2015 11:27:20 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.3 with SMTP id f3ls114397laa.31.gmail; Fri, 06 Mar 2015 11:27:20 -0800 (PST) X-Received: by 10.112.140.38 with SMTP id rd6mr14311877lbb.116.1425670040601; Fri, 06 Mar 2015 11:27:20 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id h6si7877136lbm.69.2015.03.06.11.27.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Mar 2015 11:27:20 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbiw7 with SMTP id w7so12867614lbi.6 for ; Fri, 06 Mar 2015 11:27:20 -0800 (PST) X-Received: by 10.112.162.232 with SMTP id yd8mr14191668lbb.41.1425670040465; Fri, 06 Mar 2015 11:27:20 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp96444lbj; Fri, 6 Mar 2015 11:27:19 -0800 (PST) X-Received: by 10.70.23.69 with SMTP id k5mr27959316pdf.68.1425670034352; Fri, 06 Mar 2015 11:27:14 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si4508163pdn.18.2015.03.06.11.27.13 for ; Fri, 06 Mar 2015 11:27:14 -0800 (PST) Received-SPF: none (google.com: linux-gpio-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755698AbbCFT1L (ORCPT ); Fri, 6 Mar 2015 14:27:11 -0500 Received: from mail-la0-f41.google.com ([209.85.215.41]:34840 "EHLO mail-la0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755913AbbCFT1J (ORCPT ); Fri, 6 Mar 2015 14:27:09 -0500 Received: by labmn12 with SMTP id mn12so23442952lab.2 for ; Fri, 06 Mar 2015 11:27:08 -0800 (PST) X-Received: by 10.152.182.196 with SMTP id eg4mr14406673lac.70.1425670027981; Fri, 06 Mar 2015 11:27:07 -0800 (PST) Received: from localhost ([195.238.92.128]) by mx.google.com with ESMTPSA id lf3sm1972252lbc.2.2015.03.06.11.27.07 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 06 Mar 2015 11:27:07 -0800 (PST) From: To: Linus Walleij , ssantosh@kernel.org, Javier Martinez Canillas , tony@atomide.com Cc: Alexandre Courbot , linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org, Grygorii Strashko Subject: [RFC/RFT PATCH 2/2] gpio: omap: ensure that runtime pm will disable unused gpio banks Date: Fri, 6 Mar 2015 21:26:57 +0200 Message-Id: <1425670017-19598-2-git-send-email-grygorii.strashko@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1425670017-19598-1-git-send-email-grygorii.strashko@linaro.org> References: <1425670017-19598-1-git-send-email-grygorii.strashko@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: grygorii.strashko@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Grygorii Strashko Now there are two points related to Runtime PM usage: 1) bank state doesn't need to be checked in places where Rintime PM is used, bacause Runtime PM maintains its own usage counter: if (!BANK_USED(bank)) pm_runtime_get_sync(bank->dev); so, it's safe to drop such checks. 2) There is a call of pm_runtime_get_sync() in omap_gpio_irq_type(), but no corresponding put. As result, GPIO devices could be powered on forever if at least one GPIO was used as IRQ. Hence, allow powering off GPIO banks by adding missed pm_runtime_put(bank->dev) at the end of omap_gpio_irq_type(). Signed-off-by: Grygorii Strashko --- drivers/gpio/gpio-omap.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 2b2fc4b..b1176c5 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -497,8 +497,7 @@ static int omap_gpio_irq_type(struct irq_data *d, unsigned type) unsigned long flags; unsigned offset; - if (!BANK_USED(bank)) - pm_runtime_get_sync(bank->dev); + pm_runtime_get_sync(bank->dev); #ifdef CONFIG_ARCH_OMAP1 if (d->irq > IH_MPUIO_BASE) @@ -530,6 +529,8 @@ static int omap_gpio_irq_type(struct irq_data *d, unsigned type) else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) __irq_set_handler_locked(d->irq, handle_edge_irq); + pm_runtime_put(bank->dev); + return retval; } @@ -680,8 +681,7 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset) * If this is the first gpio_request for the bank, * enable the bank module. */ - if (!BANK_USED(bank)) - pm_runtime_get_sync(bank->dev); + pm_runtime_get_sync(bank->dev); spin_lock_irqsave(&bank->lock, flags); /* Set trigger to none. You need to enable the desired trigger with @@ -713,8 +713,7 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) * If this is the last gpio to be freed in the bank, * disable the bank module. */ - if (!BANK_USED(bank)) - pm_runtime_put(bank->dev); + pm_runtime_put(bank->dev); } /* @@ -807,8 +806,7 @@ static unsigned int omap_gpio_irq_startup(struct irq_data *d) unsigned long flags; unsigned offset = GPIO_INDEX(bank, gpio); - if (!BANK_USED(bank)) - pm_runtime_get_sync(bank->dev); + pm_runtime_get_sync(bank->dev); spin_lock_irqsave(&bank->lock, flags); omap_gpio_init_irq(bank, gpio, offset); @@ -835,8 +833,7 @@ static void omap_gpio_irq_shutdown(struct irq_data *d) * If this is the last IRQ to be freed in the bank, * disable the bank module. */ - if (!BANK_USED(bank)) - pm_runtime_put(bank->dev); + pm_runtime_put(bank->dev); } static void omap_gpio_ack_irq(struct irq_data *d)