Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1417153 > unrolled thread

[PATCH v3 10/20] pwm: sysfs: Add PWM Capture support

Started byLee Jones <lee.jones@linaro.org>
First post2016-06-08 11:30 +0200
Last post2016-06-10 16:40 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v3 10/20] pwm: sysfs: Add PWM Capture support Lee Jones <lee.jones@linaro.org> - 2016-06-08 11:30 +0200
    Re: [PATCH v3 10/20] pwm: sysfs: Add PWM Capture support Thierry Reding <thierry.reding@gmail.com> - 2016-06-10 16:10 +0200
      Re: [PATCH v3 10/20] pwm: sysfs: Add PWM Capture support Lee Jones <lee.jones@linaro.org> - 2016-06-10 16:40 +0200

#1417153 — [PATCH v3 10/20] pwm: sysfs: Add PWM Capture support

FromLee Jones <lee.jones@linaro.org>
Date2016-06-08 11:30 +0200
Subject[PATCH v3 10/20] pwm: sysfs: Add PWM Capture support
Message-ID<rHHYe-6M4-27@gated-at.bofh.it>
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 <lee.jones@linaro.org>
---
 drivers/pwm/sysfs.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
index d985992..901e647 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, "%llu %llu\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);
-- 
2.8.3

[toc] | [next] | [standalone]


#1419452

FromThierry Reding <thierry.reding@gmail.com>
Date2016-06-10 16:10 +0200
Message-ID<rIvih-5yi-13@gated-at.bofh.it>
In reply to#1417153

[Multipart message — attachments visible in raw view] — view raw

On Wed, Jun 08, 2016 at 10:21:25AM +0100, Lee Jones wrote:
> 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>".

The format below is "<period> <duty cycle>".

No need to rev the series for this, I can take patches 8 and 10 as-is
and make those modifications myself.

Thierry

[toc] | [prev] | [next] | [standalone]


#1419479

FromLee Jones <lee.jones@linaro.org>
Date2016-06-10 16:40 +0200
Message-ID<rIvLk-5JV-11@gated-at.bofh.it>
In reply to#1419452
On Fri, 10 Jun 2016, Thierry Reding wrote:

> On Wed, Jun 08, 2016 at 10:21:25AM +0100, Lee Jones wrote:
> > 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>".
> 
> The format below is "<period> <duty cycle>".
> 
> No need to rev the series for this, I can take patches 8 and 10 as-is
> and make those modifications myself.

Ideal, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web