staging:iio:find iio channel from scan index util function
authorJonathan Cameron <jic23@cam.ac.uk>
Mon, 5 Dec 2011 21:37:10 +0000 (21:37 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 8 Dec 2011 19:36:10 +0000 (11:36 -0800)
Useful for getting to the channel based on scan mask alone.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/iio.h
drivers/staging/iio/industrialio-core.c

index 4aed915e90608f21666b03651590660d1f13d436..95d6318a14b49e40f102c89be0c5dbc768abf275 100644 (file)
@@ -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
index d8cd9e3c07a6e1d3a32b5b8724a9460c3c0ed652..dbd1ce1ce7e9df69ec81d2a977953cb0345088ca 100644 (file)
@@ -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