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: 48893 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A341F21411 for ; Fri, 22 May 2015 14:37:03 +0000 (UTC) Received: by wgwl7 with SMTP id l7sf5841546wgw.0 for ; Fri, 22 May 2015 07:37:03 -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=JXS/0pS91KqCdXREgCV1FCWSuRD4MdZ6IvtQDGUM3DQ=; b=QDDH92H13nsngJpR4KAxcGhQ5QNtfz2WaVb3VzMhCA4//CDaLxzM4CAHaHnxMXrwsF afIGEmDyiqasJuq72l4Kvvz5EAAiiYxKF3L6yJ13hfEmxCimDIvoLtgAbqVHsOw1ckC4 QiBEjl5YXVo3mNWGtHd1M8RjGqft6U7WsAaWGKSY9tYV8fDW2zFcVVtHGmgw+U0+Vstz fG7Tmzt99LgQm9HpqUsKm11Rlr5VfcJlzwHcFdHf3W6J4mf5UcSKTUJ/NkPqRmOeo49G Zh7Ij28SDg1/tmwdOX1036Q+mGZbSARQztCp9x/EYC+7Ga6b0MPioLfsutzpinNdP+Kk uhfQ== X-Gm-Message-State: ALoCoQnIkCyQyhBialm4giCex1WqqHoI69CJtPhs5QF1w2hABPemnxOZTEbPikEkrZ5iLdIA7tD8 X-Received: by 10.112.200.166 with SMTP id jt6mr8070029lbc.17.1432305423009; Fri, 22 May 2015 07:37:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.40 with SMTP id q8ls446521lag.67.gmail; Fri, 22 May 2015 07:37:02 -0700 (PDT) X-Received: by 10.112.125.231 with SMTP id mt7mr6567924lbb.113.1432305422850; Fri, 22 May 2015 07:37:02 -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 q16si1535669laa.25.2015.05.22.07.37.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 May 2015 07:37:02 -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 lami4 with SMTP id i4so14067790lam.0 for ; Fri, 22 May 2015 07:37:02 -0700 (PDT) X-Received: by 10.152.27.105 with SMTP id s9mr6738039lag.86.1432305422718; Fri, 22 May 2015 07:37:02 -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 hn6csp1454082lbb; Fri, 22 May 2015 07:37:01 -0700 (PDT) X-Received: by 10.70.24.130 with SMTP id u2mr16248862pdf.147.1432305408450; Fri, 22 May 2015 07:36:48 -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.47; Fri, 22 May 2015 07:36:48 -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 S1757280AbbEVOgW (ORCPT + 1 other); Fri, 22 May 2015 10:36:22 -0400 Received: from mail-la0-f45.google.com ([209.85.215.45]:35513 "EHLO mail-la0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757254AbbEVOgM (ORCPT ); Fri, 22 May 2015 10:36:12 -0400 Received: by labbd9 with SMTP id bd9so14015045lab.2 for ; Fri, 22 May 2015 07:36:10 -0700 (PDT) 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-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 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)