linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Vaittinen, Matti" <Matti.Vaittinen@fi.rohmeurope.com>
To: "pavel@ucw.cz" <pavel@ucw.cz>
Cc: "linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>,
	"dmurphy@ti.com" <dmurphy@ti.com>,
	"linux-rtc@vger.kernel.org" <linux-rtc@vger.kernel.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"alexandre.belloni@bootlin.com" <alexandre.belloni@bootlin.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"mturquette@baylibre.com" <mturquette@baylibre.com>,
	"mazziesaccount@gmail.com" <mazziesaccount@gmail.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"jacek.anaszewski@gmail.com" <jacek.anaszewski@gmail.com>,
	"a.zummo@towertech.it" <a.zummo@towertech.it>,
	"linus.walleij@linaro.org" <linus.walleij@linaro.org>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"bgolaszewski@baylibre.com" <bgolaszewski@baylibre.com>,
	"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
	"lee.jones@linaro.org" <lee.jones@linaro.org>,
	"sboyd@kernel.org" <sboyd@kernel.org>,
	"broonie@kernel.org" <broonie@kernel.org>
Subject: Re: [PATCH v7 11/12] leds: Add common LED binding parsing support to LED class/core
Date: Fri, 27 Dec 2019 11:29:34 +0000	[thread overview]
Message-ID: <bab4fd0447c16c4c30a07ead192efdba3e2f1e85.camel@fi.rohmeurope.com> (raw)
In-Reply-To: <20191221193758.GJ32732@amd>


