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 A59D1C433F5 for ; Fri, 22 Apr 2022 13:34:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6FF3083D5E; Fri, 22 Apr 2022 15:34: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=1650634452; bh=j4Rp6klxASOcbV6hyfDD04K2YjB7YZKGFHfFs7Qkur0=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=GaFz0k3i4HtqKRv6UzkaCZpljR7j6Ku/QeTUUFgGoXt30Wkbf3z7uJzKvFupttvxa WzVi0hZaAwZ9YeY9OFuw1AlwgiQC8oagoJ5VOUQs8f7eGj8Q7XUJm4A3LDfAt+8jK4 /7ezUO8ttMBX9uMyJNmiqDmx8sgrzRPDSBhxWVTECdNf9PVT2q+iau8leKHmX1nWFa jHZgKP5sn29XqB5XKdVUFS1s5Kbl/e4u90GY2zwDcCrQE7UuEUb6V0+gdpMwH6w0h8 oDlwZZUH+ta2ocsezIvKqvj2ZzAtWgsao3TIz+ZC6ojk/Im3Ct40+5KUOeHo9drjOK EbhSsEGAyFjFg== Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.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 CDC7083CF7; Fri, 22 Apr 2022 15:34:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650634450; bh=j4Rp6klxASOcbV6hyfDD04K2YjB7YZKGFHfFs7Qkur0=; h=From:To:Cc:Subject:Date:From; b=K1HYu0+2yqBt0kgcMA3nWylylk6xkrUacKVzO60uoEgwnJdMHZmUVHirJ5Sd4o6VZ 2qx3QnjxgjAp66tCiQQhQt3bMrZmojJ9MmP3XnwpL3qnlHE1vJrznu3d6uK5lzFQhn Z4hwu5JIFdl8RHzvwzzRts7qUpU3i1a2xsjgWdeLmgDe0bQtijNgF0+or4ha9I2rGI D2aTdSylD4MBARx2wQODerW/6Af/fP93UDYh4N8m8+4oOJoOAZQrrV8gRYSJoWuE9j hcEnYDlBfe874YM37nFISiL9IXqk0wBAoEvr7GruY/kL42Absyn4+O0XCktFEGc4Z9 sozWqPlUMR92w== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Patrice Chotard , Patrick Delaunay , Sean Anderson , Simon Glass , Steven Lawrance Subject: [PATCH] led: gpio: Use NOP uclass driver for top-level node Date: Fri, 22 Apr 2022 15:34:00 +0200 Message-Id: <20220422133400.146649-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.5 at phobos.denx.de X-Virus-Status: Clean The top level DT node of gpio-leds is not a LED itself, bind NOP uclass driver to it, and bind different LED uclass driver to its subnodes which represent the actual LEDs. This simplifies the probe() implementation and fixes the bogus top-level not-an-LED in 'led list' command output: ``` => led list led Error -121 <--- This is removed/fixed by this patch green:user0 off ``` Signed-off-by: Marek Vasut Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Sean Anderson Cc: Simon Glass Cc: Steven Lawrance --- drivers/led/led_gpio.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c index 23156907593..fbed151b5d9 100644 --- a/drivers/led/led_gpio.c +++ b/drivers/led/led_gpio.c @@ -58,17 +58,8 @@ static enum led_state_t gpio_led_get_state(struct udevice *dev) static int led_gpio_probe(struct udevice *dev) { struct led_gpio_priv *priv = dev_get_priv(dev); - int ret; - - /* Ignore the top-level LED node */ - if (device_is_compatible(dev, "gpio-leds")) - return 0; - - ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT); - if (ret) - return ret; - return 0; + return gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT); } static int led_gpio_remove(struct udevice *dev) @@ -109,18 +100,23 @@ static const struct led_ops gpio_led_ops = { .get_state = gpio_led_get_state, }; -static const struct udevice_id led_gpio_ids[] = { - { .compatible = "gpio-leds" }, - { } -}; - U_BOOT_DRIVER(led_gpio) = { .name = "gpio_led", .id = UCLASS_LED, - .of_match = led_gpio_ids, .ops = &gpio_led_ops, .priv_auto = sizeof(struct led_gpio_priv), - .bind = led_gpio_bind, .probe = led_gpio_probe, .remove = led_gpio_remove, }; + +static const struct udevice_id led_gpio_ids[] = { + { .compatible = "gpio-leds" }, + { } +}; + +U_BOOT_DRIVER(led_gpio_wrap) = { + .name = "gpio_led_wrap", + .id = UCLASS_NOP, + .of_match = led_gpio_ids, + .bind = led_gpio_bind, +}; -- 2.35.1