From patchwork Fri Feb 19 10:16:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 8359201 Return-Path: X-Original-To: patchwork-linux-input@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 DC7F4C0553 for ; Fri, 19 Feb 2016 10:16:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBD60203F7 for ; Fri, 19 Feb 2016 10:16:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECC042041B for ; Fri, 19 Feb 2016 10:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992562AbcBSKQ1 (ORCPT ); Fri, 19 Feb 2016 05:16:27 -0500 Received: from laurent.telenet-ops.be ([195.130.137.89]:34363 "EHLO laurent.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2992554AbcBSKQY (ORCPT ); Fri, 19 Feb 2016 05:16:24 -0500 Received: from ayla.of.borg ([84.195.106.123]) by laurent.telenet-ops.be with bizsmtp id LAGN1s00p2fm56U01AGNP2; Fri, 19 Feb 2016 11:16:22 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1aWi6o-0002X7-Ey; Fri, 19 Feb 2016 11:16:22 +0100 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1aWi6p-0001lX-Vz; Fri, 19 Feb 2016 11:16:24 +0100 From: Geert Uytterhoeven To: Dmitry Torokhov , Aaron Lu , Mika Westerberg , "Rafael J. Wysocki" Cc: Vincent Pelletier , Linus Walleij , Alexandre Courbot , linux-input@vger.kernel.org, linux-gpio@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 2/3] input: gpio_keys: Switch from irq_of_parse_and_map() to platform_get_irq() Date: Fri, 19 Feb 2016 11:16:21 +0100 Message-Id: <1455876982-6743-3-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455876982-6743-1-git-send-email-geert+renesas@glider.be> References: <1455876982-6743-1-git-send-email-geert+renesas@glider.be> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Note that irq_of_parse_and_map() returns 0 on failure, while platform_get_irq() returns -ENXIO on failure, so we have to make irq signed, and update all error checks. Signed-off-by: Geert Uytterhoeven --- drivers/input/keyboard/gpio_keys.c | 16 ++++++++-------- include/linux/gpio_keys.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index d2b6c3acd9c32f1d..b6262d94aff19f70 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -30,7 +30,6 @@ #include #include #include -#include #include struct gpio_button_data { @@ -511,7 +510,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, button->debounce_interval; } - if (button->irq) { + if (button->irq >= 0) { bdata->irq = button->irq; } else { irq = gpiod_to_irq(button->gpiod); @@ -531,7 +530,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; } else { - if (!button->irq) { + if (button->irq < 0) { dev_err(dev, "No IRQ specified\n"); return -EINVAL; } @@ -631,8 +630,9 @@ static void gpio_keys_close(struct input_dev *input) * Translate OpenFirmware node properties into platform_data */ static struct gpio_keys_platform_data * -gpio_keys_get_devtree_pdata(struct device *dev) +gpio_keys_get_devtree_pdata(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct device_node *node, *pp; struct gpio_keys_platform_data *pdata; struct gpio_keys_button *button; @@ -681,9 +681,9 @@ gpio_keys_get_devtree_pdata(struct device *dev) button->active_low = flags & OF_GPIO_ACTIVE_LOW; } - button->irq = irq_of_parse_and_map(pp, 0); + button->irq = platform_get_irq(pdev, 0); - if (!gpio_is_valid(button->gpio) && !button->irq) { + if (!gpio_is_valid(button->gpio) && button->irq < 0) { dev_err(dev, "Found button without gpios or irqs\n"); return ERR_PTR(-EINVAL); } @@ -725,7 +725,7 @@ MODULE_DEVICE_TABLE(of, gpio_keys_of_match); #else static inline struct gpio_keys_platform_data * -gpio_keys_get_devtree_pdata(struct device *dev) +gpio_keys_get_devtree_pdata(struct platform_device *pdev) { return ERR_PTR(-ENODEV); } @@ -743,7 +743,7 @@ static int gpio_keys_probe(struct platform_device *pdev) int wakeup = 0; if (!pdata) { - pdata = gpio_keys_get_devtree_pdata(dev); + pdata = gpio_keys_get_devtree_pdata(pdev); if (IS_ERR(pdata)) return PTR_ERR(pdata); } diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h index ee2d8c6f91300db7..0c04d38069535b86 100644 --- a/include/linux/gpio_keys.h +++ b/include/linux/gpio_keys.h @@ -30,7 +30,7 @@ struct gpio_keys_button { int debounce_interval; bool can_disable; int value; - unsigned int irq; + int irq; struct gpio_desc *gpiod; };