lkml.org 
[lkml]   [2012]   [Aug]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] leds-lm3530: replace pwm platform functions with generic pwm functions
Date
> * Rather than having to do the #ifdef here, I think it would be better
> if
> the PWM subsystem provided stub functions for pwm_request, pwm_config,
> pwm_enable, pwm_disable and pwm_free that do nothing, so you can in
> effect
> let the compiler optimize away the above code.

Thanks a lot for catching this!

This is really what I'm hesitating to use #ifdef.
Do you mean making PWM exported functions in pwm.h with CONFIG_PWM condition as below?

#ifdef CONFIG_PWM
...
int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns);
...
#else
...
static inline int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
{
return 0;
}
...
#endif


> * I don't understand why you need the "if (rvdata->pwm) return 0;" case.
> It's normally better to do the initialization exactly once from the
> probe() function. You might want to return -EPROBE_DEFER if the pwm
> source is not yet available though.

This device has 3 control mode. - register access, sensor input and PWM input.
One of modes can be selected on-the-fly.
So that's why I add code which returning 0 when PWM device exists.
Whenever mode change occurs from/to 'PWM input', pwm_request() and pwm_free() should be called.


Best Regards,
Milo





\
 
 \ /
  Last update: 2012-08-20 09:01    [W:0.057 / U:0.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site