Skip to content

Commit 72c034e

Browse files
dlechProject516
authored andcommitted
ev3dev hack: add fixed timer trigger to ADC
We need to poll the ADC every 100ms, so add a hrtimer tirgger when the driver is probed.
1 parent 9774aa4 commit 72c034e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/iio/adc/ti-ads7950.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
#include <linux/iio/buffer.h>
2929
#include <linux/iio/iio.h>
30+
#include <linux/iio/sw_trigger.h>
3031
#include <linux/iio/sysfs.h>
32+
#include <linux/iio/trigger.h>
3133
#include <linux/iio/trigger_consumer.h>
3234
#include <linux/iio/triggered_buffer.h>
3335

@@ -74,6 +76,7 @@ struct ti_ads7950_state {
7476
struct mutex slock;
7577
struct gpio_chip chip;
7678

79+
struct iio_sw_trigger *hrtimer_trigger;
7780
struct regulator *reg;
7881
unsigned int vref_mv;
7982

@@ -630,6 +633,15 @@ static int ti_ads7950_probe(struct spi_device *spi)
630633
goto error_cleanup_ring;
631634
}
632635

636+
/* Hack to create continuous polling mode */
637+
st->hrtimer_trigger = iio_sw_trigger_create("hrtimer", dev_name(&spi->dev));
638+
if (IS_ERR(st->hrtimer_trigger)) {
639+
ret = PTR_ERR(st->hrtimer_trigger);
640+
goto error_iio_device;
641+
}
642+
643+
iio_trigger_set_immutable(indio_dev, st->hrtimer_trigger->trigger);
644+
633645
/* Add GPIO chip */
634646
st->chip.label = dev_name(&st->spi->dev);
635647
st->chip.parent = &st->spi->dev;

0 commit comments

Comments
 (0)