On Sat, 2019-12-21 at 20:37 +0100, Pavel Machek wrote:
> Hi!
> 
> > Qucik grep for 'for_each' or 'linux,default-trigger' or
> 
> quick.
> 
> > If init_data is goven but no starting point for node lookup - then
> 
> is given.
> 
> > (parent) device's own DT node is used. If no led-compatible is
> > given,
> > then of_match is searched for. If neither led-compatible not
> > of_match
> 
> nor of_match.
> 
> > is given then device's own node or passed starting point are used
> > as
> > such.
> > 
> > Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> > ---
> > 
> > No changes since v6
> > 
> >  drivers/leds/led-class.c |  99 +++++++++++++--
> >  drivers/leds/led-core.c  | 258 ++++++++++++++++++++++++++++++++---
> > ----
> >  include/linux/leds.h     |  94 ++++++++++++--
> >  3 files changed, 385 insertions(+), 66 deletions(-)
> 
> Quite a lot of code added here. Can I trust you that we we'll delete
> 320 lines by converting driver or two?
> 
> > +static void led_add_props(struct led_classdev *ld, struct
> > led_properties *props)
> > +{
> > +	if (props->default_trigger)
> > +		ld->default_trigger = props->default_trigger;
> > +	/*
> > +	 * According to binding docs the LED is by-default turned OFF
> > unless
> > +	 * default_state is used to indicate it should be ON or that
> > state
> > +	 * should be kept as is
> > +	 */
> > +	if (props->default_state) {
> > +		ld->brightness = LED_OFF;
> > +		if (!strcmp(props->default_state, "on"))
> > +			ld->brightness = LED_FULL;
> 
> Max brightness is not always == LED_FULL these days.

Hmm. That sounds like having LED_FULL is pretty pointless then, right?
I mean, if LED_FULL may not be LED_FULL, why we have LED_FULL then?
Anyways, I don't know what would be better value for the default state
"on"? I am willing to rework the patch here but I need some guidance.
Other option is to use the LED_FULL here and leave drivers using
something else to use own property parsing - or convert them to use
LED_FULL too. (Sorry, I don't know these drivers or why they don't use
LED_FULL so I can't say if this makes sense or not). Can you give me a
nudge as how to improve this?

> 
> > @@ -322,6 +398,10 @@ int led_classdev_register_ext(struct device
> > *parent,
> >  			led_cdev->name);
> >  
> >  	return 0;
> > +err_out:
> > +	if (led_cdev->fwnode_owned)
> > +		fwnode_handle_put(fw);
> > +	return ret;
> >  }
> 
> led_cdev->fwnode_owned = false here?

Hmm. Thanks. I didn't think that the cdev is not freed here and could
be re-used. So yes. I think we could set the led_cdev->fwnode_owned to
false here. I'll fix this. Good catch :)

> 
> 
> > +/**
> > + * led_find_fwnode - find fwnode for led
> > + * @parent	LED controller device
> > + * @init_data	led init data with match information
> > + *
> > + * Scans the firmware nodes and returns node matching the given
> > init_data.
> > + * NOTE: Function increases refcount for found node. Caller must
> > decrease
> > + * refcount using fwnode_handle_put when finished with node.
> > + */
> > +struct fwnode_handle *led_find_fwnode(struct device *parent,
> > +				      struct led_init_data *init_data)
> > +{
> > +	struct fwnode_handle *fw;
> > +
> > +	/*
> > +	 * This should never be called W/O init data. We could always
> > return
> 
> without

Right.

> > +	 * For now we do only do node look-up for drivers which
> > populate
> > +	 * the new match properties. We could and perhaps should do
> > +	 * fw = dev_fwnode(parent); if given fwnode is NULL. But in
> > order to
> > +	 * not break existing setups we keep the old behaviour and just
> > directly
> 
> not to break.

Indeed, thanks!

> > +	/*
> > +	 * Simple things are pretty. I think simplest is to use DT
> > node-name
> > +	 * for matching the node with LED - same way regulators use the
> > node
> > +	 * name to match with desc.
> > +	 *
> > +	 * This may not work with existing LED DT entries if the node
> > name has
> > +	 * been freely selectible. In order to this to work the binding
> > doc
> 
> selectable?

Ah. Again the same problem I had with regulator voltage ranges support.
English is hard. Google told me that selectible or selectable are not
really good words to use - hence I ended up using 'pickable' ranges. I
think this could also be "if the node name has been freely pickable.
I'll switch to that.

> > +	/**
> > +	 * Please note, logic changed - if invalid property is found we
> > bail
> > +	 * early out without parsing the rest of the properties.
> > Originally
> > +	 * this was the case only for 'label' property. I don't know
> > the
> > +	 * rationale behind original logic allowing invalid properties
> > to be
> > +	 * given. If there is a reason then we should reconsider this.
> > +	 * Intuitively it feels correct to just yell and quit if we hit
> > value we
> > +	 * don't understand - but intuition may be wrong at times :)
> > +	 */
> 
> Is this supposed to be linuxdoc?

definitely not. Thanks! I'll remove the extra *

> 
> > +/**
> > + * led_find_fwnode - find fwnode matching given LED init data
> > + * @parent: LED controller device this LED is driven by
> > + * @init_data: the LED class device initialization data
> > + *
> > + * Find the fw node matching given LED init data.
> > + * NOTE: Function increases refcount for found node. Caller must
> > decrease
> > + * refcount using fwnode_handle_put when finished with node.
> > + *
> > + * Returns: node handle or NULL if matching fw node was not found
> > + */
> > +struct fwnode_handle *led_find_fwnode(struct device *parent,
> > +				      struct led_init_data *init_data);
> > +
> 
> If function _gets_ the node and increments its usage count, is it
> normally called "get"?

Ok, thanks for the guidance. I didn't know that. I'll change this to
led_get_fwnode :)

Thanks a bunch!

Br,
	Matti Vaittinen


  parent reply	other threads:[~2019-12-27 11:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-19  9:44 [PATCH v7 00/12] Support ROHM BD71828 PMIC Matti Vaittinen
2019-12-19  9:44 ` [PATCH v7 01/12] dt-bindings: leds: ROHM BD71282 PMIC LED driver Matti Vaittinen
2019-12-21 19:26   ` Pavel Machek
2019-12-19  9:46 ` [PATCH v7 02/12] dt-bindings: mfd: Document ROHM BD71828 bindings Matti Vaittinen
2019-12-19  9:58   ` Vaittinen, Matti
2019-12-19 14:36     ` Lee Jones
2019-12-20  6:33       ` Vaittinen, Matti
2019-12-20 10:55         ` Lee Jones
2019-12-19  9:46 ` [PATCH v7 03/12] mfd: rohm PMICs - use platform_device_id to match MFD sub-devices Matti Vaittinen
2019-12-19  9:49 ` [PATCH v7 04/12] mfd: bd718x7: Add compatible for BD71850 Matti Vaittinen
2019-12-19  9:50 ` [PATCH v7 05/12] mfd: bd71828: Support ROHM BD71828 PMIC - core Matti Vaittinen
2019-12-19  9:51 ` [PATCH v7 06/12] mfd: input: bd71828: Add power-key support Matti Vaittinen
2019-12-19  9:52 ` [PATCH v7 07/12] clk: bd718x7: Support ROHM BD71828 clk block Matti Vaittinen
2019-12-24  6:54   ` Stephen Boyd
2019-12-19  9:52 ` [PATCH v7 08/12] regulator: bd718x7: Split driver to common and bd718x7 specific parts Matti Vaittinen
2019-12-19  9:53 ` [PATCH v7 09/12] rtc: bd70528: add BD71828 support Matti Vaittinen
2019-12-19  9:53 ` [PATCH v7 10/12] gpio: bd71828: Initial support for ROHM BD71828 PMIC GPIOs Matti Vaittinen
2019-12-19  9:54 ` [PATCH v7 11/12] leds: Add common LED binding parsing support to LED class/core Matti Vaittinen
2019-12-21 19:37   ` Pavel Machek
2019-12-23 10:35     ` Vaittinen, Matti
2019-12-27 11:29     ` Vaittinen, Matti [this message]
2019-12-27 11:51     ` Vaittinen, Matti
2019-12-30  7:36     ` Vaittinen, Matti
2019-12-19  9:54 ` [PATCH v7 12/12] led: bd71828: Support LED outputs on ROHM BD71828 PMIC Matti Vaittinen
2019-12-21 19:48   ` Pavel Machek
2019-12-27  9:43     ` Vaittinen, Matti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bab4fd0447c16c4c30a07ead192efdba3e2f1e85.camel@fi.rohmeurope.com \
    --to=matti.vaittinen@fi.rohmeurope.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmurphy@ti.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mazziesaccount@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).