From patchwork Fri May 22 14:35:52 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: 6465011 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3E73AC0020 for ; Fri, 22 May 2015 14:36:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 681C020495 for ; Fri, 22 May 2015 14:36:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA45F2049C for ; Fri, 22 May 2015 14:36:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756486AbbEVOgV (ORCPT ); Fri, 22 May 2015 10:36:21 -0400 Received: from mail-lb0-f177.google.com ([209.85.217.177]:36309 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757233AbbEVOgM (ORCPT ); Fri, 22 May 2015 10:36:12 -0400 Received: by lbbqq2 with SMTP id qq2so14264991lbb.3 for ; Fri, 22 May 2015 07:36:10 -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=l7Y6cjk0zlOlCrv1Dhhr3yNeP6gnanCIQt3DSem/EAk=; b=ha5bicXNEAO7bLD0y3UHSb3+h38DacDkwCxzoHPizdLQEI5I/QlB14xfioPCy6dkwu svthpkImmI8qbaP887cHerT+Gi1EhahUJ/sbndqCazXppd+XIe1wnwo4W6YCJWnmnAHA xA440+As7NP+xXcGeNW3GaejoevVSH30isjSzp3cOaBRzFq9kgAY1tf3ExTF5HHbgMXw Yf8o/5Ak0GHEs8llxbHLCoYzZuN/w+IrCD5UaxfXzpbUSt1Em8NR9/MkmHZnLF95t9bA Fv8syA6E/5iucJFxED+LW6lAuZNQdNwOvnX/TWwJNBw6x/12eSinDWQrI8CCGJUxldQO 1DHA== X-Gm-Message-State: ALoCoQmzUNUwsoC/Y/EU1ty7dYq9I9qceUkFuJLG9ikdQ/17M+R5S4op8b5gHz8gJ0g+38yepAJ5 X-Received: by 10.152.115.132 with SMTP id jo4mr6850558lab.102.1432305370595; Fri, 22 May 2015 07:36:10 -0700 (PDT) Received: from localhost ([195.238.92.128]) by mx.google.com with ESMTPSA id n10sm524957laa.40.2015.05.22.07.36.09 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 22 May 2015 07:36:09 -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: [RFC/RFT PATCH 5/7] gpio: omap: rework omap_gpio_irq_startup to handle current pin state properly Date: Fri, 22 May 2015 17:35:52 +0300 Message-Id: <1432305354-5968-6-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 omap_gpio_irq_startup() can be called at time when: - corresponding GPIO has been requested already and in this case it has to be configured as input already. If not - return with -EINVAL and do not try to re-configure it as it could be unsafe. - corresponding GPIO is free: reconfigure GPIO as input. In addition, call omap_enable_gpio_module directly as all needed checks are already present inside it. Signed-off-by: Grygorii Strashko --- drivers/gpio/gpio-omap.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 2fbd569..1c226f1 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -790,11 +790,23 @@ static unsigned int omap_gpio_irq_startup(struct irq_data *d) pm_runtime_get_sync(bank->dev); spin_lock_irqsave(&bank->lock, flags); - omap_gpio_init_irq(bank, offset); + + if (!LINE_USED(bank->mod_usage, offset)) + omap_set_gpio_direction(bank, offset, 1); + else if (!omap_gpio_is_input(bank, offset)) + goto err; + omap_enable_gpio_module(bank, offset); + bank->irq_usage |= BIT(offset); + spin_unlock_irqrestore(&bank->lock, flags); omap_gpio_unmask_irq(d); return 0; +err: + spin_unlock_irqrestore(&bank->lock, flags); + if (!BANK_USED(bank)) + pm_runtime_put(bank->dev); + return -EINVAL; } static void omap_gpio_irq_shutdown(struct irq_data *d)