mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
pwm: sysfs: Add PWM capture support
Allow a user to read PWM capture results from sysfs. To start a capture and read the result, simply read the file: $ cat $PWMCHIP/capture The output format is "<period> <duty cycle>". Signed-off-by: Lee Jones <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
This commit is contained in:
parent
3a3d1a4e32
commit
1a366fe915
2 changed files with 26 additions and 0 deletions
|
|
@ -208,16 +208,33 @@ static ssize_t polarity_store(struct device *child,
|
|||
return ret ? : size;
|
||||
}
|
||||
|
||||
static ssize_t capture_show(struct device *child,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct pwm_device *pwm = child_to_pwm_device(child);
|
||||
struct pwm_capture result;
|
||||
int ret;
|
||||
|
||||
ret = pwm_capture(pwm, &result, jiffies_to_msecs(HZ));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "%u %u\n", result.period, result.duty_cycle);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_RW(period);
|
||||
static DEVICE_ATTR_RW(duty_cycle);
|
||||
static DEVICE_ATTR_RW(enable);
|
||||
static DEVICE_ATTR_RW(polarity);
|
||||
static DEVICE_ATTR_RO(capture);
|
||||
|
||||
static struct attribute *pwm_attrs[] = {
|
||||
&dev_attr_period.attr,
|
||||
&dev_attr_duty_cycle.attr,
|
||||
&dev_attr_enable.attr,
|
||||
&dev_attr_polarity.attr,
|
||||
&dev_attr_capture.attr,
|
||||
NULL
|
||||
};
|
||||
ATTRIBUTE_GROUPS(pwm);
|
||||
|
|
|
|||
Loading…
Reference in a new issue