net/mlx4_en: Fix panic on xmit while port is down
[deliverable/linux.git] / drivers / pwm / core.c
index ed337a8c34ab4bb231814136fe5cd9628962eff1..0dbd29e287dbbf495a28fa4b142fb407773b2f0d 100644 (file)
@@ -525,6 +525,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
This page took 0.038848 seconds and 5 git commands to generate.