aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/iio
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/iio')
-rw-r--r--include/linux/iio/adc/ad_sigma_delta.h173
-rw-r--r--include/linux/iio/buffer.h6
-rw-r--r--include/linux/iio/consumer.h44
-rw-r--r--include/linux/iio/iio.h65
-rw-r--r--include/linux/iio/kfifo_buf.h3
-rw-r--r--include/linux/iio/machine.h5
-rw-r--r--include/linux/iio/trigger.h13
-rw-r--r--include/linux/iio/trigger_consumer.h11
-rw-r--r--include/linux/iio/types.h1
9 files changed, 301 insertions, 20 deletions
diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h
new file mode 100644
index 000000000000..2e4eab9868a3
--- /dev/null
+++ b/include/linux/iio/adc/ad_sigma_delta.h
@@ -0,0 +1,173 @@
1/*
2 * Support code for Analog Devices Sigma-Delta ADCs
3 *
4 * Copyright 2012 Analog Devices Inc.
5 * Author: Lars-Peter Clausen <lars@metafoo.de>
6 *
7 * Licensed under the GPL-2.
8 */
9#ifndef __AD_SIGMA_DELTA_H__
10#define __AD_SIGMA_DELTA_H__
11
12enum ad_sigma_delta_mode {
13 AD_SD_MODE_CONTINUOUS = 0,
14 AD_SD_MODE_SINGLE = 1,
15 AD_SD_MODE_IDLE = 2,
16 AD_SD_MODE_POWERDOWN = 3,
17};
18
19/**
20 * struct ad_sigma_delta_calib_data - Calibration data for Sigma Delta devices
21 * @mode: Calibration mode.
22 * @channel: Calibration channel.
23 */
24struct ad_sd_calib_data {
25 unsigned int mode;
26 unsigned int channel;
27};
28
29struct ad_sigma_delta;
30struct iio_dev;
31
32/**
33 * struct ad_sigma_delta_info - Sigma Delta driver specific callbacks and options
34 * @set_channel: Will be called to select the current channel, may be NULL.
35 * @set_mode: Will be called to select the current mode, may be NULL.
36 * @postprocess_sample: Is called for each sampled data word, can be used to
37 * modify or drop the sample data, it, may be NULL.
38 * @has_registers: true if the device has writable and readable registers, false
39 * if there is just one read-only sample data shift register.
40 * @addr_shift: Shift of the register address in the communications register.
41 * @read_mask: Mask for the communications register having the read bit set.
42 */
43struct ad_sigma_delta_info {
44 int (*set_channel)(struct ad_sigma_delta *, unsigned int channel);
45 int (*set_mode)(struct ad_sigma_delta *, enum ad_sigma_delta_mode mode);
46 int (*postprocess_sample)(struct ad_sigma_delta *, unsigned int raw_sample);
47 bool has_registers;
48 unsigned int addr_shift;
49 unsigned int read_mask;
50};
51
52/**
53 * struct ad_sigma_delta - Sigma Delta device struct
54 * @spi: The spi device associated with the Sigma Delta device.
55 * @trig: The IIO trigger associated with the Sigma Delta device.
56 *
57 * Most of the fields are private to the sigma delta library code and should not
58 * be accessed by individual drivers.
59 */
60struct ad_sigma_delta {
61 struct spi_device *spi;
62 struct iio_trigger *trig;
63
64/* private: */
65 struct completion completion;
66 bool irq_dis;
67
68 bool bus_locked;
69
70 uint8_t comm;
71
72 const struct ad_sigma_delta_info *info;
73
74 /*
75 * DMA (thus cache coherency maintenance) requires the
76 * transfer buffers to live in their own cache lines.
77 */
78 uint8_t data[4] ____cacheline_aligned;
79};
80
81static inline int ad_sigma_delta_set_channel(struct ad_sigma_delta *sd,
82 unsigned int channel)
83{
84 if (sd->info->set_channel)
85 return sd->info->set_channel(sd, channel);
86
87 return 0;
88}
89
90static inline int ad_sigma_delta_set_mode(struct ad_sigma_delta *sd,
91 unsigned int mode)
92{
93 if (sd->info->set_mode)
94 return sd->info->set_mode(sd, mode);
95
96 return 0;
97}
98
99static inline int ad_sigma_delta_postprocess_sample(struct ad_sigma_delta *sd,
100 unsigned int raw_sample)
101{
102 if (sd->info->postprocess_sample)
103 return sd->info->postprocess_sample(sd, raw_sample);
104
105 return 0;
106}
107
108void ad_sd_set_comm(struct ad_sigma_delta *sigma_delta, uint8_t comm);
109int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg,
110 unsigned int size, unsigned int val);
111int ad_sd_read_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg,
112 unsigned int size, unsigned int *val);
113
114int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev,
115 const struct iio_chan_spec *chan, int *val);
116int ad_sd_calibrate_all(struct ad_sigma_delta *sigma_delta,
117 const struct ad_sd_calib_data *cd, unsigned int n);
118int ad_sd_init(struct ad_sigma_delta *sigma_delta, struct iio_dev *indio_dev,
119 struct spi_device *spi, const struct ad_sigma_delta_info *info);
120
121int ad_sd_setup_buffer_and_trigger(struct iio_dev *indio_dev);
122void ad_sd_cleanup_buffer_and_trigger(struct iio_dev *indio_dev);
123
124int ad_sd_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig);
125
126#define __AD_SD_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
127 _storagebits, _shift, _extend_name, _type) \
128 { \
129 .type = (_type), \
130 .differential = (_channel2 == -1 ? 0 : 1), \
131 .indexed = 1, \
132 .channel = (_channel1), \
133 .channel2 = (_channel2), \
134 .address = (_address), \
135 .extend_name = (_extend_name), \
136 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
137 IIO_CHAN_INFO_SCALE_SHARED_BIT | \
138 IIO_CHAN_INFO_OFFSET_SEPARATE_BIT, \
139 .scan_index = (_si), \
140 .scan_type = { \
141 .sign = 'u', \
142 .realbits = (_bits), \
143 .storagebits = (_storagebits), \
144 .shift = (_shift), \
145 .endianness = IIO_BE, \
146 }, \
147 }
148
149#define AD_SD_DIFF_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
150 _storagebits, _shift) \
151 __AD_SD_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
152 _storagebits, _shift, NULL, IIO_VOLTAGE)
153
154#define AD_SD_SHORTED_CHANNEL(_si, _channel, _address, _bits, \
155 _storagebits, _shift) \
156 __AD_SD_CHANNEL(_si, _channel, _channel, _address, _bits, \
157 _storagebits, _shift, "shorted", IIO_VOLTAGE)
158
159#define AD_SD_CHANNEL(_si, _channel, _address, _bits, \
160 _storagebits, _shift) \
161 __AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \
162 _storagebits, _shift, NULL, IIO_VOLTAGE)
163
164#define AD_SD_TEMP_CHANNEL(_si, _address, _bits, _storagebits, _shift) \
165 __AD_SD_CHANNEL(_si, 0, -1, _address, _bits, \
166 _storagebits, _shift, NULL, IIO_TEMP)
167
168#define AD_SD_SUPPLY_CHANNEL(_si, _channel, _address, _bits, _storagebits, \
169 _shift) \
170 __AD_SD_CHANNEL(_si, _channel, -1, _address, _bits, \
171 _storagebits, _shift, "supply", IIO_VOLTAGE)
172
173#endif
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 8ba516fc2ec6..c629b3a1d9a9 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -36,7 +36,7 @@ struct iio_buffer;
36 * any of them not existing. 36 * any of them not existing.
37 **/ 37 **/
38struct iio_buffer_access_funcs { 38struct iio_buffer_access_funcs {
39 int (*store_to)(struct iio_buffer *buffer, u8 *data, s64 timestamp); 39 int (*store_to)(struct iio_buffer *buffer, u8 *data);
40 int (*read_first_n)(struct iio_buffer *buffer, 40 int (*read_first_n)(struct iio_buffer *buffer,
41 size_t n, 41 size_t n,
42 char __user *buf); 42 char __user *buf);
@@ -118,10 +118,8 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
118 * iio_push_to_buffer() - push to a registered buffer. 118 * iio_push_to_buffer() - push to a registered buffer.
119 * @buffer: IIO buffer structure for device 119 * @buffer: IIO buffer structure for device
120 * @data: the data to push to the buffer 120 * @data: the data to push to the buffer
121 * @timestamp: timestamp to associate with the data
122 */ 121 */
123int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data, 122int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data);
124 s64 timestamp);
125 123
126int iio_update_demux(struct iio_dev *indio_dev); 124int iio_update_demux(struct iio_dev *indio_dev);
127 125
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index e2657e6d4d26..e875bcf0478f 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -8,7 +8,7 @@
8 * the Free Software Foundation. 8 * the Free Software Foundation.
9 */ 9 */
10#ifndef _IIO_INKERN_CONSUMER_H_ 10#ifndef _IIO_INKERN_CONSUMER_H_
11#define _IIO_INKERN_CONSUMER_H 11#define _IIO_INKERN_CONSUMER_H_
12#include <linux/iio/types.h> 12#include <linux/iio/types.h>
13 13
14struct iio_dev; 14struct iio_dev;
@@ -61,7 +61,7 @@ void iio_channel_release_all(struct iio_channel *chan);
61 61
62/** 62/**
63 * iio_read_channel_raw() - read from a given channel 63 * iio_read_channel_raw() - read from a given channel
64 * @channel: The channel being queried. 64 * @chan: The channel being queried.
65 * @val: Value read back. 65 * @val: Value read back.
66 * 66 *
67 * Note raw reads from iio channels are in adc counts and hence 67 * Note raw reads from iio channels are in adc counts and hence
@@ -71,6 +71,21 @@ int iio_read_channel_raw(struct iio_channel *chan,
71 int *val); 71 int *val);
72 72
73/** 73/**
74 * iio_read_channel_processed() - read processed value from a given channel
75 * @chan: The channel being queried.
76 * @val: Value read back.
77 *
78 * Returns an error code or 0.
79 *
80 * This function will read a processed value from a channel. A processed value
81 * means that this value will have the correct unit and not some device internal
82 * representation. If the device does not support reporting a processed value
83 * the function will query the raw value and the channels scale and offset and
84 * do the appropriate transformation.
85 */
86int iio_read_channel_processed(struct iio_channel *chan, int *val);
87
88/**
74 * iio_get_channel_type() - get the type of a channel 89 * iio_get_channel_type() - get the type of a channel
75 * @channel: The channel being queried. 90 * @channel: The channel being queried.
76 * @type: The type of the channel. 91 * @type: The type of the channel.
@@ -82,7 +97,7 @@ int iio_get_channel_type(struct iio_channel *channel,
82 97
83/** 98/**
84 * iio_read_channel_scale() - read the scale value for a channel 99 * iio_read_channel_scale() - read the scale value for a channel
85 * @channel: The channel being queried. 100 * @chan: The channel being queried.
86 * @val: First part of value read back. 101 * @val: First part of value read back.
87 * @val2: Second part of value read back. 102 * @val2: Second part of value read back.
88 * 103 *
@@ -93,4 +108,27 @@ int iio_get_channel_type(struct iio_channel *channel,
93int iio_read_channel_scale(struct iio_channel *chan, int *val, 108int iio_read_channel_scale(struct iio_channel *chan, int *val,
94 int *val2); 109 int *val2);
95 110
111/**
112 * iio_convert_raw_to_processed() - Converts a raw value to a processed value
113 * @chan: The channel being queried
114 * @raw: The raw IIO to convert
115 * @processed: The result of the conversion
116 * @scale: Scale factor to apply during the conversion
117 *
118 * Returns an error code or 0.
119 *
120 * This function converts a raw value to processed value for a specific channel.
121 * A raw value is the device internal representation of a sample and the value
122 * returned by iio_read_channel_raw, so the unit of that value is device
123 * depended. A processed value on the other hand is value has a normed unit
124 * according with the IIO specification.
125 *
126 * The scale factor allows to increase the precession of the returned value. For
127 * a scale factor of 1 the function will return the result in the normal IIO
128 * unit for the channel type. E.g. millivolt for voltage channels, if you want
129 * nanovolts instead pass 1000 as the scale factor.
130 */
131int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
132 int *processed, unsigned int scale);
133
96#endif 134#endif
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index be82936c4089..c0ae76ac4e0b 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -35,10 +35,13 @@ enum iio_chan_info_enum {
35 IIO_CHAN_INFO_FREQUENCY, 35 IIO_CHAN_INFO_FREQUENCY,
36 IIO_CHAN_INFO_PHASE, 36 IIO_CHAN_INFO_PHASE,
37 IIO_CHAN_INFO_HARDWAREGAIN, 37 IIO_CHAN_INFO_HARDWAREGAIN,
38 IIO_CHAN_INFO_HYSTERESIS,
38}; 39};
39 40
40#define IIO_CHAN_INFO_SHARED_BIT(type) BIT(type*2) 41#define IIO_CHAN_INFO_SHARED_BIT(type) BIT(type*2)
41#define IIO_CHAN_INFO_SEPARATE_BIT(type) BIT(type*2 + 1) 42#define IIO_CHAN_INFO_SEPARATE_BIT(type) BIT(type*2 + 1)
43#define IIO_CHAN_INFO_BITS(type) (IIO_CHAN_INFO_SHARED_BIT(type) | \
44 IIO_CHAN_INFO_SEPARATE_BIT(type))
42 45
43#define IIO_CHAN_INFO_RAW_SEPARATE_BIT \ 46#define IIO_CHAN_INFO_RAW_SEPARATE_BIT \
44 IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_RAW) 47 IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_RAW)
@@ -100,6 +103,10 @@ enum iio_chan_info_enum {
100 IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_HARDWAREGAIN) 103 IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_HARDWAREGAIN)
101#define IIO_CHAN_INFO_HARDWAREGAIN_SHARED_BIT \ 104#define IIO_CHAN_INFO_HARDWAREGAIN_SHARED_BIT \
102 IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_HARDWAREGAIN) 105 IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_HARDWAREGAIN)
106#define IIO_CHAN_INFO_HYSTERESIS_SEPARATE_BIT \
107 IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_HYSTERESIS)
108#define IIO_CHAN_INFO_HYSTERESIS_SHARED_BIT \
109 IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_HYSTERESIS)
103 110
104enum iio_endian { 111enum iio_endian {
105 IIO_CPU, 112 IIO_CPU,
@@ -164,7 +171,7 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
164 * IIO_ENUM() - Initialize enum extended channel attribute 171 * IIO_ENUM() - Initialize enum extended channel attribute
165 * @_name: Attribute name 172 * @_name: Attribute name
166 * @_shared: Whether the attribute is shared between all channels 173 * @_shared: Whether the attribute is shared between all channels
167 * @_e: Pointer to a iio_enum struct 174 * @_e: Pointer to an iio_enum struct
168 * 175 *
169 * This should usually be used together with IIO_ENUM_AVAILABLE() 176 * This should usually be used together with IIO_ENUM_AVAILABLE()
170 */ 177 */
@@ -180,9 +187,9 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
180/** 187/**
181 * IIO_ENUM_AVAILABLE() - Initialize enum available extended channel attribute 188 * IIO_ENUM_AVAILABLE() - Initialize enum available extended channel attribute
182 * @_name: Attribute name ("_available" will be appended to the name) 189 * @_name: Attribute name ("_available" will be appended to the name)
183 * @_e: Pointer to a iio_enum struct 190 * @_e: Pointer to an iio_enum struct
184 * 191 *
185 * Creates a read only attribute which list all the available enum items in a 192 * Creates a read only attribute which lists all the available enum items in a
186 * space separated list. This should usually be used together with IIO_ENUM() 193 * space separated list. This should usually be used together with IIO_ENUM()
187 */ 194 */
188#define IIO_ENUM_AVAILABLE(_name, _e) \ 195#define IIO_ENUM_AVAILABLE(_name, _e) \
@@ -229,6 +236,7 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
229 * @indexed: Specify the channel has a numerical index. If not, 236 * @indexed: Specify the channel has a numerical index. If not,
230 * the channel index number will be suppressed for sysfs 237 * the channel index number will be suppressed for sysfs
231 * attributes but not for event codes. 238 * attributes but not for event codes.
239 * @output: Channel is output.
232 * @differential: Channel is differential. 240 * @differential: Channel is differential.
233 */ 241 */
234struct iio_chan_spec { 242struct iio_chan_spec {
@@ -255,6 +263,21 @@ struct iio_chan_spec {
255 unsigned differential:1; 263 unsigned differential:1;
256}; 264};
257 265
266
267/**
268 * iio_channel_has_info() - Checks whether a channel supports a info attribute
269 * @chan: The channel to be queried
270 * @type: Type of the info attribute to be checked
271 *
272 * Returns true if the channels supports reporting values for the given info
273 * attribute type, false otherwise.
274 */
275static inline bool iio_channel_has_info(const struct iio_chan_spec *chan,
276 enum iio_chan_info_enum type)
277{
278 return chan->info_mask & IIO_CHAN_INFO_BITS(type);
279}
280
258#define IIO_ST(si, rb, sb, sh) \ 281#define IIO_ST(si, rb, sb, sh) \
259 { .sign = si, .realbits = rb, .storagebits = sb, .shift = sh } 282 { .sign = si, .realbits = rb, .storagebits = sb, .shift = sh }
260 283
@@ -312,6 +335,9 @@ struct iio_dev;
312 * Meaning is event dependent. 335 * Meaning is event dependent.
313 * @validate_trigger: function to validate the trigger when the 336 * @validate_trigger: function to validate the trigger when the
314 * current trigger gets changed. 337 * current trigger gets changed.
338 * @update_scan_mode: function to configure device and scan buffer when
339 * channels have changed
340 * @debugfs_reg_access: function to read or write register value of device
315 **/ 341 **/
316struct iio_info { 342struct iio_info {
317 struct module *driver_module; 343 struct module *driver_module;
@@ -367,10 +393,10 @@ struct iio_info {
367 * scan mask is valid for the device. 393 * scan mask is valid for the device.
368 */ 394 */
369struct iio_buffer_setup_ops { 395struct iio_buffer_setup_ops {
370 int (*preenable)(struct iio_dev *); 396 int (*preenable)(struct iio_dev *);
371 int (*postenable)(struct iio_dev *); 397 int (*postenable)(struct iio_dev *);
372 int (*predisable)(struct iio_dev *); 398 int (*predisable)(struct iio_dev *);
373 int (*postdisable)(struct iio_dev *); 399 int (*postdisable)(struct iio_dev *);
374 bool (*validate_scan_mask)(struct iio_dev *indio_dev, 400 bool (*validate_scan_mask)(struct iio_dev *indio_dev,
375 const unsigned long *scan_mask); 401 const unsigned long *scan_mask);
376}; 402};
@@ -516,6 +542,31 @@ static inline struct iio_dev *iio_device_get(struct iio_dev *indio_dev)
516 return indio_dev ? dev_to_iio_dev(get_device(&indio_dev->dev)) : NULL; 542 return indio_dev ? dev_to_iio_dev(get_device(&indio_dev->dev)) : NULL;
517} 543}
518 544
545
546/**
547 * iio_device_set_drvdata() - Set device driver data
548 * @indio_dev: IIO device structure
549 * @data: Driver specific data
550 *
551 * Allows to attach an arbitrary pointer to an IIO device, which can later be
552 * retrieved by iio_device_get_drvdata().
553 */
554static inline void iio_device_set_drvdata(struct iio_dev *indio_dev, void *data)
555{
556 dev_set_drvdata(&indio_dev->dev, data);
557}
558
559/**
560 * iio_device_get_drvdata() - Get device driver data
561 * @indio_dev: IIO device structure
562 *
563 * Returns the data previously set with iio_device_set_drvdata()
564 */
565static inline void *iio_device_get_drvdata(struct iio_dev *indio_dev)
566{
567 return dev_get_drvdata(&indio_dev->dev);
568}
569
519/* Can we make this smaller? */ 570/* Can we make this smaller? */
520#define IIO_ALIGN L1_CACHE_BYTES 571#define IIO_ALIGN L1_CACHE_BYTES
521/** 572/**
diff --git a/include/linux/iio/kfifo_buf.h b/include/linux/iio/kfifo_buf.h
index 014d5a13b32b..25eeac762e84 100644
--- a/include/linux/iio/kfifo_buf.h
+++ b/include/linux/iio/kfifo_buf.h
@@ -1,3 +1,5 @@
1#ifndef __LINUX_IIO_KFIFO_BUF_H__
2#define __LINUX_IIO_KFIFO_BUF_H__
1 3
2#include <linux/kfifo.h> 4#include <linux/kfifo.h>
3#include <linux/iio/iio.h> 5#include <linux/iio/iio.h>
@@ -6,3 +8,4 @@
6struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev); 8struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev);
7void iio_kfifo_free(struct iio_buffer *r); 9void iio_kfifo_free(struct iio_buffer *r);
8 10
11#endif
diff --git a/include/linux/iio/machine.h b/include/linux/iio/machine.h
index 400a453ff67b..809a3f08d5a5 100644
--- a/include/linux/iio/machine.h
+++ b/include/linux/iio/machine.h
@@ -8,6 +8,9 @@
8 * the Free Software Foundation. 8 * the Free Software Foundation.
9 */ 9 */
10 10
11#ifndef __LINUX_IIO_MACHINE_H__
12#define __LINUX_IIO_MACHINE_H__
13
11/** 14/**
12 * struct iio_map - description of link between consumer and device channels 15 * struct iio_map - description of link between consumer and device channels
13 * @adc_channel_label: Label used to identify the channel on the provider. 16 * @adc_channel_label: Label used to identify the channel on the provider.
@@ -22,3 +25,5 @@ struct iio_map {
22 const char *consumer_dev_name; 25 const char *consumer_dev_name;
23 const char *consumer_channel; 26 const char *consumer_channel;
24}; 27};
28
29#endif
diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
index a9819940a84c..20239da1d0f7 100644
--- a/include/linux/iio/trigger.h
+++ b/include/linux/iio/trigger.h
@@ -29,7 +29,7 @@ struct iio_subirq {
29 * instances of a given device. 29 * instances of a given device.
30 **/ 30 **/
31struct iio_trigger_ops { 31struct iio_trigger_ops {
32 struct module *owner; 32 struct module *owner;
33 int (*set_trigger_state)(struct iio_trigger *trig, bool state); 33 int (*set_trigger_state)(struct iio_trigger *trig, bool state);
34 int (*try_reenable)(struct iio_trigger *trig); 34 int (*try_reenable)(struct iio_trigger *trig);
35 int (*validate_device)(struct iio_trigger *trig, 35 int (*validate_device)(struct iio_trigger *trig,
@@ -39,7 +39,7 @@ struct iio_trigger_ops {
39 39
40/** 40/**
41 * struct iio_trigger - industrial I/O trigger device 41 * struct iio_trigger - industrial I/O trigger device
42 * 42 * @ops: [DRIVER] operations structure
43 * @id: [INTERN] unique id number 43 * @id: [INTERN] unique id number
44 * @name: [DRIVER] unique name 44 * @name: [DRIVER] unique name
45 * @dev: [DRIVER] associated device (if relevant) 45 * @dev: [DRIVER] associated device (if relevant)
@@ -76,19 +76,19 @@ struct iio_trigger {
76static inline struct iio_trigger *to_iio_trigger(struct device *d) 76static inline struct iio_trigger *to_iio_trigger(struct device *d)
77{ 77{
78 return container_of(d, struct iio_trigger, dev); 78 return container_of(d, struct iio_trigger, dev);
79}; 79}
80 80
81static inline void iio_trigger_put(struct iio_trigger *trig) 81static inline void iio_trigger_put(struct iio_trigger *trig)
82{ 82{
83 module_put(trig->ops->owner); 83 module_put(trig->ops->owner);
84 put_device(&trig->dev); 84 put_device(&trig->dev);
85}; 85}
86 86
87static inline void iio_trigger_get(struct iio_trigger *trig) 87static inline void iio_trigger_get(struct iio_trigger *trig)
88{ 88{
89 get_device(&trig->dev); 89 get_device(&trig->dev);
90 __module_get(trig->ops->owner); 90 __module_get(trig->ops->owner);
91}; 91}
92 92
93/** 93/**
94 * iio_trigger_register() - register a trigger with the IIO core 94 * iio_trigger_register() - register a trigger with the IIO core
@@ -104,7 +104,8 @@ void iio_trigger_unregister(struct iio_trigger *trig_info);
104 104
105/** 105/**
106 * iio_trigger_poll() - called on a trigger occurring 106 * iio_trigger_poll() - called on a trigger occurring
107 * @trig: trigger which occurred 107 * @trig: trigger which occurred
108 * @time: timestamp when trigger occurred
108 * 109 *
109 * Typically called in relevant hardware interrupt handler. 110 * Typically called in relevant hardware interrupt handler.
110 **/ 111 **/
diff --git a/include/linux/iio/trigger_consumer.h b/include/linux/iio/trigger_consumer.h
index 60d64b356945..c4f8c7409666 100644
--- a/include/linux/iio/trigger_consumer.h
+++ b/include/linux/iio/trigger_consumer.h
@@ -7,6 +7,15 @@
7 * the Free Software Foundation. 7 * the Free Software Foundation.
8 */ 8 */
9 9
10#ifndef __LINUX_IIO_TRIGGER_CONSUMER_H__
11#define __LINUX_IIO_TRIGGER_CONSUMER_H__
12
13#include <linux/interrupt.h>
14#include <linux/types.h>
15
16struct iio_dev;
17struct iio_trigger;
18
10/** 19/**
11 * struct iio_poll_func - poll function pair 20 * struct iio_poll_func - poll function pair
12 * 21 *
@@ -50,3 +59,5 @@ void iio_trigger_notify_done(struct iio_trigger *trig);
50 */ 59 */
51int iio_triggered_buffer_postenable(struct iio_dev *indio_dev); 60int iio_triggered_buffer_postenable(struct iio_dev *indio_dev);
52int iio_triggered_buffer_predisable(struct iio_dev *indio_dev); 61int iio_triggered_buffer_predisable(struct iio_dev *indio_dev);
62
63#endif
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
index 44e397705d7f..5c647ecfd5ba 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
@@ -57,5 +57,6 @@ enum iio_modifier {
57#define IIO_VAL_INT_PLUS_MICRO 2 57#define IIO_VAL_INT_PLUS_MICRO 2
58#define IIO_VAL_INT_PLUS_NANO 3 58#define IIO_VAL_INT_PLUS_NANO 3
59#define IIO_VAL_INT_PLUS_MICRO_DB 4 59#define IIO_VAL_INT_PLUS_MICRO_DB 4
60#define IIO_VAL_FRACTIONAL 10
60 61
61#endif /* _IIO_TYPES_H_ */ 62#endif /* _IIO_TYPES_H_ */