From patchwork Thu Sep 6 07:59:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 146069 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp194811ljw; Thu, 6 Sep 2018 00:59:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaeR0Dw8+204fv/LcHeJo9OqIfjG6HRiY1Thh9jvNh7cwYCT1Y2/McdqaTornay6sVxSws+ X-Received: by 2002:a63:4306:: with SMTP id q6-v6mr1527821pga.181.1536220762919; Thu, 06 Sep 2018 00:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536220762; cv=none; d=google.com; s=arc-20160816; b=h/CNlHftV2/J00C6mL1LuVHp7Li2c7wx+amdFRz3Mtedb7rJSkuBY5X8a6sIXBb2pr lwLT3xCftiotcIPEunBrr8grnyRqb0cYFfFBE8Fmj1MwN780nXRhXLeLUOVg3tFJf3xe FfVHt2fU9UEKwTuuYRBZayPrOoeyBKOUynDMNVSzTFfO0EDQVUJ+0Koda+wiRVaWDW+V nJw3w6e6bfeFYrGf3/MsIm7XGxpgbaTE7hmz6rZ6VHiG/I0gW62ycla2a6CPbxACwP65 c3WOsUrpmDbUKHTj0OYcLPrx9uEyIzphoAszkOYrGWgEisZP1vHhATtctAxW0HekL0t8 OnLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=g6txyK8o4x08RKCFZhnsAtEHfb0e8GRkllRjW843LzE=; b=IrbEIgYGQCJidoJy9oAyL6eYCetatFYyAX+zbtEpsI3okk3IqNmaxKXZhIxoSBt9xw fELKLIDJuv2U4dOk65Duby0ROmJWmjyq/ABkfZyMawt33JsBFjWqnZd+z9jTHgc2g7KM ww9Ysk6jwdGUPzE7CaNQ53cYmmnckV7GbtSYxuZU4QDI8xn01svYCvtpzohK2OdDSdWw MdiOuOlQCt4EeSoFBGGwK3u/EDXSPHIeRHmHvavjnKielx7066aR6sNod8xfybo5q21S 5v7CU13ex+7DOpRMsBAxUNH7Dl8PjFUwwSW4khSyiYw0oCwiqIsCOmMOFVex72IDqjiy CoLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hVP9S6Ko; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e125-v6si4343914pgc.424.2018.09.06.00.59.22; Thu, 06 Sep 2018 00:59:22 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hVP9S6Ko; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728109AbeIFMdc (ORCPT + 5 others); Thu, 6 Sep 2018 08:33:32 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:39627 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbeIFMdb (ORCPT ); Thu, 6 Sep 2018 08:33:31 -0400 Received: by mail-lj1-f196.google.com with SMTP id l15-v6so8507711lji.6 for ; Thu, 06 Sep 2018 00:59:19 -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:in-reply-to:references; bh=g6txyK8o4x08RKCFZhnsAtEHfb0e8GRkllRjW843LzE=; b=hVP9S6Ko2zpWExobKJOwU+ctnG8ackVNZhXfYkz/H35rBNTQtaoHKcu6ebRpRuusei y4rCKd4wqrh0akFwfSK8cACDKYVK3zIkCg4pwIPsruiTBlwBcpn2SDgz8qvHWUIhODON TIDKEcCM3MCHgvt3baOouY5u8jQu339ucix/s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=g6txyK8o4x08RKCFZhnsAtEHfb0e8GRkllRjW843LzE=; b=Dg1xFWqk7oHLQ/HQG8LHK2XXNILSOkCzjmkjoz8OfpzXPe8chJ8rf4sZEgw+W8C9eX olFHB0YRrm9IsBoEQ3LBk9qfyDfwwDfmsxQ2r9c6I7MdP0W03csg6iLgiq4TKvZ03uZ3 Q23BXHmLx5DapB+pqN5UpMEVn9V4WPyLJHNkgJ7SsSglQE/sSlx0y4S9sQqJLKH/nr3Q gx+iJk+oxs1uB6Vo9c1Xbae1F25kdAsjTvhJ+DZbNyPaQTwz9dPBrrW/giL3fKFq+ohz d8jEjpLmlGxM1W5UE428kjHGQeIazLXmXnfFwbKs4HSc/nG3DaNHGcOREWavMkdCx6QJ 3YcA== X-Gm-Message-State: APzg51Aa0L+C2PIyxiYCrtRDeR1ENSha8aF2fVdXls6Jb8rwq070wvWl TycYF27x1haIlwM4lrSsOhzeig== X-Received: by 2002:a2e:712:: with SMTP id 18-v6mr1074946ljh.101.1536220758595; Thu, 06 Sep 2018 00:59:18 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id f129-v6sm690869lff.37.2018.09.06.00.59.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 00:59:17 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Andy Shevchenko , "Rafael J . Wysocki" , Sakari Ailus , Linus Walleij Subject: [PATCH 2/3] Input: gpio_keys - always try fwnode first Date: Thu, 6 Sep 2018 09:59:01 +0200 Message-Id: <20180906075902.31240-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180906075902.31240-1-linus.walleij@linaro.org> References: <20180906075902.31240-1-linus.walleij@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This makes the gpio_keys input driver try fwnode first when looking up GPIO descriptors, even if no fwnode was passed. With the changes to the gpiolib, if NULL us passed as fwnode, the gpiolib will attempt to look up the GPIO descriptor from the machine descriptor tables. Cc: Dmitry Torokhov Cc: Andy Shevchenko Cc: Rafael J. Wysocki Cc: Sakari Ailus Signed-off-by: Linus Walleij --- Dmitry: I'm looking for your ACK if you agree with this approach overall so I can apply this with the changes to gpiolib to the GPIO tree. --- drivers/input/keyboard/gpio_keys.c | 47 ++++++++++++++++++------------ 1 file changed, 28 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 492a971b95b5..eef2dcbc9185 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -499,25 +499,34 @@ static int gpio_keys_setup_key(struct platform_device *pdev, bdata->button = button; spin_lock_init(&bdata->lock); - if (child) { - bdata->gpiod = devm_fwnode_get_gpiod_from_child(dev, NULL, - child, - GPIOD_IN, - desc); - if (IS_ERR(bdata->gpiod)) { - error = PTR_ERR(bdata->gpiod); - if (error == -ENOENT) { - /* - * GPIO is optional, we may be dealing with - * purely interrupt-driven setup. - */ - bdata->gpiod = NULL; - } else { - if (error != -EPROBE_DEFER) - dev_err(dev, "failed to get gpio: %d\n", - error); - return error; - } + /* + * We try this first as it will find GPIOs even from board + * files if properly done. + */ + bdata->gpiod = devm_fwnode_get_gpiod_from_child(dev, NULL, + child, + GPIOD_IN, + desc); + /* + * If we have a valid fwnode and this lookup fails, we need + * to give up. Otherwise we try to use the GPIO from the + * platform data. + */ + if (!IS_ERR(bdata->gpiod)) { + /* All is good */ + } else if (child) { + error = PTR_ERR(bdata->gpiod); + if (error == -ENOENT) { + /* + * GPIO is optional, we may be dealing with + * purely interrupt-driven setup. + */ + bdata->gpiod = NULL; + } else { + if (error != -EPROBE_DEFER) + dev_err(dev, "failed to get gpio: %d\n", + error); + return error; } } else if (gpio_is_valid(button->gpio)) { /*