1 // SPDX-License-Identifier: GPL-2.0-only
2 /* The industrial I/O core in kernel channel mapping
4 * Copyright (c) 2011 Jonathan Cameron
7 #include <linux/export.h>
8 #include <linux/property.h>
9 #include <linux/slab.h>
10 #include <linux/mutex.h>
12 #include <linux/iio/iio.h>
13 #include <linux/iio/iio-opaque.h>
15 #include <linux/iio/machine.h>
16 #include <linux/iio/driver.h>
17 #include <linux/iio/consumer.h>
19 struct iio_map_internal {
20 struct iio_dev *indio_dev;
25 static LIST_HEAD(iio_map_list);
26 static DEFINE_MUTEX(iio_map_list_lock);
28 static int iio_map_array_unregister_locked(struct iio_dev *indio_dev)
31 struct iio_map_internal *mapi, *next;
33 list_for_each_entry_safe(mapi, next, &iio_map_list, l) {
34 if (indio_dev == mapi->indio_dev) {
43 int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
46 struct iio_map_internal *mapi;
51 mutex_lock(&iio_map_list_lock);
52 while (maps[i].consumer_dev_name) {
53 mapi = kzalloc(sizeof(*mapi), GFP_KERNEL);
59 mapi->indio_dev = indio_dev;
60 list_add_tail(&mapi->l, &iio_map_list);
65 iio_map_array_unregister_locked(indio_dev);
66 mutex_unlock(&iio_map_list_lock);
70 EXPORT_SYMBOL_GPL(iio_map_array_register);
73 * Remove all map entries associated with the given iio device
75 int iio_map_array_unregister(struct iio_dev *indio_dev)
79 mutex_lock(&iio_map_list_lock);
80 ret = iio_map_array_unregister_locked(indio_dev);
81 mutex_unlock(&iio_map_list_lock);
85 EXPORT_SYMBOL_GPL(iio_map_array_unregister);
87 static void iio_map_array_unregister_cb(void *indio_dev)
89 iio_map_array_unregister(indio_dev);
92 int devm_iio_map_array_register(struct device *dev, struct iio_dev *indio_dev, struct iio_map *maps)
96 ret = iio_map_array_register(indio_dev, maps);
100 return devm_add_action_or_reset(dev, iio_map_array_unregister_cb, indio_dev);
102 EXPORT_SYMBOL_GPL(devm_iio_map_array_register);
104 static const struct iio_chan_spec
105 *iio_chan_spec_from_name(const struct iio_dev *indio_dev, const char *name)
108 const struct iio_chan_spec *chan = NULL;
110 for (i = 0; i < indio_dev->num_channels; i++)
111 if (indio_dev->channels[i].datasheet_name &&
112 strcmp(name, indio_dev->channels[i].datasheet_name) == 0) {
113 chan = &indio_dev->channels[i];
120 * __fwnode_iio_simple_xlate - translate iiospec to the IIO channel index
121 * @indio_dev: pointer to the iio_dev structure
122 * @iiospec: IIO specifier as found in the device tree
124 * This is simple translation function, suitable for the most 1:1 mapped
125 * channels in IIO chips. This function performs only one sanity check:
126 * whether IIO index is less than num_channels (that is specified in the
129 static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
130 const struct fwnode_reference_args *iiospec)
135 if (iiospec->args[0] >= indio_dev->num_channels) {
136 dev_err(&indio_dev->dev, "invalid channel index %llu\n",
141 return iiospec->args[0];
144 static int __fwnode_iio_channel_get(struct iio_channel *channel,
145 struct fwnode_handle *fwnode, int index)
147 struct fwnode_reference_args iiospec;
149 struct iio_dev *indio_dev;
152 err = fwnode_property_get_reference_args(fwnode, "io-channels",
153 "#io-channel-cells", 0,
158 idev = bus_find_device_by_fwnode(&iio_bus_type, iiospec.fwnode);
160 fwnode_handle_put(iiospec.fwnode);
161 return -EPROBE_DEFER;
164 indio_dev = dev_to_iio_dev(idev);
165 channel->indio_dev = indio_dev;
166 if (indio_dev->info->fwnode_xlate)
167 index = indio_dev->info->fwnode_xlate(indio_dev, &iiospec);
169 index = __fwnode_iio_simple_xlate(indio_dev, &iiospec);
170 fwnode_handle_put(iiospec.fwnode);
173 channel->channel = &indio_dev->channels[index];
178 iio_device_put(indio_dev);
182 static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
185 struct iio_channel *channel;
189 return ERR_PTR(-EINVAL);
191 channel = kzalloc(sizeof(*channel), GFP_KERNEL);
193 return ERR_PTR(-ENOMEM);
195 err = __fwnode_iio_channel_get(channel, fwnode, index);
197 goto err_free_channel;
206 static struct iio_channel *
207 __fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode, const char *name)
209 struct iio_channel *chan;
213 * For named iio channels, first look up the name in the
214 * "io-channel-names" property. If it cannot be found, the
215 * index will be an error code, and fwnode_iio_channel_get()
219 index = fwnode_property_match_string(fwnode, "io-channel-names",
222 chan = fwnode_iio_channel_get(fwnode, index);
223 if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
227 pr_err("ERROR: could not get IIO channel %pfw:%s(%i)\n",
228 fwnode, name, index);
230 * In this case, we found 'name' in 'io-channel-names'
231 * but somehow we still fail so that we should not proceed
232 * with any other lookup. Hence, explicitly return -EINVAL
233 * (maybe not the better error code) so that the caller
234 * won't do a system lookup.
236 return ERR_PTR(-EINVAL);
239 * If index < 0, then fwnode_property_get_reference_args() fails
240 * with -EINVAL or -ENOENT (ACPI case) which is expected. We
241 * should not proceed if we get any other error.
243 if (PTR_ERR(chan) != -EINVAL && PTR_ERR(chan) != -ENOENT)
245 } else if (PTR_ERR(chan) != -ENOENT) {
247 * if !name, then we should only proceed the lookup if
248 * fwnode_property_get_reference_args() returns -ENOENT.
253 /* so we continue the lookup */
254 return ERR_PTR(-ENODEV);
257 struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
260 struct fwnode_handle *parent;
261 struct iio_channel *chan;
263 /* Walk up the tree of devices looking for a matching iio channel */
264 chan = __fwnode_iio_channel_get_by_name(fwnode, name);
265 if (!IS_ERR(chan) || PTR_ERR(chan) != -ENODEV)
269 * No matching IIO channel found on this node.
270 * If the parent node has a "io-channel-ranges" property,
271 * then we can try one of its channels.
273 fwnode_for_each_parent_node(fwnode, parent) {
274 if (!fwnode_property_present(parent, "io-channel-ranges")) {
275 fwnode_handle_put(parent);
276 return ERR_PTR(-ENODEV);
279 chan = __fwnode_iio_channel_get_by_name(fwnode, name);
280 if (!IS_ERR(chan) || PTR_ERR(chan) != -ENODEV) {
281 fwnode_handle_put(parent);
286 return ERR_PTR(-ENODEV);
288 EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);
290 static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
292 struct fwnode_handle *fwnode = dev_fwnode(dev);
293 struct iio_channel *chans;
294 int i, mapind, nummaps = 0;
298 ret = fwnode_property_get_reference_args(fwnode, "io-channels",
299 "#io-channel-cells", 0,
306 return ERR_PTR(-ENODEV);
308 /* NULL terminated array to save passing size */
309 chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
311 return ERR_PTR(-ENOMEM);
313 /* Search for FW matches */
314 for (mapind = 0; mapind < nummaps; mapind++) {
315 ret = __fwnode_iio_channel_get(&chans[mapind], fwnode, mapind);
317 goto error_free_chans;
322 for (i = 0; i < mapind; i++)
323 iio_device_put(chans[i].indio_dev);
328 static struct iio_channel *iio_channel_get_sys(const char *name,
329 const char *channel_name)
331 struct iio_map_internal *c_i = NULL, *c = NULL;
332 struct iio_channel *channel;
335 if (!(name || channel_name))
336 return ERR_PTR(-ENODEV);
338 /* first find matching entry the channel map */
339 mutex_lock(&iio_map_list_lock);
340 list_for_each_entry(c_i, &iio_map_list, l) {
341 if ((name && strcmp(name, c_i->map->consumer_dev_name) != 0) ||
343 strcmp(channel_name, c_i->map->consumer_channel) != 0))
346 iio_device_get(c->indio_dev);
349 mutex_unlock(&iio_map_list_lock);
351 return ERR_PTR(-ENODEV);
353 channel = kzalloc(sizeof(*channel), GFP_KERNEL);
359 channel->indio_dev = c->indio_dev;
361 if (c->map->adc_channel_label) {
363 iio_chan_spec_from_name(channel->indio_dev,
364 c->map->adc_channel_label);
366 if (!channel->channel) {
377 iio_device_put(c->indio_dev);
381 struct iio_channel *iio_channel_get(struct device *dev,
382 const char *channel_name)
384 const char *name = dev ? dev_name(dev) : NULL;
385 struct iio_channel *channel;
388 channel = fwnode_iio_channel_get_by_name(dev_fwnode(dev),
390 if (!IS_ERR(channel) || PTR_ERR(channel) != -ENODEV)
394 return iio_channel_get_sys(name, channel_name);
396 EXPORT_SYMBOL_GPL(iio_channel_get);
398 void iio_channel_release(struct iio_channel *channel)
402 iio_device_put(channel->indio_dev);
405 EXPORT_SYMBOL_GPL(iio_channel_release);
407 static void devm_iio_channel_free(void *iio_channel)
409 iio_channel_release(iio_channel);
412 struct iio_channel *devm_iio_channel_get(struct device *dev,
413 const char *channel_name)
415 struct iio_channel *channel;
418 channel = iio_channel_get(dev, channel_name);
422 ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
428 EXPORT_SYMBOL_GPL(devm_iio_channel_get);
430 struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
431 struct fwnode_handle *fwnode,
432 const char *channel_name)
434 struct iio_channel *channel;
437 channel = fwnode_iio_channel_get_by_name(fwnode, channel_name);
441 ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
447 EXPORT_SYMBOL_GPL(devm_fwnode_iio_channel_get_by_name);
449 struct iio_channel *iio_channel_get_all(struct device *dev)
452 struct iio_channel *chans;
453 struct iio_map_internal *c = NULL;
459 return ERR_PTR(-EINVAL);
461 chans = fwnode_iio_channel_get_all(dev);
463 * We only want to carry on if the error is -ENODEV. Anything else
464 * should be reported up the stack.
466 if (!IS_ERR(chans) || PTR_ERR(chans) != -ENODEV)
469 name = dev_name(dev);
471 mutex_lock(&iio_map_list_lock);
472 /* first count the matching maps */
473 list_for_each_entry(c, &iio_map_list, l)
474 if (name && strcmp(name, c->map->consumer_dev_name) != 0)
484 /* NULL terminated array to save passing size */
485 chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
491 /* for each map fill in the chans element */
492 list_for_each_entry(c, &iio_map_list, l) {
493 if (name && strcmp(name, c->map->consumer_dev_name) != 0)
495 chans[mapind].indio_dev = c->indio_dev;
496 chans[mapind].data = c->map->consumer_data;
497 chans[mapind].channel =
498 iio_chan_spec_from_name(chans[mapind].indio_dev,
499 c->map->adc_channel_label);
500 if (!chans[mapind].channel) {
502 goto error_free_chans;
504 iio_device_get(chans[mapind].indio_dev);
509 goto error_free_chans;
511 mutex_unlock(&iio_map_list_lock);
516 for (i = 0; i < nummaps; i++)
517 iio_device_put(chans[i].indio_dev);
520 mutex_unlock(&iio_map_list_lock);
524 EXPORT_SYMBOL_GPL(iio_channel_get_all);
526 void iio_channel_release_all(struct iio_channel *channels)
528 struct iio_channel *chan = &channels[0];
530 while (chan->indio_dev) {
531 iio_device_put(chan->indio_dev);
536 EXPORT_SYMBOL_GPL(iio_channel_release_all);
538 static void devm_iio_channel_free_all(void *iio_channels)
540 iio_channel_release_all(iio_channels);
543 struct iio_channel *devm_iio_channel_get_all(struct device *dev)
545 struct iio_channel *channels;
548 channels = iio_channel_get_all(dev);
549 if (IS_ERR(channels))
552 ret = devm_add_action_or_reset(dev, devm_iio_channel_free_all,
559 EXPORT_SYMBOL_GPL(devm_iio_channel_get_all);
561 static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
562 enum iio_chan_info_enum info)
565 int vals[INDIO_MAX_RAW_ELEMENTS];
572 if (!iio_channel_has_info(chan->channel, info))
575 if (chan->indio_dev->info->read_raw_multi) {
576 ret = chan->indio_dev->info->read_raw_multi(chan->indio_dev,
577 chan->channel, INDIO_MAX_RAW_ELEMENTS,
578 vals, &val_len, info);
582 ret = chan->indio_dev->info->read_raw(chan->indio_dev,
583 chan->channel, val, val2, info);
589 int iio_read_channel_raw(struct iio_channel *chan, int *val)
591 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
594 mutex_lock(&iio_dev_opaque->info_exist_lock);
595 if (!chan->indio_dev->info) {
600 ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_RAW);
602 mutex_unlock(&iio_dev_opaque->info_exist_lock);
606 EXPORT_SYMBOL_GPL(iio_read_channel_raw);
608 int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
610 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
613 mutex_lock(&iio_dev_opaque->info_exist_lock);
614 if (!chan->indio_dev->info) {
619 ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_AVERAGE_RAW);
621 mutex_unlock(&iio_dev_opaque->info_exist_lock);
625 EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
627 static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
628 int raw, int *processed,
631 int scale_type, scale_val, scale_val2;
632 int offset_type, offset_val, offset_val2;
635 offset_type = iio_channel_read(chan, &offset_val, &offset_val2,
636 IIO_CHAN_INFO_OFFSET);
637 if (offset_type >= 0) {
638 switch (offset_type) {
641 case IIO_VAL_INT_PLUS_MICRO:
642 case IIO_VAL_INT_PLUS_NANO:
644 * Both IIO_VAL_INT_PLUS_MICRO and IIO_VAL_INT_PLUS_NANO
645 * implicitely truncate the offset to it's integer form.
648 case IIO_VAL_FRACTIONAL:
649 offset_val /= offset_val2;
651 case IIO_VAL_FRACTIONAL_LOG2:
652 offset_val >>= offset_val2;
661 scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
662 IIO_CHAN_INFO_SCALE);
663 if (scale_type < 0) {
665 * If no channel scaling is available apply consumer scale to
666 * raw value and return.
668 *processed = raw * scale;
672 switch (scale_type) {
674 *processed = raw64 * scale_val * scale;
676 case IIO_VAL_INT_PLUS_MICRO:
678 *processed = -raw64 * scale_val;
680 *processed = raw64 * scale_val;
681 *processed += div_s64(raw64 * (s64)scale_val2 * scale,
684 case IIO_VAL_INT_PLUS_NANO:
686 *processed = -raw64 * scale_val;
688 *processed = raw64 * scale_val;
689 *processed += div_s64(raw64 * (s64)scale_val2 * scale,
692 case IIO_VAL_FRACTIONAL:
693 *processed = div_s64(raw64 * (s64)scale_val * scale,
696 case IIO_VAL_FRACTIONAL_LOG2:
697 *processed = (raw64 * (s64)scale_val * scale) >> scale_val2;
706 int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
707 int *processed, unsigned int scale)
709 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
712 mutex_lock(&iio_dev_opaque->info_exist_lock);
713 if (!chan->indio_dev->info) {
718 ret = iio_convert_raw_to_processed_unlocked(chan, raw, processed,
721 mutex_unlock(&iio_dev_opaque->info_exist_lock);
725 EXPORT_SYMBOL_GPL(iio_convert_raw_to_processed);
727 int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2,
728 enum iio_chan_info_enum attribute)
730 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
733 mutex_lock(&iio_dev_opaque->info_exist_lock);
734 if (!chan->indio_dev->info) {
739 ret = iio_channel_read(chan, val, val2, attribute);
741 mutex_unlock(&iio_dev_opaque->info_exist_lock);
745 EXPORT_SYMBOL_GPL(iio_read_channel_attribute);
747 int iio_read_channel_offset(struct iio_channel *chan, int *val, int *val2)
749 return iio_read_channel_attribute(chan, val, val2, IIO_CHAN_INFO_OFFSET);
751 EXPORT_SYMBOL_GPL(iio_read_channel_offset);
753 int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
756 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
759 mutex_lock(&iio_dev_opaque->info_exist_lock);
760 if (!chan->indio_dev->info) {
765 if (iio_channel_has_info(chan->channel, IIO_CHAN_INFO_PROCESSED)) {
766 ret = iio_channel_read(chan, val, NULL,
767 IIO_CHAN_INFO_PROCESSED);
772 ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_RAW);
775 ret = iio_convert_raw_to_processed_unlocked(chan, *val, val,
780 mutex_unlock(&iio_dev_opaque->info_exist_lock);
784 EXPORT_SYMBOL_GPL(iio_read_channel_processed_scale);
786 int iio_read_channel_processed(struct iio_channel *chan, int *val)
788 /* This is just a special case with scale factor 1 */
789 return iio_read_channel_processed_scale(chan, val, 1);
791 EXPORT_SYMBOL_GPL(iio_read_channel_processed);
793 int iio_read_channel_scale(struct iio_channel *chan, int *val, int *val2)
795 return iio_read_channel_attribute(chan, val, val2, IIO_CHAN_INFO_SCALE);
797 EXPORT_SYMBOL_GPL(iio_read_channel_scale);
799 static int iio_channel_read_avail(struct iio_channel *chan,
800 const int **vals, int *type, int *length,
801 enum iio_chan_info_enum info)
803 if (!iio_channel_has_available(chan->channel, info))
806 return chan->indio_dev->info->read_avail(chan->indio_dev, chan->channel,
807 vals, type, length, info);
810 int iio_read_avail_channel_attribute(struct iio_channel *chan,
811 const int **vals, int *type, int *length,
812 enum iio_chan_info_enum attribute)
814 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
817 mutex_lock(&iio_dev_opaque->info_exist_lock);
818 if (!chan->indio_dev->info) {
823 ret = iio_channel_read_avail(chan, vals, type, length, attribute);
825 mutex_unlock(&iio_dev_opaque->info_exist_lock);
829 EXPORT_SYMBOL_GPL(iio_read_avail_channel_attribute);
831 int iio_read_avail_channel_raw(struct iio_channel *chan,
832 const int **vals, int *length)
837 ret = iio_read_avail_channel_attribute(chan, vals, &type, length,
840 if (ret >= 0 && type != IIO_VAL_INT)
841 /* raw values are assumed to be IIO_VAL_INT */
846 EXPORT_SYMBOL_GPL(iio_read_avail_channel_raw);
848 static int iio_channel_read_max(struct iio_channel *chan,
849 int *val, int *val2, int *type,
850 enum iio_chan_info_enum info)
860 ret = iio_channel_read_avail(chan, &vals, type, &length, info);
862 case IIO_AVAIL_RANGE:
878 *val = vals[--length];
880 if (vals[--length] > *val)
885 /* FIXME: learn about max for other iio values */
895 int iio_read_max_channel_raw(struct iio_channel *chan, int *val)
897 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
901 mutex_lock(&iio_dev_opaque->info_exist_lock);
902 if (!chan->indio_dev->info) {
907 ret = iio_channel_read_max(chan, val, NULL, &type, IIO_CHAN_INFO_RAW);
909 mutex_unlock(&iio_dev_opaque->info_exist_lock);
913 EXPORT_SYMBOL_GPL(iio_read_max_channel_raw);
915 int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type)
917 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
919 /* Need to verify underlying driver has not gone away */
921 mutex_lock(&iio_dev_opaque->info_exist_lock);
922 if (!chan->indio_dev->info) {
927 *type = chan->channel->type;
929 mutex_unlock(&iio_dev_opaque->info_exist_lock);
933 EXPORT_SYMBOL_GPL(iio_get_channel_type);
935 static int iio_channel_write(struct iio_channel *chan, int val, int val2,
936 enum iio_chan_info_enum info)
938 return chan->indio_dev->info->write_raw(chan->indio_dev,
939 chan->channel, val, val2, info);
942 int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2,
943 enum iio_chan_info_enum attribute)
945 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
948 mutex_lock(&iio_dev_opaque->info_exist_lock);
949 if (!chan->indio_dev->info) {
954 ret = iio_channel_write(chan, val, val2, attribute);
956 mutex_unlock(&iio_dev_opaque->info_exist_lock);
960 EXPORT_SYMBOL_GPL(iio_write_channel_attribute);
962 int iio_write_channel_raw(struct iio_channel *chan, int val)
964 return iio_write_channel_attribute(chan, val, 0, IIO_CHAN_INFO_RAW);
966 EXPORT_SYMBOL_GPL(iio_write_channel_raw);
968 unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan)
970 const struct iio_chan_spec_ext_info *ext_info;
973 if (!chan->channel->ext_info)
976 for (ext_info = chan->channel->ext_info; ext_info->name; ext_info++)
981 EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count);
983 static const struct iio_chan_spec_ext_info *
984 iio_lookup_ext_info(const struct iio_channel *chan, const char *attr)
986 const struct iio_chan_spec_ext_info *ext_info;
988 if (!chan->channel->ext_info)
991 for (ext_info = chan->channel->ext_info; ext_info->name; ++ext_info) {
992 if (!strcmp(attr, ext_info->name))
999 ssize_t iio_read_channel_ext_info(struct iio_channel *chan,
1000 const char *attr, char *buf)
1002 const struct iio_chan_spec_ext_info *ext_info;
1004 ext_info = iio_lookup_ext_info(chan, attr);
1008 return ext_info->read(chan->indio_dev, ext_info->private,
1009 chan->channel, buf);
1011 EXPORT_SYMBOL_GPL(iio_read_channel_ext_info);
1013 ssize_t iio_write_channel_ext_info(struct iio_channel *chan, const char *attr,
1014 const char *buf, size_t len)
1016 const struct iio_chan_spec_ext_info *ext_info;
1018 ext_info = iio_lookup_ext_info(chan, attr);
1022 return ext_info->write(chan->indio_dev, ext_info->private,
1023 chan->channel, buf, len);
1025 EXPORT_SYMBOL_GPL(iio_write_channel_ext_info);