Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
[linux-2.6.git] / drivers / staging / iio / iio_simple_dummy.h
blobc9e8702caca41890ce5f9f6e14b91ea07f0a4329
1 /**
2 * Copyright (c) 2011 Jonathan Cameron
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
8 * Join together the various functionality of iio_simple_dummy driver
9 */
11 #include <linux/kernel.h>
13 struct iio_dummy_accel_calibscale;
15 /**
16 * struct iio_dummy_state - device instance specific state.
17 * @dac_val: cache for dac value
18 * @single_ended_adc_val: cache for single ended adc value
19 * @differential_adc_val: cache for differential adc value
20 * @accel_val: cache for acceleration value
21 * @accel_calibbias: cache for acceleration calibbias
22 * @accel_calibscale: cache for acceleration calibscale
23 * @lock: lock to ensure state is consistent
24 * @event_irq: irq number for event line (faked)
25 * @event_val: cache for event theshold value
26 * @event_en: cache of whether event is enabled
28 struct iio_dummy_state {
29 int dac_val;
30 int single_ended_adc_val;
31 int differential_adc_val[2];
32 int accel_val;
33 int accel_calibbias;
34 const struct iio_dummy_accel_calibscale *accel_calibscale;
35 struct mutex lock;
36 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
37 int event_irq;
38 int event_val;
39 bool event_en;
40 #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
43 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
45 struct iio_dev;
47 int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev,
48 u64 event_code);
50 int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,
51 u64 event_code,
52 int state);
54 int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev,
55 u64 event_code,
56 int *val);
58 int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,
59 u64 event_code,
60 int val);
62 int iio_simple_dummy_events_register(struct iio_dev *indio_dev);
63 int iio_simple_dummy_events_unregister(struct iio_dev *indio_dev);
65 #else /* Stubs for when events are disabled at compile time */
67 static inline int
68 iio_simple_dummy_events_register(struct iio_dev *indio_dev)
70 return 0;
73 static inline int
74 iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)
76 return 0;
79 #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/
81 /**
82 * enum iio_simple_dummy_scan_elements - scan index enum
83 * @voltage0: the single ended voltage channel
84 * @diffvoltage1m2: first differential channel
85 * @diffvoltage3m4: second differenial channel
86 * @accelx: acceleration channel
88 * Enum provides convenient numbering for the scan index.
90 enum iio_simple_dummy_scan_elements {
91 voltage0,
92 diffvoltage1m2,
93 diffvoltage3m4,
94 accelx,
97 #ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
98 int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev,
99 const struct iio_chan_spec *channels, unsigned int num_channels);
100 void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev);
101 #else
102 static inline int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev,
103 const struct iio_chan_spec *channels, unsigned int num_channels)
105 return 0;
107 static inline
108 void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev)
110 #endif /* CONFIG_IIO_SIMPLE_DUMMY_BUFFER */