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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 989FFC433FE for ; Mon, 7 Nov 2022 00:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229909AbiKGAbv (ORCPT ); Sun, 6 Nov 2022 19:31:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbiKGAbu (ORCPT ); Sun, 6 Nov 2022 19:31:50 -0500 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B50BBAC for ; Sun, 6 Nov 2022 16:31:47 -0800 (PST) Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (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 049F4806F4; Mon, 7 Nov 2022 01:31:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1667781105; bh=XuhhJEgYkSS8HL3DD9bt8liOemKBwG/SmKUmsT7arbE=; h=From:To:Cc:Subject:Date:From; b=FAtVrIra3stTQpsQokfrUBiffTpyc4LbpvZqdsXgiqUyNQje/QXJMIEkEU+uTZD/g jjMycsk8HjQiVi+w/oyjhWAWD0fKVN/0ryBZBoKOFWee7G1w6N+MGNM2YVgD/dCSy+ 5Tahvf1pkWAN9G08Sdz8VNPVZulE2f1JdxZKEhh93yycH5ViL+0mGNQsNAJZ/R7muC 1RzDleW5Xc1F6sjCwe8cH0Xau6g876e3lfPT6BHmysWeeD2sC3GrjPmR94GN4C+Jn7 7WAdhpLSNKxX+5AWlc5JF3BFT2MGD5EX7iDAkGa7pLaMQ9cS5Y0tG3Wmd5jCvSJnP8 +3vDY26kxBRLQ== From: Marek Vasut To: linux-leds@vger.kernel.org Cc: Marek Vasut , Christoph Niedermaier , Pavel Machek Subject: [PATCH] leds: gpio: Configure per-LED pin control Date: Mon, 7 Nov 2022 01:31:33 +0100 Message-Id: <20221107003133.377704-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Each gpio-leds DT node DT subnode can have a pinctrl property assigned to it, parse the DT subnode pinctrl properties and configure each pin accordingly. Signed-off-by: Marek Vasut --- Cc: Christoph Niedermaier Cc: Pavel Machek To: linux-leds@vger.kernel.org --- drivers/leds/leds-gpio.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 092eb59a7d325..01ca88876f008 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -77,6 +78,7 @@ static int create_gpio_led(const struct gpio_led *template, struct fwnode_handle *fwnode, gpio_blink_set_t blink_set) { struct led_init_data init_data = {}; + struct pinctrl *pinctrl; int ret, state; led_dat->cdev.default_trigger = template->default_trigger; @@ -119,6 +121,22 @@ static int create_gpio_led(const struct gpio_led *template, &init_data); } + if (ret) + return ret; + + pinctrl = devm_pinctrl_get_select_default(led_dat->cdev.dev); + if (IS_ERR(pinctrl)) { + ret = PTR_ERR(pinctrl); + if (ret != -ENODEV) { + dev_warn(led_dat->cdev.dev, + "Failed to select %pOF pinctrl: %d\n", + to_of_node(fwnode), ret); + } else { + /* pinctrl-%d not present, not an error */ + ret = 0; + } + } + return ret; } -- 2.35.1