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