From patchwork Fri May 22 14:35:49 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: 48889 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 181AD214BA for ; Fri, 22 May 2015 14:36:46 +0000 (UTC) Received: by wgbgf7 with SMTP id gf7sf5814798wgb.2 for ; Fri, 22 May 2015 07:36:45 -0700 (PDT) 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=Z0edPLWgKGP1e2R+RdkXY1iNRoWpuTbw0Ds6/+7R3aY=; b=YfDteC7RPlqtQBvrU3MeQUk9dR1gxkXI8/FtwQgL9gS2tj7PNyjDt8j+epkPFDW8hc RORDSKhq330kViMhpLj+w9okRXvveFN0sRva1hLJSSgLekQJuD1GoeVgnmG2WOsYPnu6 lKFCFQOpc8E8DezuMcsYT0iMh2PlcxP8DZVfW/MPUNXj67uKKkHctIjqpzJFB3f9b/1Q tR5saH7hKhjvyXtXOd0ecMffbl0HPpyjjB97Jqvl9VkQ8EaBEp9V2kzh0XdHVZ1DcIfQ u1/Te9syH3Mh+q73arfCzgcQuTKLeRmTH4e43JHbpikvC3kIEYkCxrdeILxbNpkyBnX1 qW0w== X-Gm-Message-State: ALoCoQmq5GSf3eOGSxLhQs3jAVUeEmVa1ckSFgUK61ppWUaDNkbGQBvUJEWHoPGVEuWwqQa6xfwt X-Received: by 10.180.106.10 with SMTP id gq10mr4301503wib.0.1432305405374; Fri, 22 May 2015 07:36:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.68 with SMTP id be4ls436773lab.47.gmail; Fri, 22 May 2015 07:36:45 -0700 (PDT) X-Received: by 10.112.64.193 with SMTP id q1mr6549794lbs.11.1432305405084; Fri, 22 May 2015 07:36:45 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id ps10si1535656lbb.26.2015.05.22.07.36.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 May 2015 07:36:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by laat2 with SMTP id t2so14029679laa.1 for ; Fri, 22 May 2015 07:36:45 -0700 (PDT) X-Received: by 10.152.4.137 with SMTP id k9mr6577725lak.29.1432305404964; Fri, 22 May 2015 07:36:44 -0700 (PDT) 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.108.230 with SMTP id hn6csp1453861lbb; Fri, 22 May 2015 07:36:43 -0700 (PDT) X-Received: by 10.70.56.4 with SMTP id w4mr16352841pdp.148.1432305402717; Fri, 22 May 2015 07:36:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ci13si3665255pac.227.2015.05.22.07.36.41; Fri, 22 May 2015 07:36:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757253AbbEVOgK (ORCPT + 1 other); Fri, 22 May 2015 10:36:10 -0400 Received: from mail-lb0-f181.google.com ([209.85.217.181]:34200 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757233AbbEVOgI (ORCPT ); Fri, 22 May 2015 10:36:08 -0400 Received: by lbcmx3 with SMTP id mx3so14321270lbc.1 for ; Fri, 22 May 2015 07:36:06 -0700 (PDT) X-Received: by 10.112.161.197 with SMTP id xu5mr6587456lbb.69.1432305366152; Fri, 22 May 2015 07:36:06 -0700 (PDT) Received: from localhost ([195.238.92.128]) by mx.google.com with ESMTPSA id oy3sm535594lbb.1.2015.05.22.07.36.05 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 22 May 2015 07:36:05 -0700 (PDT) From: Grygorii Strashko To: Linus Walleij , Alexandre Courbot , tony@atomide.com Cc: Javier Martinez Canillas , ssantosh@kernel.org, Kevin Hilman , linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org, Grygorii Strashko Subject: [PATCH 2/7] gpio: omap: fix error handling in omap_gpio_irq_type Date: Fri, 22 May 2015 17:35:49 +0300 Message-Id: <1432305354-5968-3-git-send-email-grygorii.strashko@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432305354-5968-1-git-send-email-grygorii.strashko@linaro.org> References: <1432305354-5968-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.215.48 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: , The GPIO bank will be kept powered in case if input parameters are invalid or error occurred in omap_gpio_irq_type. Hence, fix it by ensuring that GPIO bank will be unpowered in case of errors and add additional check of value returned from omap_set_gpio_triggering(). Signed-off-by: Grygorii Strashko --- drivers/gpio/gpio-omap.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index bb60cbc..f6cc638 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -488,9 +488,6 @@ static int omap_gpio_irq_type(struct irq_data *d, unsigned type) unsigned long flags; unsigned offset = d->hwirq; - if (!BANK_USED(bank)) - pm_runtime_get_sync(bank->dev); - if (type & ~IRQ_TYPE_SENSE_MASK) return -EINVAL; @@ -498,12 +495,18 @@ static int omap_gpio_irq_type(struct irq_data *d, unsigned type) (type & (IRQ_TYPE_LEVEL_LOW|IRQ_TYPE_LEVEL_HIGH))) return -EINVAL; + if (!BANK_USED(bank)) + pm_runtime_get_sync(bank->dev); + spin_lock_irqsave(&bank->lock, flags); retval = omap_set_gpio_triggering(bank, offset, type); + if (retval) + goto error; omap_gpio_init_irq(bank, offset); if (!omap_gpio_is_input(bank, offset)) { spin_unlock_irqrestore(&bank->lock, flags); - return -EINVAL; + retval = -EINVAL; + goto error; } spin_unlock_irqrestore(&bank->lock, flags); @@ -512,6 +515,11 @@ 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); + return 0; + +error: + if (!BANK_USED(bank)) + pm_runtime_put(bank->dev); return retval; }