From: Jonathan Cameron Date: Mon, 5 Dec 2011 21:37:10 +0000 (+0000) Subject: staging:iio:find iio channel from scan index util function X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5fb21c824e8ff22ae9361a789e8b845d72ae0557;p=mv-sheeva.git staging:iio:find iio channel from scan index util function Useful for getting to the channel based on scan mask alone. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 4aed915e906..95d6318a14b 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -322,6 +322,14 @@ struct iio_dev { int groupcounter; }; +/** + * iio_find_channel_from_si() - get channel from its scan index + * @indio_dev: device + * @si: scan index to match + */ +const struct iio_chan_spec +*iio_find_channel_from_si(struct iio_dev *indio_dev, int si); + /** * iio_device_register() - register a device with the IIO subsystem * @indio_dev: Device structure filled by the device driver diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index d8cd9e3c07a..dbd1ce1ce7e 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -89,6 +89,17 @@ static const char * const iio_chan_info_postfix[] = { = "filter_low_pass_3db_frequency", }; +const struct iio_chan_spec +*iio_find_channel_from_si(struct iio_dev *indio_dev, int si) +{ + int i; + + for (i = 0; i < indio_dev->num_channels; i++) + if (indio_dev->channels[i].scan_index == si) + return &indio_dev->channels[i]; + return NULL; +} + /** * struct iio_detected_event_list - list element for events that have occurred * @list: linked list header