diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-10-14 16:34:14 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-10-17 15:36:30 -0700 |
commit | e6477000fced2c961c26fa42845bd388fdf95e79 (patch) | |
tree | b3705a6ec07cc46e786c5e1087576d4053085f9f /drivers/staging/iio/iio_simple_dummy.h | |
parent | 3a84331db23b4cb4c497ef5aa5f7aea65d936309 (diff) |
staging:iio:dummy Add event support + fake event generator
The event generator is not very pretty but does the job and
allows this driver to look a lot more like a normal driver
than it otherwise would.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/iio_simple_dummy.h')
-rw-r--r-- | drivers/staging/iio/iio_simple_dummy.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/drivers/staging/iio/iio_simple_dummy.h b/drivers/staging/iio/iio_simple_dummy.h new file mode 100644 index 000000000000..998fd1fd356a --- /dev/null +++ b/drivers/staging/iio/iio_simple_dummy.h @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2011 Jonathan Cameron + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * Join together the various functionality of iio_simple_dummy driver + */ + +#include <linux/kernel.h> + +struct iio_dummy_accel_calibscale; + +/** + * struct iio_dummy_state - device instance specific state. + * @dac_val: cache for dac value + * @single_ended_adc_val: cache for single ended adc value + * @differential_adc_val: cache for differential adc value + * @accel_val: cache for acceleration value + * @accel_calibbias: cache for acceleration calibbias + * @accel_calibscale: cache for acceleration calibscale + * @lock: lock to ensure state is consistent + * @event_irq: irq number for event line (faked) + * @event_val: cache for event theshold value + * @event_en: cache of whether event is enabled + */ +struct iio_dummy_state { + int dac_val; + int single_ended_adc_val; + int differential_adc_val[2]; + int accel_val; + int accel_calibbias; + const struct iio_dummy_accel_calibscale *accel_calibscale; + struct mutex lock; +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + int event_irq; + int event_val; + bool event_en; +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ +}; + +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + +struct iio_dev; + +int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev, + u64 event_code); + +int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev, + u64 event_code, + int state); + +int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev, + u64 event_code, + int *val); + +int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev, + u64 event_code, + int val); + +int iio_simple_dummy_events_register(struct iio_dev *indio_dev); +int iio_simple_dummy_events_unregister(struct iio_dev *indio_dev); + +#else /* Stubs for when events are disabled at compile time */ + +static inline int +iio_simple_dummy_events_register(struct iio_dev *indio_dev) +{ + return 0; +}; + +static inline int +iio_simple_dummy_events_unregister(struct iio_dev *indio_dev) +{ + return 0; +}; + +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/ + + |