Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1058400imm; Thu, 5 Jul 2018 13:58:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeSHPf+mCmTC5F/X8RCWO017u7ypTjsuLpVhdjIBZcLj3gq7KcjOBOdiCztoDSVrQGYHx/T X-Received: by 2002:a63:4c21:: with SMTP id z33-v6mr6948723pga.383.1530824291985; Thu, 05 Jul 2018 13:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530824291; cv=none; d=google.com; s=arc-20160816; b=t7YYfLp67Zr5EMt4smroqTXGLDoUuaO7gG/R7NX9LdBT/ZH6ooRV2RW3aN63DA9+hB K9oG3K5mZxX1pn3XqA33AuCMaT01unAHeKCRXWEghPCg4S3sU3yyRFvIwt+l97eVUHG7 MklYX1wpfOT+xGUO36iljK4Rd5ToA3qgTQOfvBEDXkr+Wqlesajc2y/LemEjUdI3NgmV 2q5zbAfTJrfnPyQ4XmWL4hkIvzMj4lPeNFgY3xG+CnYU7LdphL0XI69NobZwHRU4dPkf P1nS4qixe0oSNGj61c+T7U4IVr2E31utedFl4u/1UbQiB8QWcIxSJFNvZpasu9WzlR05 vgng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=gzMT1cSZbCGff5BKrjRPltQiXPbWPdjiFgo76ko8LCA=; b=o2f5qBpj94HpqirpKbEYiokkWwdby0U+QLRNSvMQXwRVw1r64Pjrij0+i2ygsBKU3p ESm1qKjp0ariLR8ykpKK4aeCbIkz7W0ytEYjGYobyyQNA+26Omq5w66dLv6xNBcHuyOQ GP3r4Gw6y8rREJ3h6rDCFLaRUA3JK1Zem8zuhfLL2nnDgrrrYhB321+lo7vDJV+3sptJ aK6yW2fTlhPzIQhCJuN1w+nartLncKvcXJesCbHEdUslAHQA1uyZ42cXQWPb4XwRJfif Mjbnbjt9v9DjfTPnwKnk/UiHsqoCbq/FqUWHmVk/EsfCguMPVjqbXLHwlhUk5uQhCheT Q0xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uuso1QmT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65-v6si6776405pfd.73.2018.07.05.13.57.57; Thu, 05 Jul 2018 13:58:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@gmail.com header.s=20161025 header.b=uuso1QmT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754632AbeGEU4X (ORCPT + 99 others); Thu, 5 Jul 2018 16:56:23 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:44344 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754478AbeGEU4K (ORCPT ); Thu, 5 Jul 2018 16:56:10 -0400 Received: by mail-lj1-f196.google.com with SMTP id q127-v6so7017282ljq.11; Thu, 05 Jul 2018 13:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gzMT1cSZbCGff5BKrjRPltQiXPbWPdjiFgo76ko8LCA=; b=uuso1QmTAf8f/4aUfOYK5o0UtNVyYVm56whpO1vg+SK3AmJZ0ZJRFbyjWofcSkRA1n ES2JVHXBiIUFWoiS1oz3RH0ocLNqtB8b5xpv9p7WQfEHz1wIspNlG7WHqM1cc5NLlm6c B76cPXu2rm2l9S+/phlN9sO6xoQXhPolrqvzt5VYcAIfBdeWgMknDVg6/qs2FdCT0Y8m ImV3CD1f3rZ4Ch/ESfHUar5uKZiqdZA5Vilej5Zm4io7dwRhdFdetLdORj4pfhAymLj+ e7Bjvbb3SDR2BR0cnOVvsLg0d/fjwdpvCs9kiQ78tK0wXNZ8UNKIVnRxbOsjlnVng1U9 jpmA== 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:mime-version:content-transfer-encoding; bh=gzMT1cSZbCGff5BKrjRPltQiXPbWPdjiFgo76ko8LCA=; b=ltn8Mlg1Pk9u39D74Xd6LuNe+S/xs94nc1b3TApvV3P3gm2+Ro+dvBNRzI0rPeaVmG aTpYkzj90RavYZwIUJBHYsSPhlXxJTrTi6kRdYsWuyw3CX/d45whayCpIXFTPOqSFTY5 9rRD0r2ikwFwkPBnTOSWejDgx7p/0nC8r5sZvw8PCAQsNpfIEFc4nBvH31N2t/rHIdlL yZ2DBGI1RfAsnVhKcM3ZRI/I/8rzs7IPg+kHgre2TH1i086apep+z1qRcQl58O86WJbK Ym/k1GjxYDnTIDD6m4sW564d4FrIhvh0jmRm5ivEFTSsY8FHw8yrM+Yft2jjaOl1yTAG AeJQ== X-Gm-Message-State: APt69E1KMgicXjoaClhKfPIrurd0cs0iqCZ5F1HxjygHcK+qLZjYG7nk JK+pr12YIwP/zkdIbWaudw0hV2Y5blM= X-Received: by 2002:a2e:118f:: with SMTP id 15-v6mr4887852ljr.38.1530824168822; Thu, 05 Jul 2018 13:56:08 -0700 (PDT) Received: from z50.localnet ([31.0.83.69]) by smtp.gmail.com with ESMTPSA id x21-v6sm1648744lfe.70.2018.07.05.13.56.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 13:56:07 -0700 (PDT) From: Janusz Krzysztofik To: Lee Jones Cc: Boris Brezillon , Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Wolfram Sang , Uwe =?ISO-8859-1?Q?Kleine=2DK=F6nig?= , Fabio Estevam , Phil Reid , Lucas Stach , Clemens Gruber , Peter Rosin , patches@opensource.cirrus.com, linux-i2c@vger.kernel.org Subject: Re: [PATCH] gpiolib: Defer on non-DT find_chip_by_name() failure Date: Thu, 05 Jul 2018 22:56:40 +0200 Message-ID: <1579112.qQSMXVQn9s@z50> In-Reply-To: <20180705055037.GI496@dell> References: <20180703172635.32508-1-jmkrzyszt@gmail.com> <7058252.SGNltMTCCa@z50> <20180705055037.GI496@dell> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday, July 5, 2018 7:50:37 AM CEST Lee Jones wrote: > On Wed, 04 Jul 2018, Janusz Krzysztofik wrote: > > On Tuesday, July 3, 2018 7:31:41 PM CEST Boris Brezillon wrote: > > > Hi Janusz, > > > > > > On Tue, 3 Jul 2018 19:26:35 +0200 > > > > > > Janusz Krzysztofik wrote: > > > > Avoid replication of error code conversion in non-DT GPIO consumers' > > > > code by returning -EPROBE_DEFER from gpiod_find() in case a chip > > > > identified by its label in a registered lookup table is not ready. > > > > > > > > See https://lkml.org/lkml/2018/5/30/176 for example case. > > > > > > > > Signed-off-by: Janusz Krzysztofik > > > > --- > > > > If accepted, please add > > > > > > > > Suggested-by: Boris Brezillon > > > > > > > > if Boris doesn't mind. > > > > > > > > Thanks, > > > > Janusz > > > > > > > > drivers/gpio/gpiolib.c | 13 ++++++++++--- > > > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > > > > index e11a3bb03820..15dc77c80328 100644 > > > > --- a/drivers/gpio/gpiolib.c > > > > +++ b/drivers/gpio/gpiolib.c > > > > @@ -3639,9 +3639,16 @@ static struct gpio_desc *gpiod_find(struct > > > > device > > > > *dev, const char *con_id,> > > > > > > > > chip = find_chip_by_name(p->chip_label); > > > > > > > > if (!chip) { > > > > > > > > - dev_err(dev, "cannot find GPIO chip %s\n", > > > > - p->chip_label); > > > > - return ERR_PTR(-ENODEV); > > > > + /* > > > > + * As the lookup table indicates a chip with > > > > + * p->chip_label should exist, assume it may > > > > + * still appear latar and let the interested > > > > > > > ^ later > > > > > > > > + * consumer be probed again or let the Deferred > > > > + * Probe infrastructure handle the error. > > > > + */ > > > > + dev_warn(dev, "cannot find GPIO chip %s, deferring\n", > > > > + p->chip_label); > > > > + return ERR_PTR(-EPROBE_DEFER); > > > > > > > > } > > > > > > > > if (chip->ngpio <= p->chip_hwnum) { > > > > > > Looks good otherwise. Let's hope we're not breaking implementations > > > testing for -ENODEV... > > > > I've reviewed them all and found two which I think may be affected: > > - drivers/mfd/arizona-core.c, > > - drivers/i2c/busses/i2c-imx.c. > > As far as I can understand the code, both depend on error != -EPROBE_DEFER > > in order to continue in degraded mode. I'm adding their maintainers to > > the loop. > From a quick glance, the -EPROBE_DEFER handing in Arizona Core appears > to be correct. Would you mind explaining what your concerns are in > more detail please? Hi That's more about handling -ENODEV rather than -EPROBE_DEFER. Before the change, if GPIO chip supposed to provide "reset" pin was not ready during arizona_dev_init(), devm_gpiod_get() returned -ENODEV and device was initialized in degraded mode, i.e., with no control over the "reset" pin. After the change, gpiod_get() will return -EPROBE_DEFER in such case and arizona_dev_init() won't succeed in case the GPIO chip doesn't appear later for some reason. Thanks, Januszz