summaryrefslogtreecommitdiff
path: root/drivers/pwm/sysfs.c
diff options
context:
space:
mode:
authorThierry Reding <thierry.reding@gmail.com>2016-07-25 16:23:39 +0200
committerThierry Reding <thierry.reding@gmail.com>2016-07-25 16:23:39 +0200
commitbd2686122d3b45db1398776921bd47fedfd6d6a5 (patch)
treea4c9e124eefb9da5434e39f628ee732a597d30c5 /drivers/pwm/sysfs.c
parent489babeae6b9386af25fe6dc3bc727a51ff5d962 (diff)
parent1a366fe9153f445e950a7a344932b7419aa83094 (diff)
downloadlinux-bd2686122d3b45db1398776921bd47fedfd6d6a5.tar.gz
linux-bd2686122d3b45db1398776921bd47fedfd6d6a5.tar.xz
Merge branch 'for-4.8/capture' into for-next
Diffstat (limited to 'drivers/pwm/sysfs.c')
-rw-r--r--drivers/pwm/sysfs.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
index 01695d48dd54..18ed725594c3 100644
--- a/drivers/pwm/sysfs.c
+++ b/drivers/pwm/sysfs.c
@@ -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);