summaryrefslogtreecommitdiff
path: root/drivers/pwm/core.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/core.c
parent489babeae6b9386af25fe6dc3bc727a51ff5d962 (diff)
parent1a366fe9153f445e950a7a344932b7419aa83094 (diff)
Merge branch 'for-4.8/capture' into for-next
Diffstat (limited to 'drivers/pwm/core.c')
-rw-r--r--drivers/pwm/core.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index ed337a8c34ab..0dbd29e287db 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -526,6 +526,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
*