From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4963B3EFD05; Wed, 20 May 2026 15:22:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779290551; cv=none; b=K0KBNQPfd1hOK3Dlg6XCdSfTzTTbqiCDqm2PXUAiHKAjzifUCMY+93CxwqcA4BHWvVnXjufW1E8tvnb2jJTrNKWf0JOuc5q3cEw3NwWlGbSW1fQpiwuXYBSS5H05sOPOkP3Jeyzvs1E/BEcL4MQhZBACYSzPwDbpnh068aTbgdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779290551; c=relaxed/simple; bh=wbGoCOdgwuxVd1xRlPnp+y3A9nbTYscIb98IusY0CeA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=t0jtS4+3emcENJpGoFOjmwsXPFgWfaiV0WrROIp81mDp19YOaqjpiHFFSnT+GpNDbj8huMpLHirW7xH8bef4SLK3mW17VbJPilx+8GkjD06Se4h2oGA+xYhI6THjYppuPquDXUdlYVeWuqW0LrphUrC2sy/4xbQJniZFp1tvA+U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BAi49y3O; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BAi49y3O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C398E1F000E9; Wed, 20 May 2026 15:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779290549; bh=+S/tUNi5/lR2jSPqjA34mWFzaraQw7XTvBIQbGpfR+A=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=BAi49y3OY9UWXYIlmNYgcrWtD4wuluUi25SQOeqHMyhBzc1FEScSiW/aGJZQHtW1o v6NY5mYplc7IemOCHDcoD6UCpBB86Myg+5kr8LmxBzRy9Byha+j3fvbluqYBpaC12D ZoM/sB0lr6RjneJhCqYJjurEQaqQV+BOvQ8SdVL9YCs2gYN1fobtwfDufDhHX0w3CW nMKoetHfJP76WLOh2tuXtvqzhDy4SGZFM1/JDD4rcIYlypIalGFWOxY6/mShOrQP6r 7Jb7U6F/P74MKP47w+0sozTHvrlXyRSSrvQFAtCrzmyu01xIOXluJwOl72aqen5QDU O+V94Nmnb00Yw== Date: Wed, 20 May 2026 16:22:25 +0100 From: Lee Jones To: Alban Bedel Cc: linux-leds@vger.kernel.org, Pavel Machek , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] leds: class: Use firmware nodes for device lookup Message-ID: <20260520152225.GH2767592@google.com> References: <20260513115853.1584230-1-alban.bedel@lht.dlh.de> Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260513115853.1584230-1-alban.bedel@lht.dlh.de> On Wed, 13 May 2026, Alban Bedel wrote: > Replace the OF based lookup with the fwnode equivalent to get support > for ACPI and software nodes. > > Signed-off-by: Alban Bedel > --- > v2: * Keep the doc string > * Update comment to reference the function now used > --- > drivers/leds/led-class.c | 30 ++++++++++++++++-------------- > 1 file changed, 16 insertions(+), 14 deletions(-) > > diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c > index 9e14ae588f78..a17db3d6644f 100644 > --- a/drivers/leds/led-class.c > +++ b/drivers/leds/led-class.c > @@ -249,32 +249,34 @@ static const struct class leds_class = { > }; > > /** > - * of_led_get() - request a LED device via the LED framework > - * @np: device node to get the LED device from > + * fwnode_led_get() - request a LED device via the LED framework > + * @fwnode: firmware node to get the LED device from > * @index: the index of the LED > * @name: the name of the LED used to map it to its function, if present > * > * Returns the LED device parsed from the phandle specified in the "leds" > * property of a device tree node or a negative error-code on failure. > */ > -static struct led_classdev *of_led_get(struct device_node *np, int index, > - const char *name) > +static struct led_classdev *fwnode_led_get(struct fwnode_handle *fwnode, > + int index, const char *name) > { > + struct fwnode_handle *led_node; > struct device *led_dev; > - struct device_node *led_node; > > /* > * For named LEDs, first look up the name in the "led-names" property. > - * If it cannot be found, then of_parse_phandle() will propagate the error. > + * If it cannot be found, then fwnode_find_reference() will propagate > + * the error. > */ > if (name) > - index = of_property_match_string(np, "led-names", name); > - led_node = of_parse_phandle(np, "leds", index); > - if (!led_node) > - return ERR_PTR(-ENOENT); > + index = fwnode_property_match_string(fwnode, "led-names", > + name); > + led_node = fwnode_find_reference(fwnode, "leds", index); What happens if fwnode_property_match_string() returns an error? > + if (IS_ERR(led_node)) > + return ERR_CAST(led_node); > > - led_dev = class_find_device_by_fwnode(&leds_class, of_fwnode_handle(led_node)); > - of_node_put(led_node); > + led_dev = class_find_device_by_fwnode(&leds_class, led_node); > + fwnode_handle_put(led_node); > > return led_module_get(led_dev); > } > @@ -332,7 +334,7 @@ struct led_classdev *__must_check devm_of_led_get(struct device *dev, > if (!dev) > return ERR_PTR(-EINVAL); > > - led = of_led_get(dev->of_node, index, NULL); > + led = fwnode_led_get(dev_fwnode(dev), index, NULL); > if (IS_ERR(led)) > return led; > > @@ -354,7 +356,7 @@ struct led_classdev *led_get(struct device *dev, char *con_id) > const char *provider = NULL; > struct device *led_dev; > > - led_cdev = of_led_get(dev->of_node, -1, con_id); > + led_cdev = fwnode_led_get(dev_fwnode(dev), -1, con_id); > if (!IS_ERR(led_cdev) || PTR_ERR(led_cdev) != -ENOENT) > return led_cdev; > > -- > 2.39.5 > -- Lee Jones