mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
pwm: Add PWM capture support
Supply a PWM capture callback op in order to pass back information obtained by running analysis on a PWM signal. This would normally (at least during testing) be called from the sysfs routines with a view to printing out PWM capture data which has been encoded into a string. Signed-off-by: Lee Jones <[email protected]> [[email protected]: make capture data unsigned int for symmetry] Signed-off-by: Thierry Reding <[email protected]>
This commit is contained in:
parent
1a695a905c
commit
3a3d1a4e32
2 changed files with 51 additions and 0 deletions
|
|
@ -524,6 +524,33 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(pwm_apply_state);
|
||||
|
||||
/**
|
||||
* pwm_capture() - capture and report a PWM signal
|
||||
* @pwm: PWM device
|
||||
* @result: structure to fill with capture result
|
||||
* @timeout: time to wait, in milliseconds, before giving up on capture
|
||||
*
|
||||
* Returns: 0 on success or a negative error code on failure.
|
||||
*/
|
||||
int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
|
||||
unsigned long timeout)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (!pwm || !pwm->chip->ops)
|
||||
return -EINVAL;
|
||||
|
||||
if (!pwm->chip->ops->capture)
|
||||
return -ENOSYS;
|
||||
|
||||
mutex_lock(&pwm_lock);
|
||||
err = pwm->chip->ops->capture(pwm->chip, pwm, result, timeout);
|
||||
mutex_unlock(&pwm_lock);
|
||||
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pwm_capture);
|
||||
|
||||
/**
|
||||
* pwm_adjust_config() - adjust the current PWM config to the PWM arguments
|
||||
* @pwm: PWM device
|
||||
|
|
|
|||
Loading…
Reference in a new issue