RE: [PATCH] leds-lm3530: replace pwm platform functions withgeneric pwm functions

From: Kim, Milo
Date: Mon Aug 20 2012 - 02:13:25 EST


> * 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



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/