From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C210C3A5A8 for ; Wed, 4 Sep 2019 12:34:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E166821670 for ; Wed, 4 Sep 2019 12:34:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730052AbfIDMeY (ORCPT ); Wed, 4 Sep 2019 08:34:24 -0400 Received: from mga11.intel.com ([192.55.52.93]:4080 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728878AbfIDMeY (ORCPT ); Wed, 4 Sep 2019 08:34:24 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 05:34:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,467,1559545200"; d="scan'208";a="194716420" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga002.jf.intel.com with ESMTP; 04 Sep 2019 05:34:21 -0700 Received: from andy by smile with local (Exim 4.92.1) (envelope-from ) id 1i5UUO-0000nP-7s; Wed, 04 Sep 2019 15:34:20 +0300 Date: Wed, 4 Sep 2019 15:34:20 +0300 From: Andy Shevchenko To: Dmitry Torokhov Cc: Linus Walleij , Andreas Kemnade , linux-gpio@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] gpiolib: of: fix fallback quirks handling Message-ID: <20190904123420.GK2680@smile.fi.intel.com> References: <20190903231856.GA165165@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190903231856.GA165165@dtor-ws> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 03, 2019 at 04:18:56PM -0700, Dmitry Torokhov wrote: > We should only try to execute fallback quirks handling when previous > call returned -ENOENT, and not when we did not get -EPROBE_DEFER. > The other errors should be treated as hard errors: we did find the GPIO > description, but for some reason we failed to handle it properly. > > The fallbacks should only be executed when previous handlers returned > -ENOENT, which means the mapping/description was not found. > > Also let's remove the explicit deferral handling when iterating through > GPIO suffixes: it is not needed anymore as we will not be calling > fallbacks for anything but -ENOENT. > I would rather leave extra parenthesis and comments untouched, nevertheless, FWIW, Reviewed-by: Andy Shevchenko > Fixes: df451f83e1fc ("gpio: of: fix Freescale SPI CS quirk handling") > Signed-off-by: Dmitry Torokhov > --- > drivers/gpio/gpiolib-of.c | 27 +++++++++------------------ > 1 file changed, 9 insertions(+), 18 deletions(-) > > diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c > index b034abe59f28..b45b39c48a34 100644 > --- a/drivers/gpio/gpiolib-of.c > +++ b/drivers/gpio/gpiolib-of.c > @@ -457,36 +457,27 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, > > desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx, > &of_flags); > - /* > - * -EPROBE_DEFER in our case means that we found a > - * valid GPIO property, but no controller has been > - * registered so far. > - * > - * This means we don't need to look any further for > - * alternate name conventions, and we should really > - * preserve the return code for our user to be able to > - * retry probing later. > - */ > - if (IS_ERR(desc) && PTR_ERR(desc) == -EPROBE_DEFER) > - return desc; > > - if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) > + if (!IS_ERR(desc) || PTR_ERR(desc) != -ENOENT) > break; > } > > - /* Special handling for SPI GPIOs if used */ > - if (IS_ERR(desc)) > + if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) { > + /* Special handling for SPI GPIOs if used */ > desc = of_find_spi_gpio(dev, con_id, &of_flags); > - if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) { > + } > + > + if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) { > /* This quirk looks up flags and all */ > desc = of_find_spi_cs_gpio(dev, con_id, idx, flags); > if (!IS_ERR(desc)) > return desc; > } > > - /* Special handling for regulator GPIOs if used */ > - if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) > + if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) { > + /* Special handling for regulator GPIOs if used */ > desc = of_find_regulator_gpio(dev, con_id, &of_flags); > + } > > if (IS_ERR(desc)) > return desc; > -- > 2.23.0.187.g17f5b7556c-goog > > > -- > Dmitry -- With Best Regards, Andy Shevchenko