Messages in this thread | | | From | "Kim, Milo" <> | Subject | RE: [PATCH] leds-lm3530: replace pwm platform functions with generic pwm functions | Date | Mon, 20 Aug 2012 06:13:20 +0000 |
| |
> * 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
| |