[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190715151935.4ci23aqw4liz56fg@holly.lan>
Date: Mon, 15 Jul 2019 16:19:35 +0100
From: Daniel Thompson <daniel.thompson@...aro.org>
To: Jean-Jacques Hiblot <jjhiblot@...com>
Cc: Dan Murphy <dmurphy@...com>, jacek.anaszewski@...il.com,
pavel@....cz, robh+dt@...nel.org, mark.rutland@....com,
linux-leds@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org
Subject: Re: [PATCH 1/2] leds: Add control of the voltage/current regulator
to the LED core
On Mon, Jul 15, 2019 at 11:47:08AM +0200, Jean-Jacques Hiblot wrote:
> > > > > + if (IS_ERR(led_cdev->regulator)) {
> > > > > + dev_err(led_cdev->dev, "Cannot get the power supply for %s\n",
> > > > > + led_cdev->name);
> > > > > + device_unregister(led_cdev->dev);
> > > > > + mutex_unlock(&led_cdev->led_access);
> > > > > + return PTR_ERR(led_cdev->regulator);
> > > > This is listed as optional in the DT doc. This appears to be required.
> > > The regulator core will provide a dummy regulator if none is given in the
> > > device tree. I would rather have an error in that case, but that is not how
> > > it works.
> > If you actively wanted to get -ENODEV back when there is no regulator
> > then you can use devm_regulator_get_optional() for that.
> >
> > However perhaps be careful what you wish for. If you use get_optional()
> > then you will have to sprinkle NULL or IS_ERR() checks everywhere. I'd
> > favour using the current approach!
>
> Thanks for the info. I think I'll use the get_optionnal(). That will add a
> bit of complexity, but it will avoid deferring some work in
> led_set_brightness_nopm() when it is not needed.
Makes sense, I didn't notice that it allows you to avoid deferred work.
Daniel.
Powered by blists - more mailing lists