Added hrtimer trigger v2
Hi,
This patch is the revision 2 of hrtimer iio trigger.
- Used int as trigger id instead of long;
- Fix Kconfig;
- checked maximium value of frequency (u16);
Thanks,
Denis
PATCH 1/1 iio:trigger: Added iio-hrtimer-trigger
This patch adds high resolution timer trigger support for iio framework.
--- drivers/iio/trigger/Kconfig | 9 + drivers/iio/trigger/Makefile | 1 + drivers/iio/trigger/iio-trig-hrtimer.c | 284 ++++++++++++++++++++++++++++++++ 3 files changed, 294 insertions(+) create mode 100644 drivers/iio/trigger/iio-trig-hrtimer.c
drivers/iio/trigger/Kconfig +9 -0
@@ -25,4 +25,13 @@ config IIO_SYSFS_TRIGGER To compile this driver as a module, choose M here: the module will be called iio-trig-sysfs. +config IIO_HRTIMER_TRIGGER + tristate "HRTIMER trigger" + help + Provides support for using HRTIMER entries as IIO triggers. + If unsure, say N (but it's safe to say "Y"). + + To compile this driver as a module, choose M here: the + module will be called iio-trig-hrtimer. + endmenu
drivers/iio/trigger/Makefile +1 -0
@@ -5,3 +5,4 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_IIO_INTERRUPT_TRIGGER) += iio-trig-interrupt.o obj-$(CONFIG_IIO_SYSFS_TRIGGER) += iio-trig-sysfs.o +obj-$(CONFIG_IIO_HRTIMER_TRIGGER) += iio-trig-hrtimer.o
drivers/iio/trigger/iio-trig-hrtimer.c new file +284 -0
284 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH] iio:trigger: Added iio-hrtimer-trigger
Quoted 2 lines · Denis CIOCCA
This patch adds high resolution timer trigger support for iio framework.
I think the driver is mostly fine (a couple of minor comments inline). But maybe we should give some more though how we want to deal with the creation and deletion of software triggers like this one. Half of the code in this drivers is boiler plate code copied from the sysfs trigger and is dealing with creating and deleting the triggers.
[...]
drivers/iio/trigger/Makefile line 8
Quoted 9 lines
drivers/iio/trigger/Makefile +1
-0@@ -5,3 +5,4 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_IIO_INTERRUPT_TRIGGER) += iio-trig-interrupt.o obj-$(CONFIG_IIO_SYSFS_TRIGGER) += iio-trig-sysfs.o +obj-$(CONFIG_IIO_HRTIMER_TRIGGER) += iio-trig-hrtimer.o
Alphabetical order, please.
[...]
Quoted 4 lines
drivers/iio/trigger/Makefile +4
-0+static ssize_t iio_hrtimer_trigger_set_freq_value(struct device *dev, + struct device_attribute *attr, const char *buf, size_t len) +{ + int ret;
drivers/iio/trigger/Makefile
Quoted 10 lines
drivers/iio/trigger/Makefile +10
-0+ u16 frequency; + struct iio_trigger *trig = to_iio_trigger(dev); + struct iio_hrtimer_trigger_data *trig_data = + iio_trigger_get_drvdata(trig); + + ret = kstrtou16(buf, 10, &frequency); + if (ret < 0) + return ret; + + if (frequency > MAX_UNSIGNED_INT16)
Will never be true with frequency being a u16.
Quoted 10 lines
drivers/iio/trigger/Makefile +10
-0+ return -EINVAL; + + trig_data->freq = frequency; + + if (frequency) + trig_data->period = + ktime_set(0, NSEC_PER_SEC / trig_data->freq); + + return len; +}
[...]
drivers/iio/trigger/Makefile
Quoted 9 lines
drivers/iio/trigger/Makefile +9
-0+ +enum hrtimer_restart iio_hrtimer_trigger_func(struct hrtimer *timer) +{ + struct iio_hrtimer_trigger_data *trig_data; + + trig_data = container_of(timer, struct iio_hrtimer_trigger_data, timer); + + hrtimer_forward_now(timer, trig_data->period); + iio_trigger_poll(trig_data->trig, 0);
iio_trigger_poll(trig_data->trig, iio_get_time_ns());
Quoted 3 lines
drivers/iio/trigger/Makefile +3
-0+ + return HRTIMER_RESTART; +}
[...]