xref: /OK3568_Linux_fs/kernel/include/linux/iio/consumer.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Industrial I/O in kernel consumer interface
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (c) 2011 Jonathan Cameron
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun #ifndef _IIO_INKERN_CONSUMER_H_
8*4882a593Smuzhiyun #define _IIO_INKERN_CONSUMER_H_
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <linux/types.h>
11*4882a593Smuzhiyun #include <linux/iio/types.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun struct iio_dev;
14*4882a593Smuzhiyun struct iio_chan_spec;
15*4882a593Smuzhiyun struct device;
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun /**
18*4882a593Smuzhiyun  * struct iio_channel - everything needed for a consumer to use a channel
19*4882a593Smuzhiyun  * @indio_dev:		Device on which the channel exists.
20*4882a593Smuzhiyun  * @channel:		Full description of the channel.
21*4882a593Smuzhiyun  * @data:		Data about the channel used by consumer.
22*4882a593Smuzhiyun  */
23*4882a593Smuzhiyun struct iio_channel {
24*4882a593Smuzhiyun 	struct iio_dev *indio_dev;
25*4882a593Smuzhiyun 	const struct iio_chan_spec *channel;
26*4882a593Smuzhiyun 	void *data;
27*4882a593Smuzhiyun };
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun /**
30*4882a593Smuzhiyun  * iio_channel_get() - get description of all that is needed to access channel.
31*4882a593Smuzhiyun  * @dev:		Pointer to consumer device. Device name must match
32*4882a593Smuzhiyun  *			the name of the device as provided in the iio_map
33*4882a593Smuzhiyun  *			with which the desired provider to consumer mapping
34*4882a593Smuzhiyun  *			was registered.
35*4882a593Smuzhiyun  * @consumer_channel:	Unique name to identify the channel on the consumer
36*4882a593Smuzhiyun  *			side. This typically describes the channels use within
37*4882a593Smuzhiyun  *			the consumer. E.g. 'battery_voltage'
38*4882a593Smuzhiyun  */
39*4882a593Smuzhiyun struct iio_channel *iio_channel_get(struct device *dev,
40*4882a593Smuzhiyun 				    const char *consumer_channel);
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /**
43*4882a593Smuzhiyun  * iio_channel_release() - release channels obtained via iio_channel_get
44*4882a593Smuzhiyun  * @chan:		The channel to be released.
45*4882a593Smuzhiyun  */
46*4882a593Smuzhiyun void iio_channel_release(struct iio_channel *chan);
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun /**
49*4882a593Smuzhiyun  * devm_iio_channel_get() - Resource managed version of iio_channel_get().
50*4882a593Smuzhiyun  * @dev:		Pointer to consumer device. Device name must match
51*4882a593Smuzhiyun  *			the name of the device as provided in the iio_map
52*4882a593Smuzhiyun  *			with which the desired provider to consumer mapping
53*4882a593Smuzhiyun  *			was registered.
54*4882a593Smuzhiyun  * @consumer_channel:	Unique name to identify the channel on the consumer
55*4882a593Smuzhiyun  *			side. This typically describes the channels use within
56*4882a593Smuzhiyun  *			the consumer. E.g. 'battery_voltage'
57*4882a593Smuzhiyun  *
58*4882a593Smuzhiyun  * Returns a pointer to negative errno if it is not able to get the iio channel
59*4882a593Smuzhiyun  * otherwise returns valid pointer for iio channel.
60*4882a593Smuzhiyun  *
61*4882a593Smuzhiyun  * The allocated iio channel is automatically released when the device is
62*4882a593Smuzhiyun  * unbound.
63*4882a593Smuzhiyun  */
64*4882a593Smuzhiyun struct iio_channel *devm_iio_channel_get(struct device *dev,
65*4882a593Smuzhiyun 					 const char *consumer_channel);
66*4882a593Smuzhiyun /**
67*4882a593Smuzhiyun  * iio_channel_get_all() - get all channels associated with a client
68*4882a593Smuzhiyun  * @dev:		Pointer to consumer device.
69*4882a593Smuzhiyun  *
70*4882a593Smuzhiyun  * Returns an array of iio_channel structures terminated with one with
71*4882a593Smuzhiyun  * null iio_dev pointer.
72*4882a593Smuzhiyun  * This function is used by fairly generic consumers to get all the
73*4882a593Smuzhiyun  * channels registered as having this consumer.
74*4882a593Smuzhiyun  */
75*4882a593Smuzhiyun struct iio_channel *iio_channel_get_all(struct device *dev);
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun /**
78*4882a593Smuzhiyun  * iio_channel_release_all() - reverse iio_channel_get_all
79*4882a593Smuzhiyun  * @chan:		Array of channels to be released.
80*4882a593Smuzhiyun  */
81*4882a593Smuzhiyun void iio_channel_release_all(struct iio_channel *chan);
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun /**
84*4882a593Smuzhiyun  * devm_iio_channel_get_all() - Resource managed version of
85*4882a593Smuzhiyun  *				iio_channel_get_all().
86*4882a593Smuzhiyun  * @dev: Pointer to consumer device.
87*4882a593Smuzhiyun  *
88*4882a593Smuzhiyun  * Returns a pointer to negative errno if it is not able to get the iio channel
89*4882a593Smuzhiyun  * otherwise returns an array of iio_channel structures terminated with one with
90*4882a593Smuzhiyun  * null iio_dev pointer.
91*4882a593Smuzhiyun  *
92*4882a593Smuzhiyun  * This function is used by fairly generic consumers to get all the
93*4882a593Smuzhiyun  * channels registered as having this consumer.
94*4882a593Smuzhiyun  *
95*4882a593Smuzhiyun  * The allocated iio channels are automatically released when the device is
96*4882a593Smuzhiyun  * unbounded.
97*4882a593Smuzhiyun  */
98*4882a593Smuzhiyun struct iio_channel *devm_iio_channel_get_all(struct device *dev);
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun struct iio_cb_buffer;
101*4882a593Smuzhiyun /**
102*4882a593Smuzhiyun  * iio_channel_get_all_cb() - register callback for triggered capture
103*4882a593Smuzhiyun  * @dev:		Pointer to client device.
104*4882a593Smuzhiyun  * @cb:			Callback function.
105*4882a593Smuzhiyun  * @private:		Private data passed to callback.
106*4882a593Smuzhiyun  *
107*4882a593Smuzhiyun  * NB right now we have no ability to mux data from multiple devices.
108*4882a593Smuzhiyun  * So if the channels requested come from different devices this will
109*4882a593Smuzhiyun  * fail.
110*4882a593Smuzhiyun  */
111*4882a593Smuzhiyun struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
112*4882a593Smuzhiyun 					     int (*cb)(const void *data,
113*4882a593Smuzhiyun 						       void *private),
114*4882a593Smuzhiyun 					     void *private);
115*4882a593Smuzhiyun /**
116*4882a593Smuzhiyun  * iio_channel_cb_set_buffer_watermark() - set the buffer watermark.
117*4882a593Smuzhiyun  * @cb_buffer:		The callback buffer from whom we want the channel
118*4882a593Smuzhiyun  *			information.
119*4882a593Smuzhiyun  * @watermark: buffer watermark in bytes.
120*4882a593Smuzhiyun  *
121*4882a593Smuzhiyun  * This function allows to configure the buffer watermark.
122*4882a593Smuzhiyun  */
123*4882a593Smuzhiyun int iio_channel_cb_set_buffer_watermark(struct iio_cb_buffer *cb_buffer,
124*4882a593Smuzhiyun 					size_t watermark);
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun /**
127*4882a593Smuzhiyun  * iio_channel_release_all_cb() - release and unregister the callback.
128*4882a593Smuzhiyun  * @cb_buffer:		The callback buffer that was allocated.
129*4882a593Smuzhiyun  */
130*4882a593Smuzhiyun void iio_channel_release_all_cb(struct iio_cb_buffer *cb_buffer);
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun /**
133*4882a593Smuzhiyun  * iio_channel_start_all_cb() - start the flow of data through callback.
134*4882a593Smuzhiyun  * @cb_buff:		The callback buffer we are starting.
135*4882a593Smuzhiyun  */
136*4882a593Smuzhiyun int iio_channel_start_all_cb(struct iio_cb_buffer *cb_buff);
137*4882a593Smuzhiyun 
138*4882a593Smuzhiyun /**
139*4882a593Smuzhiyun  * iio_channel_stop_all_cb() - stop the flow of data through the callback.
140*4882a593Smuzhiyun  * @cb_buff:		The callback buffer we are stopping.
141*4882a593Smuzhiyun  */
142*4882a593Smuzhiyun void iio_channel_stop_all_cb(struct iio_cb_buffer *cb_buff);
143*4882a593Smuzhiyun 
144*4882a593Smuzhiyun /**
145*4882a593Smuzhiyun  * iio_channel_cb_get_channels() - get access to the underlying channels.
146*4882a593Smuzhiyun  * @cb_buffer:		The callback buffer from whom we want the channel
147*4882a593Smuzhiyun  *			information.
148*4882a593Smuzhiyun  *
149*4882a593Smuzhiyun  * This function allows one to obtain information about the channels.
150*4882a593Smuzhiyun  * Whilst this may allow direct reading if all buffers are disabled, the
151*4882a593Smuzhiyun  * primary aim is to allow drivers that are consuming a channel to query
152*4882a593Smuzhiyun  * things like scaling of the channel.
153*4882a593Smuzhiyun  */
154*4882a593Smuzhiyun struct iio_channel
155*4882a593Smuzhiyun *iio_channel_cb_get_channels(const struct iio_cb_buffer *cb_buffer);
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun /**
158*4882a593Smuzhiyun  * iio_channel_cb_get_iio_dev() - get access to the underlying device.
159*4882a593Smuzhiyun  * @cb_buffer:		The callback buffer from whom we want the device
160*4882a593Smuzhiyun  *			information.
161*4882a593Smuzhiyun  *
162*4882a593Smuzhiyun  * This function allows one to obtain information about the device.
163*4882a593Smuzhiyun  * The primary aim is to allow drivers that are consuming a device to query
164*4882a593Smuzhiyun  * things like current trigger.
165*4882a593Smuzhiyun  */
166*4882a593Smuzhiyun struct iio_dev
167*4882a593Smuzhiyun *iio_channel_cb_get_iio_dev(const struct iio_cb_buffer *cb_buffer);
168*4882a593Smuzhiyun 
169*4882a593Smuzhiyun /**
170*4882a593Smuzhiyun  * iio_read_channel_raw() - read from a given channel
171*4882a593Smuzhiyun  * @chan:		The channel being queried.
172*4882a593Smuzhiyun  * @val:		Value read back.
173*4882a593Smuzhiyun  *
174*4882a593Smuzhiyun  * Note raw reads from iio channels are in adc counts and hence
175*4882a593Smuzhiyun  * scale will need to be applied if standard units required.
176*4882a593Smuzhiyun  */
177*4882a593Smuzhiyun int iio_read_channel_raw(struct iio_channel *chan,
178*4882a593Smuzhiyun 			 int *val);
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun /**
181*4882a593Smuzhiyun  * iio_read_channel_average_raw() - read from a given channel
182*4882a593Smuzhiyun  * @chan:		The channel being queried.
183*4882a593Smuzhiyun  * @val:		Value read back.
184*4882a593Smuzhiyun  *
185*4882a593Smuzhiyun  * Note raw reads from iio channels are in adc counts and hence
186*4882a593Smuzhiyun  * scale will need to be applied if standard units required.
187*4882a593Smuzhiyun  *
188*4882a593Smuzhiyun  * In opposit to the normal iio_read_channel_raw this function
189*4882a593Smuzhiyun  * returns the average of multiple reads.
190*4882a593Smuzhiyun  */
191*4882a593Smuzhiyun int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
192*4882a593Smuzhiyun 
193*4882a593Smuzhiyun /**
194*4882a593Smuzhiyun  * iio_read_channel_processed() - read processed value from a given channel
195*4882a593Smuzhiyun  * @chan:		The channel being queried.
196*4882a593Smuzhiyun  * @val:		Value read back.
197*4882a593Smuzhiyun  *
198*4882a593Smuzhiyun  * Returns an error code or 0.
199*4882a593Smuzhiyun  *
200*4882a593Smuzhiyun  * This function will read a processed value from a channel. A processed value
201*4882a593Smuzhiyun  * means that this value will have the correct unit and not some device internal
202*4882a593Smuzhiyun  * representation. If the device does not support reporting a processed value
203*4882a593Smuzhiyun  * the function will query the raw value and the channels scale and offset and
204*4882a593Smuzhiyun  * do the appropriate transformation.
205*4882a593Smuzhiyun  */
206*4882a593Smuzhiyun int iio_read_channel_processed(struct iio_channel *chan, int *val);
207*4882a593Smuzhiyun 
208*4882a593Smuzhiyun /**
209*4882a593Smuzhiyun  * iio_write_channel_attribute() - Write values to the device attribute.
210*4882a593Smuzhiyun  * @chan:	The channel being queried.
211*4882a593Smuzhiyun  * @val:	Value being written.
212*4882a593Smuzhiyun  * @val2:	Value being written.val2 use depends on attribute type.
213*4882a593Smuzhiyun  * @attribute:	info attribute to be read.
214*4882a593Smuzhiyun  *
215*4882a593Smuzhiyun  * Returns an error code or 0.
216*4882a593Smuzhiyun  */
217*4882a593Smuzhiyun int iio_write_channel_attribute(struct iio_channel *chan, int val,
218*4882a593Smuzhiyun 				int val2, enum iio_chan_info_enum attribute);
219*4882a593Smuzhiyun 
220*4882a593Smuzhiyun /**
221*4882a593Smuzhiyun  * iio_read_channel_attribute() - Read values from the device attribute.
222*4882a593Smuzhiyun  * @chan:	The channel being queried.
223*4882a593Smuzhiyun  * @val:	Value being written.
224*4882a593Smuzhiyun  * @val2:	Value being written.Val2 use depends on attribute type.
225*4882a593Smuzhiyun  * @attribute:	info attribute to be written.
226*4882a593Smuzhiyun  *
227*4882a593Smuzhiyun  * Returns an error code if failed. Else returns a description of what is in val
228*4882a593Smuzhiyun  * and val2, such as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val
229*4882a593Smuzhiyun  * + val2/1e6
230*4882a593Smuzhiyun  */
231*4882a593Smuzhiyun int iio_read_channel_attribute(struct iio_channel *chan, int *val,
232*4882a593Smuzhiyun 			       int *val2, enum iio_chan_info_enum attribute);
233*4882a593Smuzhiyun 
234*4882a593Smuzhiyun /**
235*4882a593Smuzhiyun  * iio_write_channel_raw() - write to a given channel
236*4882a593Smuzhiyun  * @chan:		The channel being queried.
237*4882a593Smuzhiyun  * @val:		Value being written.
238*4882a593Smuzhiyun  *
239*4882a593Smuzhiyun  * Note raw writes to iio channels are in dac counts and hence
240*4882a593Smuzhiyun  * scale will need to be applied if standard units required.
241*4882a593Smuzhiyun  */
242*4882a593Smuzhiyun int iio_write_channel_raw(struct iio_channel *chan, int val);
243*4882a593Smuzhiyun 
244*4882a593Smuzhiyun /**
245*4882a593Smuzhiyun  * iio_read_max_channel_raw() - read maximum available raw value from a given
246*4882a593Smuzhiyun  *				channel, i.e. the maximum possible value.
247*4882a593Smuzhiyun  * @chan:		The channel being queried.
248*4882a593Smuzhiyun  * @val:		Value read back.
249*4882a593Smuzhiyun  *
250*4882a593Smuzhiyun  * Note raw reads from iio channels are in adc counts and hence
251*4882a593Smuzhiyun  * scale will need to be applied if standard units are required.
252*4882a593Smuzhiyun  */
253*4882a593Smuzhiyun int iio_read_max_channel_raw(struct iio_channel *chan, int *val);
254*4882a593Smuzhiyun 
255*4882a593Smuzhiyun /**
256*4882a593Smuzhiyun  * iio_read_avail_channel_raw() - read available raw values from a given channel
257*4882a593Smuzhiyun  * @chan:		The channel being queried.
258*4882a593Smuzhiyun  * @vals:		Available values read back.
259*4882a593Smuzhiyun  * @length:		Number of entries in vals.
260*4882a593Smuzhiyun  *
261*4882a593Smuzhiyun  * Returns an error code, IIO_AVAIL_RANGE or IIO_AVAIL_LIST.
262*4882a593Smuzhiyun  *
263*4882a593Smuzhiyun  * For ranges, three vals are always returned; min, step and max.
264*4882a593Smuzhiyun  * For lists, all the possible values are enumerated.
265*4882a593Smuzhiyun  *
266*4882a593Smuzhiyun  * Note raw available values from iio channels are in adc counts and
267*4882a593Smuzhiyun  * hence scale will need to be applied if standard units are required.
268*4882a593Smuzhiyun  */
269*4882a593Smuzhiyun int iio_read_avail_channel_raw(struct iio_channel *chan,
270*4882a593Smuzhiyun 			       const int **vals, int *length);
271*4882a593Smuzhiyun 
272*4882a593Smuzhiyun /**
273*4882a593Smuzhiyun  * iio_read_avail_channel_attribute() - read available channel attribute values
274*4882a593Smuzhiyun  * @chan:		The channel being queried.
275*4882a593Smuzhiyun  * @vals:		Available values read back.
276*4882a593Smuzhiyun  * @type:		Type of values read back.
277*4882a593Smuzhiyun  * @length:		Number of entries in vals.
278*4882a593Smuzhiyun  * @attribute:		info attribute to be read back.
279*4882a593Smuzhiyun  *
280*4882a593Smuzhiyun  * Returns an error code, IIO_AVAIL_RANGE or IIO_AVAIL_LIST.
281*4882a593Smuzhiyun  */
282*4882a593Smuzhiyun int iio_read_avail_channel_attribute(struct iio_channel *chan,
283*4882a593Smuzhiyun 				     const int **vals, int *type, int *length,
284*4882a593Smuzhiyun 				     enum iio_chan_info_enum attribute);
285*4882a593Smuzhiyun 
286*4882a593Smuzhiyun /**
287*4882a593Smuzhiyun  * iio_get_channel_type() - get the type of a channel
288*4882a593Smuzhiyun  * @channel:		The channel being queried.
289*4882a593Smuzhiyun  * @type:		The type of the channel.
290*4882a593Smuzhiyun  *
291*4882a593Smuzhiyun  * returns the enum iio_chan_type of the channel
292*4882a593Smuzhiyun  */
293*4882a593Smuzhiyun int iio_get_channel_type(struct iio_channel *channel,
294*4882a593Smuzhiyun 			 enum iio_chan_type *type);
295*4882a593Smuzhiyun 
296*4882a593Smuzhiyun /**
297*4882a593Smuzhiyun  * iio_read_channel_offset() - read the offset value for a channel
298*4882a593Smuzhiyun  * @chan:		The channel being queried.
299*4882a593Smuzhiyun  * @val:		First part of value read back.
300*4882a593Smuzhiyun  * @val2:		Second part of value read back.
301*4882a593Smuzhiyun  *
302*4882a593Smuzhiyun  * Note returns a description of what is in val and val2, such
303*4882a593Smuzhiyun  * as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val
304*4882a593Smuzhiyun  * + val2/1e6
305*4882a593Smuzhiyun  */
306*4882a593Smuzhiyun int iio_read_channel_offset(struct iio_channel *chan, int *val,
307*4882a593Smuzhiyun 			   int *val2);
308*4882a593Smuzhiyun 
309*4882a593Smuzhiyun /**
310*4882a593Smuzhiyun  * iio_read_channel_scale() - read the scale value for a channel
311*4882a593Smuzhiyun  * @chan:		The channel being queried.
312*4882a593Smuzhiyun  * @val:		First part of value read back.
313*4882a593Smuzhiyun  * @val2:		Second part of value read back.
314*4882a593Smuzhiyun  *
315*4882a593Smuzhiyun  * Note returns a description of what is in val and val2, such
316*4882a593Smuzhiyun  * as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val
317*4882a593Smuzhiyun  * + val2/1e6
318*4882a593Smuzhiyun  */
319*4882a593Smuzhiyun int iio_read_channel_scale(struct iio_channel *chan, int *val,
320*4882a593Smuzhiyun 			   int *val2);
321*4882a593Smuzhiyun 
322*4882a593Smuzhiyun /**
323*4882a593Smuzhiyun  * iio_convert_raw_to_processed() - Converts a raw value to a processed value
324*4882a593Smuzhiyun  * @chan:		The channel being queried
325*4882a593Smuzhiyun  * @raw:		The raw IIO to convert
326*4882a593Smuzhiyun  * @processed:		The result of the conversion
327*4882a593Smuzhiyun  * @scale:		Scale factor to apply during the conversion
328*4882a593Smuzhiyun  *
329*4882a593Smuzhiyun  * Returns an error code or 0.
330*4882a593Smuzhiyun  *
331*4882a593Smuzhiyun  * This function converts a raw value to processed value for a specific channel.
332*4882a593Smuzhiyun  * A raw value is the device internal representation of a sample and the value
333*4882a593Smuzhiyun  * returned by iio_read_channel_raw, so the unit of that value is device
334*4882a593Smuzhiyun  * depended. A processed value on the other hand is value has a normed unit
335*4882a593Smuzhiyun  * according with the IIO specification.
336*4882a593Smuzhiyun  *
337*4882a593Smuzhiyun  * The scale factor allows to increase the precession of the returned value. For
338*4882a593Smuzhiyun  * a scale factor of 1 the function will return the result in the normal IIO
339*4882a593Smuzhiyun  * unit for the channel type. E.g. millivolt for voltage channels, if you want
340*4882a593Smuzhiyun  * nanovolts instead pass 1000000 as the scale factor.
341*4882a593Smuzhiyun  */
342*4882a593Smuzhiyun int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
343*4882a593Smuzhiyun 	int *processed, unsigned int scale);
344*4882a593Smuzhiyun 
345*4882a593Smuzhiyun /**
346*4882a593Smuzhiyun  * iio_get_channel_ext_info_count() - get number of ext_info attributes
347*4882a593Smuzhiyun  *				      connected to the channel.
348*4882a593Smuzhiyun  * @chan:		The channel being queried
349*4882a593Smuzhiyun  *
350*4882a593Smuzhiyun  * Returns the number of ext_info attributes
351*4882a593Smuzhiyun  */
352*4882a593Smuzhiyun unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan);
353*4882a593Smuzhiyun 
354*4882a593Smuzhiyun /**
355*4882a593Smuzhiyun  * iio_read_channel_ext_info() - read ext_info attribute from a given channel
356*4882a593Smuzhiyun  * @chan:		The channel being queried.
357*4882a593Smuzhiyun  * @attr:		The ext_info attribute to read.
358*4882a593Smuzhiyun  * @buf:		Where to store the attribute value. Assumed to hold
359*4882a593Smuzhiyun  *			at least PAGE_SIZE bytes.
360*4882a593Smuzhiyun  *
361*4882a593Smuzhiyun  * Returns the number of bytes written to buf (perhaps w/o zero termination;
362*4882a593Smuzhiyun  * it need not even be a string), or an error code.
363*4882a593Smuzhiyun  */
364*4882a593Smuzhiyun ssize_t iio_read_channel_ext_info(struct iio_channel *chan,
365*4882a593Smuzhiyun 				  const char *attr, char *buf);
366*4882a593Smuzhiyun 
367*4882a593Smuzhiyun /**
368*4882a593Smuzhiyun  * iio_write_channel_ext_info() - write ext_info attribute from a given channel
369*4882a593Smuzhiyun  * @chan:		The channel being queried.
370*4882a593Smuzhiyun  * @attr:		The ext_info attribute to read.
371*4882a593Smuzhiyun  * @buf:		The new attribute value. Strings needs to be zero-
372*4882a593Smuzhiyun  *			terminated, but the terminator should not be included
373*4882a593Smuzhiyun  *			in the below len.
374*4882a593Smuzhiyun  * @len:		The size of the new attribute value.
375*4882a593Smuzhiyun  *
376*4882a593Smuzhiyun  * Returns the number of accepted bytes, which should be the same as len.
377*4882a593Smuzhiyun  * An error code can also be returned.
378*4882a593Smuzhiyun  */
379*4882a593Smuzhiyun ssize_t iio_write_channel_ext_info(struct iio_channel *chan, const char *attr,
380*4882a593Smuzhiyun 				   const char *buf, size_t len);
381*4882a593Smuzhiyun 
382*4882a593Smuzhiyun #endif
383