From patchwork Tue Feb 13 06:08:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 872617 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zgXM81PRpz9sP9 for ; Tue, 13 Feb 2018 17:14:59 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751437AbeBMGO6 (ORCPT ); Tue, 13 Feb 2018 01:14:58 -0500 Received: from mirror2.csie.ntu.edu.tw ([140.112.30.76]:44966 "EHLO wens.csie.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751354AbeBMGO6 (ORCPT ); Tue, 13 Feb 2018 01:14:58 -0500 X-Greylist: delayed 397 seconds by postgrey-1.27 at vger.kernel.org; Tue, 13 Feb 2018 01:14:58 EST Received: by wens.csie.org (Postfix, from userid 1000) id D57145FD7D; Tue, 13 Feb 2018 14:08:17 +0800 (CST) From: Chen-Yu Tsai To: Linus Walleij Cc: Chen-Yu Tsai , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpio: Handle deferred probing in of_find_gpio() properly Date: Tue, 13 Feb 2018 14:08:14 +0800 Message-Id: <20180213060814.18165-1-wens@csie.org> X-Mailer: git-send-email 2.16.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org of_get_named_gpiod_flags() used directly in of_find_gpio() or indirectly through of_find_spi_gpio() or of_find_regulator_gpio() can return -EPROBE_DEFER. This gets overwritten by the subsequent of_find_*_gpio() calls. This patch fixes this by trying of_find_spi_gpio() or of_find_regulator_gpio() only if deferred probing was not requested by the previous of_get_named_gpiod_flags() call. Fixes: 6a537d48461d ("gpio: of: Support regulator nonstandard GPIO properties") Fixes: c85823390215 ("gpio: of: Support SPI nonstandard GPIO properties") Signed-off-by: Chen-Yu Tsai --- Hi Linus, Fresh fix for 4.16. I'm probably not the only one finding devices using gpios not working anymore. In my case it was pwrseq-mmc-simple probing before pinctrl/gpio, not being able to get the gpio, and then just consider the gpio missing instead of deferring. This in turn caused my SDIO WiFi to not work. --- drivers/gpio/gpiolib-of.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 564bb7a31da4..edad176a210a 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -246,11 +246,11 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, } /* Special handling for SPI GPIOs if used */ - if (IS_ERR(desc)) + if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) desc = of_find_spi_gpio(dev, con_id, &of_flags); /* Special handling for regulator GPIOs if used */ - if (IS_ERR(desc)) + if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) desc = of_find_regulator_gpio(dev, con_id, &of_flags); if (IS_ERR(desc))