From patchwork Wed Jun 22 14:33:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 639222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rZRtM6jPQz9t12 for ; Thu, 23 Jun 2016 00:34:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=NGo4l0a3; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752175AbcFVOdm (ORCPT ); Wed, 22 Jun 2016 10:33:42 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:33609 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752600AbcFVOdl (ORCPT ); Wed, 22 Jun 2016 10:33:41 -0400 Received: by mail-lf0-f50.google.com with SMTP id f6so75389329lfg.0 for ; Wed, 22 Jun 2016 07:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Q30ZiI7vPKOBqQXJh3Taud5KuAIh9DhQY+wbg7+q7UY=; b=NGo4l0a3pykBYWjOBbLqP3EG8am2DlVhMhhG4wOJccXdqYO+JPkhG8rjxBUfLPb5+1 db/ulqCqmbzYUSpyzXCee7jcyEQwq2ZQ+TCdFxZh/8P//7MmGBpBYNVrRZSEA8T5Be2Y MRZp69OPFG6O/djwTsQ3XDUAgTJpUTcZR58MQ= 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; bh=Q30ZiI7vPKOBqQXJh3Taud5KuAIh9DhQY+wbg7+q7UY=; b=io8xyU1Wy50vdz3WUzDWSqH3r0ZZWApPl+tFJEKJvZ3U+6Z/mFZS/4On5+QwHDQIE8 W+5F0nrC74Yj6NqoXkFFdR73UJVHWAyM2Wpe7voxVMA6tOmSjfjeUmaMAuJSVmvytY7c cF9fWIzykCFveHuLPa2Y09/m5GbZKN2Tx5X0gzujDbuXos163njMwVZzAO37b+2/X9GZ +buS7N0fdfoOkCAaT2oXrz89v7ulbaB86W8CsTogGpEfmLWytqxF/E9FhRA/0n/kOQlg FEqsGTO4DoFavyp0ElJ7ELL7C9kMcLAcPWKybQ96OQMi4an1fgq8TbohXQjVkfZ/6rmQ DGsw== X-Gm-Message-State: ALyK8tLRzFPKot+daOtCTftTLZKjzkMBme2ZbRs66/vqDelwaL+jvUPh4jiWtgoNwLeplO+X X-Received: by 10.25.166.2 with SMTP id p2mr9759418lfe.48.1466606018916; Wed, 22 Jun 2016 07:33:38 -0700 (PDT) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 39sm52299lja.37.2016.06.22.07.33.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 07:33:38 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij Subject: [PATCH] gpio: convince line to become input in irq helper Date: Wed, 22 Jun 2016 16:33:35 +0200 Message-Id: <1466606015-16326-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.11 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The generic IRQ helper library just checks if the IRQ line is set as input before activating it for interrupts. As we recently started to check things better with .get_dir() it turns out that it's good to try to convince the line to become an input before attempting to lock it as IRQ. Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 58d822d7e8da..b9a6a5c69fbb 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1010,6 +1010,23 @@ static int gpiochip_irq_reqres(struct irq_data *d) if (!try_module_get(chip->gpiodev->owner)) return -ENODEV; + /* + * If it is possible to switch this GPIO to an input + * this is a good time to do it. + */ + if (chip->direction_input) { + struct gpio_desc *desc; + int ret; + + desc = gpiochip_get_desc(chip, d->hwirq); + if (IS_ERR(desc)) + return PTR_ERR(desc); + + ret = chip->direction_input(chip, d->hwirq); + if (!ret) + clear_bit(FLAG_IS_OUT, &desc->flags); + } + if (gpiochip_lock_as_irq(chip, d->hwirq)) { chip_err(chip, "unable to lock HW IRQ %lu for IRQ\n",