Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp992589pxa; Fri, 28 Aug 2020 00:05:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZOv3hyAvGGjx2pYhtwAqQ3aIrcdIVZoqEYBpG1Jd3yT43nPVuFYv02WmQtHoZ+vsbNrRg X-Received: by 2002:a17:907:72d2:: with SMTP id du18mr375777ejc.359.1598598316524; Fri, 28 Aug 2020 00:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598598316; cv=none; d=google.com; s=arc-20160816; b=IPc16OcMrHKxwSulqCzBSwYx7alJ0XMC/TE2Intgz86tzsCkw6wV4dKuGfcsSWobPx tsjcHTrDQJps/BKYh3FKaJRAla8Zh3gNWynwoXQMxVuJkpQ1Tdc2ahf0veTeHe6Qi+nw qEdXmGlspfFgy0E0xCKUINMwvLWTqp1tNuhzmk6oHSKNd49IEnXqHo3bJrbx8+WsDGkR 8hZ4oJrl9dAPmWKt4tdLocKlpSvDnJ0eTMU12PHJKoZeJSYwbc0h10GDWibu3Xtfhc4H umZE84B3WZDacWewm0GxUg8Y6qf7QiGB70XcCe1C2fsvoLOIFx3TyjWR2Pw5fijUq74w 5sWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:references :in-reply-to:message-id:date:subject:cc:to:from; bh=FUqMdhhSCrxs5og8didqIXbhFIKL2wrQ1+g608cGW+s=; b=UyKkD4fqZXeCsw9XvGqusMah5/pk8TbVIupThM+qt6jaEgYvVm+Q3LL1Uouz5z6XgQ ztF1/qm1s6QKhIaNiiUwKCpp6I8vMrPOlL92yv58OOk7zmM9XgSJmJJHTFM0mZ6I17Of jd3xv/Dhu60FO08EEHcb7dObXYenr02yy9pP16URhR5TomdcOTbb8GwY/ZBCpxgl5YI2 aD7P+4d/Kz/kUeF28YvsIKdDWARRo39sfw6NlCrzxuRUlfUIlFW4Mgw7+FnN3IvfqeCx 9y3Usj71QGvr9MTpGUXrHuM8Gh2lwx2At8eboh8yfMgJrCJhazx8LzhIhQLtcoBiZz6i eoHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w20si13686edi.555.2020.08.28.00.04.53; Fri, 28 Aug 2020 00:05:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726010AbgH1HBG (ORCPT + 99 others); Fri, 28 Aug 2020 03:01:06 -0400 Received: from mail.thorsis.com ([92.198.35.195]:37491 "EHLO mail.thorsis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbgH1HBE (ORCPT ); Fri, 28 Aug 2020 03:01:04 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.thorsis.com (Postfix) with ESMTP id C04F9412D; Fri, 28 Aug 2020 09:00:59 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.thorsis.com Received: from mail.thorsis.com ([127.0.0.1]) by localhost (mail.thorsis.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GemdL7l_63G6; Fri, 28 Aug 2020 09:00:59 +0200 (CEST) Received: by mail.thorsis.com (Postfix, from userid 109) id DCEB335D1; Fri, 28 Aug 2020 09:00:57 +0200 (CEST) X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_RECEIVED, NO_RELAYS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 From: Alexander Dahl To: linux-leds@vger.kernel.org Cc: Jacek Anaszewski , Pavel Machek , Dan Murphy , linux-kernel@vger.kernel.org, Alexander Dahl Subject: Re: [PATCH] leds: pwm: Allow automatic labels for DT based devices Date: Fri, 28 Aug 2020 09:00:52 +0200 Message-ID: <7920560.iacgkFlgr8@ada> In-Reply-To: References: <20200826093737.29008-1-ada@thorsis.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Jacek, Am Donnerstag, 27. August 2020, 23:28:45 CEST schrieb Jacek Anaszewski: > On 8/26/20 11:37 AM, Alexander Dahl wrote: > > From: Alexander Dahl > >=20 > > If LEDs are configured through device tree and the property 'label' is > > omitted, the label is supposed to be generated from the properties > > 'function' and 'color' if present. While this works fine for e.g. the > > 'leds-gpio' driver, it did not for 'leds-pwm'. > >=20 > > The reason is, you get this label naming magic only if you add a LED > > device through 'devm_led_classdev_register_ext()' and pass a pointer to > > the current device tree node. The approach to fix this was adopted from > > the 'leds-gpio' driver. > >=20 > > For the following node from dts the LED appeared as 'led5' in sysfs > > before and as 'red:debug' after this change. > >=20 > > pwm_leds { > > =20 > > compatible =3D "pwm-leds"; > > =20 > > led5 { > > =20 > > function =3D LED_FUNCTION_DEBUG; > > color =3D ; > > pwms =3D <&pwm0 2 10000000 0>; > > max-brightness =3D <127>; > > =20 > > linux,default-trigger =3D "heartbeat"; > > panic-indicator; > > =20 > > }; > > =20 > > }; > >=20 > > Signed-off-by: Alexander Dahl > > --- > >=20 > > Notes: > > v1: based on v5.9-rc2, backport on v5.4.59 also works > > =20 > > drivers/leds/leds-pwm.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > >=20 > > diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c > > index ef7b91bd2064..a27a1d75a3e9 100644 > > --- a/drivers/leds/leds-pwm.c > > +++ b/drivers/leds/leds-pwm.c > > @@ -65,6 +65,7 @@ static int led_pwm_add(struct device *dev, struct > > led_pwm_priv *priv,>=20 > > struct led_pwm *led, struct fwnode_handle *fwnode) > > =20 > > { > > =20 > > struct led_pwm_data *led_data =3D &priv->leds[priv->num_leds]; > >=20 > > + struct led_init_data init_data =3D {}; > >=20 > > int ret; > > =09 > > led_data->active_low =3D led->active_low; > >=20 > > @@ -90,7 +91,13 @@ static int led_pwm_add(struct device *dev, struct > > led_pwm_priv *priv,>=20 > > pwm_init_state(led_data->pwm, &led_data->pwmstate); > >=20 > > - ret =3D devm_led_classdev_register(dev, &led_data->cdev); > > + if (fwnode) { > > + init_data.fwnode =3D fwnode; > > + ret =3D devm_led_classdev_register_ext(dev, &led_data->cdev, > > + &init_data); > > + } else { > > + ret =3D devm_led_classdev_register(dev, &led_data->cdev); > > + } > >=20 > > if (ret) { > > =09 > > dev_err(dev, "failed to register PWM led for %s: %d\n", > > =09 > > led->name, ret); >=20 > This part looks good, but corresponding update of > Documentation/devicetree/bindings/leds/leds-pwm.txt is needed as well. I'm not sure, what needs updating. The properties 'function' and 'color' ar= e=20 already documented in Documentation/devicetree/bindings/leds/common.yaml = =E2=80=A6 the=20 only thing I can think of here is updating the examples? That would be nice= ,=20 as would be updating to yaml, but I don't see the strong relation, yet. > It would be good to switch to yaml by this occassion. Is there some guidance on that in general? Greets Alex