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: 6464981 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BA2C19F46A for ; Fri, 22 May 2015 14:36:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB04520483 for ; Fri, 22 May 2015 14:36:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E3FD120494 for ; Fri, 22 May 2015 14:36:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757270AbbEVOgO (ORCPT ); Fri, 22 May 2015 10:36:14 -0400 Received: from mail-la0-f44.google.com ([209.85.215.44]:35453 "EHLO mail-la0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757208AbbEVOgH (ORCPT ); Fri, 22 May 2015 10:36:07 -0400 Received: by labbd9 with SMTP id bd9so14013506lab.2 for ; Fri, 22 May 2015 07:36:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yCC4vExyPQVq3QVBAbrAEDNAbskYdCn+Jguh5xdbDeQ=; b=BaDRBXGi2bqWLCSEx+IcfkxSXOfeTd46fAL44w06fvCB9cGdFtVP5w/oy8NDFjuowS TW4Ptfx/cex4iNryhOcPeoQbM1svw7JIZVxS4HmivJhYunp5F1iV3xBOqYGRoiHYFoV3 2fLMtRtP3QxgWmJPX7eZQqEFuKok4pr9N3wzJ35hu5J+FRHonsrIc3C2O2K+Qmkeuzbl fOp/qXdtslfOILBm/5un4q8AgM/OsvhUE2svh5XT+j4RGIodd+O2gfbiRDP3tQhooe5I Q6nIW2sLNeq+yqrf189An0A05CE9kYsLkAk/xMZkM6jP+Lmb9BolDvRGOagrIQzZS9ic rUTw== X-Gm-Message-State: ALoCoQn3FkS5NNACK5FNRlsJBpuEwUQQ1uOiFkFl0WvG0tnrMvLYVMfqoU3K4uoqHdjaVnC4bemK 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-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 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 Acked-by: Javier Martinez Canillas --- 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; }