cnvst_pwm_state.duty_cycle = cnvst_pwm_state.period;
ret = pwm_apply_might_sleep(st->cnvst_pwm, &cnvst_pwm_state);
- /* sleep 2 µS to let finish the current pulse */
- fsleep(2);
return ret;
}
cnvst_pwm_state.duty_cycle = 0;
ret = pwm_apply_might_sleep(st->cnvst_pwm, &cnvst_pwm_state);
- /* sleep 2 µS to let finish the current pulse */
- fsleep(2);
return ret;
}
error_ret:
iio_trigger_notify_done(indio_dev->trig);
/* The rising edge of the CONVST signal starts a new conversion. */
- if (st->gpio_convst) {
- gpiod_set_value(st->gpio_convst, 1);
- } else {
- ret = ad7606_pwm_set_high(st);
- if (ret < 0)
- dev_err(st->dev, "Could not set PWM to high.");
- }
+ gpiod_set_value(st->gpio_convst, 1);
return IRQ_HANDLED;
}
{
struct ad7606_state *st = iio_priv(indio_dev);
- if (st->gpio_convst)
- gpiod_set_value(st->gpio_convst, 1);
- else
- return ad7606_pwm_set_high(st);
+ gpiod_set_value(st->gpio_convst, 1);
return 0;
}
{
struct ad7606_state *st = iio_priv(indio_dev);
- if (st->gpio_convst)
- gpiod_set_value(st->gpio_convst, 0);
- else
- return ad7606_pwm_set_low(st);
+ gpiod_set_value(st->gpio_convst, 0);
return 0;
}
indio_dev->setup_ops = &ad7606_backend_buffer_ops;
} else {
+
+ /* Reserve the PWM use only for backend (force gpio_convst definition) */
+ if (!st->gpio_convst)
+ return dev_err_probe(dev, -EINVAL,
+ "No backend, connect convst to a GPIO");
+
init_completion(&st->completion);
st->trig = devm_iio_trigger_alloc(dev, "%s-dev%d",
indio_dev->name,