Re: Re: [PATCH v3 1/4] leds: leds-pwm: Convert to use devm_get_pwm

From: Thierry Reding
Date: Tue Dec 11 2012 - 03:36:37 EST


On Tue, Dec 11, 2012 at 09:29:21AM +0100, Peter Ujfalusi wrote:
> On Tuesday 11 December 2012 08:03:07 Thierry Reding wrote:
> > On Mon, Dec 10, 2012 at 11:00:34AM +0100, Peter Ujfalusi wrote:
> > > Update the driver to use the new API for requesting pwm so we can take
> > > advantage of the pwm_lookup table to find the correct pwm to be used for
> > > the LED functionality.
> > > If the devm_get_pwm fails we fall back to legacy mode to try to get the
> > > pwm.
> > >
> > > Signed-off-by: Peter Ujfalusi <peter.ujfalusi@xxxxxx>
> > > ---
> > >
> > > drivers/leds/leds-pwm.c | 19 ++++++-------------
> > > include/linux/leds_pwm.h | 2 +-
> > > 2 files changed, 7 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> > > index 2157524..351257c 100644
> > > --- a/drivers/leds/leds-pwm.c
> > > +++ b/drivers/leds/leds-pwm.c
> > > @@ -67,12 +67,11 @@ static int led_pwm_probe(struct platform_device *pdev)
> > >
> > > cur_led = &pdata->leds[i];
> > > led_dat = &leds_data[i];
> > >
> > > - led_dat->pwm = pwm_request(cur_led->pwm_id,
> > > - cur_led->name);
> > > + led_dat->pwm = devm_pwm_get(&pdev->dev, cur_led->name);
> > >
> > > if (IS_ERR(led_dat->pwm)) {
> > >
> > > ret = PTR_ERR(led_dat->pwm);
> > >
> > > - dev_err(&pdev->dev, "unable to request PWM %d\n",
> > > - cur_led->pwm_id);
> > > + dev_err(&pdev->dev, "unable to request PWM for %s\n",
> > > + cur_led->name);
> > >
> > > goto err;
> > >
> > > }
> >
> > The commit message says that legacy mode is used as fallback if
> > devm_get_pwm() (that should really be devm_pwm_get() btw) fails but I
> > don't see where pwm_request() is called.
>
> Oh, true. The fallback has been removed based on earlier comment from Bryan
> Wu. I will correct the commit message.

I'm not so sure that's a good idea. After all there may still be users
who rely on the legacy behaviour.

Thierry

Attachment: pgp00000.pgp
Description: PGP signature