From patchwork Mon Dec 7 22:39:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 7792401 Return-Path: X-Original-To: patchwork-linux-spi@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 DB807BEEE5 for ; Mon, 7 Dec 2015 22:39:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1AE4A2038A for ; Mon, 7 Dec 2015 22:39:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F98420497 for ; Mon, 7 Dec 2015 22:39:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933395AbbLGWj2 (ORCPT ); Mon, 7 Dec 2015 17:39:28 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:36229 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933210AbbLGWjW (ORCPT ); Mon, 7 Dec 2015 17:39:22 -0500 Received: by wmww144 with SMTP id w144so159616261wmw.1; Mon, 07 Dec 2015 14:39:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fOpAM7d1YEBdVbppChOlViIU1Ku4aJXRz23+XL6ggv0=; b=HWf6W4R4/dzwefvmv9qYusX/EmWYVf8Z4oRj0e0unCZ89ixS+1i2sC1p23dpUCkT4e zwmY8e4P5QNxAqSp6i2goh2foypMV0W+lU82NkISv8JOGbV3fiDeSLvbqgh5bolUugLo pyDKiCeRuBQ5MyudTBL54yuFZ4ZuxMzxL1bf3kojLMI+J/T+AKZcOmmn8R3Lp5HJ3NoR gK0QFVu6mBMUAUucbB+gly87jrJElnXvB8tDpPbYBGjyS3bW3eOaQufZ4YM3AvTL+/dT Ewa3mDRX7JBW4wRmrus+HbkUWZFX+aZBFtMexk289rvUv1+COXWg4AZfjLD4pjsJLq+w /lRg== X-Received: by 10.28.33.136 with SMTP id h130mr828201wmh.93.1449527961346; Mon, 07 Dec 2015 14:39:21 -0800 (PST) Received: from localhost.localdomain (ax113-6-78-236-204-66.fbx.proxad.net. [78.236.204.66]) by smtp.gmail.com with ESMTPSA id w67sm650187wmw.17.2015.12.07.14.39.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Dec 2015 14:39:20 -0800 (PST) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: rjw@rjwysocki.net, lenb@kernel.org, linus.walleij@linaro.org, gnurou@gmail.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, broonie@kernel.org Cc: linux-spi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, Christophe Ricard Subject: [PATCH v4 2/3] ACPI / gpio: Add irq_type when a gpio is used as an interrupt Date: Mon, 7 Dec 2015 23:39:11 +0100 Message-Id: <1449527952-8399-3-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449527952-8399-1-git-send-email-christophe-h.ricard@st.com> References: <1449527952-8399-1-git-send-email-christophe-h.ricard@st.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 When a gpio is used as an interrupt in acpi, the irq_type was not available for device driver. Make it available in acpi_find_gpio with a new acpi_gpio_info field (irq_type) and setthe irq_type if necessary in acpi_dev_gpio_irq_get. Signed-off-by: Christophe Ricard --- drivers/gpio/gpiolib-acpi.c | 22 ++++++++++++++++++---- drivers/gpio/gpiolib.h | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index bbcac3a..4b893c8 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -416,9 +416,12 @@ static int acpi_find_gpio(struct acpi_resource *ares, void *data) * GpioIo is used then the only way to set the flag is * to use _DSD "gpios" property. */ - if (lookup->info.gpioint) + if (lookup->info.gpioint) { lookup->info.active_low = agpio->polarity == ACPI_ACTIVE_LOW; + lookup->info.irq_type = acpi_get_irq_type(agpio->triggering, + agpio->polarity); + } } return 1; @@ -529,7 +532,7 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev, */ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) { - int idx, i; + int idx, i, irq; for (i = 0, idx = 0; idx <= index; i++) { struct acpi_gpio_info info; @@ -538,8 +541,19 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); if (IS_ERR(desc)) break; - if (info.gpioint && idx++ == index) - return gpiod_to_irq(desc); + if (info.gpioint && idx++ == index) { + irq = gpiod_to_irq(desc); + if (irq < 0) { + dev_err(&adev->dev, + "Failed to translate GPIO to IRQ\n"); + return irq; + } + /* Set type if specified and different than the current one */ + if (info.irq_type != IRQ_TYPE_NONE && + info.irq_type != irq_get_trigger_type(irq)) + irq_set_irq_type(irq, info.irq_type); + return irq; + } } return -ENOENT; } diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 78e634d..624fbc4 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -27,6 +27,7 @@ struct acpi_device; struct acpi_gpio_info { bool gpioint; bool active_low; + int irq_type; }; /* gpio suffixes used for ACPI and device tree lookup */