From patchwork Tue Sep 30 15:40:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 5004061 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 850259F2F0 for ; Tue, 30 Sep 2014 15:48:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ACDE8201CE for ; Tue, 30 Sep 2014 15:48:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA2CD2017D for ; Tue, 30 Sep 2014 15:48:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750992AbaI3PsI (ORCPT ); Tue, 30 Sep 2014 11:48:08 -0400 Received: from webbox1416.server-home.net ([77.236.96.61]:54472 "EHLO webbox1416.server-home.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750818AbaI3PsI (ORCPT ); Tue, 30 Sep 2014 11:48:08 -0400 X-Greylist: delayed 482 seconds by postgrey-1.27 at vger.kernel.org; Tue, 30 Sep 2014 11:48:07 EDT Received: from imapserver.systec-electronic.com (unknown [212.185.67.148]) by webbox1416.server-home.net (Postfix) with ESMTPA id 263B827A713; Tue, 30 Sep 2014 16:59:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by imapserver.systec-electronic.com (Postfix) with ESMTP id 770D3DA1123; Tue, 30 Sep 2014 17:40:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at imapserver.systec-electronic.com Received: from imapserver.systec-electronic.com ([127.0.0.1]) by localhost (imapserver.systec-electronic.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AJrXSN7rGCin; Tue, 30 Sep 2014 17:39:58 +0200 (CEST) Received: from ws-stein.systec-electronic.de (unknown [192.168.10.109]) by imapserver.systec-electronic.com (Postfix) with ESMTP id BB388DA0AD2; Tue, 30 Sep 2014 17:39:58 +0200 (CEST) From: Alexander Stein To: Dmitry Torokhov Cc: Alexander Stein , linux-input@vger.kernel.org Subject: [RFC 1/1] Input: gpio_keys - add device tree support for interrupt only keys Date: Tue, 30 Sep 2014 17:40:47 +0200 Message-Id: <1412091647-1562-1-git-send-email-alexander.stein@systec-electronic.com> X-Mailer: git-send-email 1.8.5.5 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.6 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 This features already exists for board config setups. Add support for device tree based systems. Signed-off-by: Alexander Stein --- I'm aware thatthe device tree binding description is missing yet. But for now I just want some feedback about that approach. drivers/input/keyboard/gpio_keys.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 8c98e97..7b90e1b 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -29,6 +29,7 @@ #include #include #include +#include #include struct gpio_button_data { @@ -617,28 +618,32 @@ gpio_keys_get_devtree_pdata(struct device *dev) i = 0; for_each_child_of_node(node, pp) { - int gpio; + int gpio = -1; + int irq; enum of_gpio_flags flags; - if (!of_find_property(pp, "gpios", NULL)) { + irq = irq_of_parse_and_map(pp, 0); + + if (of_find_property(pp, "gpios", NULL)) { + gpio = of_get_gpio_flags(pp, 0, &flags); + if (gpio < 0) { + error = gpio; + if (error != -EPROBE_DEFER) + dev_err(dev, + "Failed to get gpio flags, error: %d\n", + error); + return ERR_PTR(error); + } + } else if (irq == 0) { pdata->nbuttons--; - dev_warn(dev, "Found button without gpios\n"); + dev_warn(dev, "Found button without gpios or irqs\n"); continue; } - gpio = of_get_gpio_flags(pp, 0, &flags); - if (gpio < 0) { - error = gpio; - if (error != -EPROBE_DEFER) - dev_err(dev, - "Failed to get gpio flags, error: %d\n", - error); - return ERR_PTR(error); - } - button = &pdata->buttons[i++]; button->gpio = gpio; + button->irq = irq; button->active_low = flags & OF_GPIO_ACTIVE_LOW; if (of_property_read_u32(pp, "linux,code", &button->code)) {