Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59DEDECAAD3 for ; Mon, 19 Sep 2022 19:45:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0B32784C1C; Mon, 19 Sep 2022 21:45:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1663616712; bh=25jxgB1bEs7Bpy8vJsvm/ciDUIX0ampv6BYbG8YgUM8=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=kBUpwMZj2Vpc0t9+kxkHnhl4H/WidYmcoxVGERVCfxLkA/nZzfd1sUnUQlIoIHkwV EN298mxv+IQ/8aZq25i/u2BgX2O4ytl5++shqMHRY32AqsrJ67I57nBMIhtCj6f584 ybPBJPZzj5Zff6qXx5e6vK6AqWcrbgMR87jvYUZusThjo7L6AXjm/QdsDeuZP5UoTq hmV33+ADEaCYzLT39mut+qh6MPzibegaQY1I7N7xrBHi/kYwerINtuBvhaIy/l9LCW 8BVpRqbnpC9F46+z91D1/7EBLh9ukUghEXcETCW5+j1AszMfrs04cFe2Yqg24m941R sT5/gjUjAT2Sg== Received: from tr.lan (ip-86-49-12-201.bb.vodafone.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 0067284B5D; Mon, 19 Sep 2022 21:45:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1663616711; bh=25jxgB1bEs7Bpy8vJsvm/ciDUIX0ampv6BYbG8YgUM8=; h=From:To:Cc:Subject:Date:From; b=TFWxm3IBiS4V5GfNydtXLkQqnRFKKoV0Tu+nIGYcQC6kjO03eZFa2IwkRj2NkIERE HNt0cb5Ccg0Q9nYLLB2fI7LXKDEdRf9jHGK4O3Sbjgaw8FACJV+NjBxIV0iWw9TMnX 0FU4Oh+juqOyzGK6cV3oQcDI18mmPgkVp6fAFBMYMl8T6T0BogPBPhALldRruk525H XS6bdoyFNDQ6V0NsjQvhPfrt3g0aAtwFwJteag4GjHZlJdJ9nOoPY8EpSYvAYHqdQu yZobqrpl+YLoxBcw2fEonjetgV0754gNTVLINy1iDnC63fF/6U94IAszC0yUUagQ7F amQaeNfNPbMsg== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Samuel Holland , Simon Glass Subject: [PATCH] gpio: Get rid of gpio_hog_probe_all() Date: Mon, 19 Sep 2022 21:45:02 +0200 Message-Id: <20220919194502.106252-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The gpio_hog_probe_all() functionality can be perfectly well replaced by DM_FLAG_PROBE_AFTER_BIND DM flag, which would trigger .probe() callback of each GPIO hog driver instance after .bind() and thus configure the hogged GPIO accordingly. Signed-off-by: Marek Vasut --- Cc: Heinrich Schuchardt Cc: Samuel Holland Cc: Simon Glass --- common/board_r.c | 3 --- common/spl/spl.c | 3 --- doc/README.gpio | 6 ++---- drivers/gpio/gpio-uclass.c | 25 ++----------------------- include/asm-generic/gpio.h | 8 -------- 5 files changed, 4 insertions(+), 41 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index 56eb60fa275..c556aa5a073 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -750,9 +750,6 @@ static init_fnc_t init_sequence_r[] = { initr_status_led, #endif /* PPC has a udelay(20) here dating from 2002. Why? */ -#if defined(CONFIG_GPIO_HOG) - gpio_hog_probe_all, -#endif #ifdef CONFIG_BOARD_LATE_INIT board_late_init, #endif diff --git a/common/spl/spl.c b/common/spl/spl.c index 29e0898f03d..683e0dfc526 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -770,9 +770,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } } - if (CONFIG_IS_ENABLED(GPIO_HOG)) - gpio_hog_probe_all(); - #if CONFIG_IS_ENABLED(BOARD_INIT) spl_board_init(); #endif diff --git a/doc/README.gpio b/doc/README.gpio index 548ff37b8cc..d253f654fad 100644 --- a/doc/README.gpio +++ b/doc/README.gpio @@ -2,10 +2,8 @@ GPIO hog (CONFIG_GPIO_HOG) -------- -All the GPIO hog are initialized in gpio_hog_probe_all() function called in -board_r.c just before board_late_init() but you can also acces directly to -the gpio with gpio_hog_lookup_name(). - +All the GPIO hog are initialized using DM_FLAG_PROBE_AFTER_BIND DM flag +after bind(). Example, for the device tree: diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 0ed32b72170..32df0448a7b 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -315,34 +315,11 @@ static int gpio_hog_probe(struct udevice *dev) return 0; } -int gpio_hog_probe_all(void) -{ - struct udevice *dev; - int ret; - int retval = 0; - - for (uclass_first_device(UCLASS_NOP, &dev); - dev; - uclass_find_next_device(&dev)) { - if (dev->driver == DM_DRIVER_GET(gpio_hog)) { - ret = device_probe(dev); - if (ret) { - printf("Failed to probe device %s err: %d\n", - dev->name, ret); - retval = ret; - } - } - } - - return retval; -} - int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc) { struct udevice *dev; *desc = NULL; - gpio_hog_probe_all(); if (!uclass_get_device_by_name(UCLASS_NOP, name, &dev)) { struct gpio_hog_priv *priv = dev_get_priv(dev); @@ -1503,6 +1480,8 @@ static int gpio_post_bind(struct udevice *dev) &child); if (ret) return ret; + + dev_or_flags(child, DM_FLAG_PROBE_AFTER_BIND); } } } diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 81f63f06f15..e56d3777ae5 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -460,14 +460,6 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc); */ int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc); -/** - * gpio_hog_probe_all() - probe all gpio devices with - * gpio-hog subnodes. - * - * @return: Returns return value from device_probe() - */ -int gpio_hog_probe_all(void); - /** * gpio_lookup_name - Look up a GPIO name and return its details * -- 2.35.1