diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2016-04-06 16:01:07 +0530 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2016-04-19 19:58:15 +0100 |
commit | efc2c0133f198bc65593a67015af358919b0c48f (patch) | |
tree | a5559eed375f002c6ed912abd05c79e73f4bb7c4 /include/linux/iio | |
parent | 8bf872d8d261feefcdf67027522e3f717cad2bfe (diff) | |
download | linux-stable-efc2c0133f198bc65593a67015af358919b0c48f.tar.gz linux-stable-efc2c0133f198bc65593a67015af358919b0c48f.tar.bz2 linux-stable-efc2c0133f198bc65593a67015af358919b0c48f.zip |
iio: core: Add devm_ APIs for iio_channel_{get,release}_all
Some of kernel driver uses the IIO framework to get the sensor
value via ADC or IIO HW driver. The client driver get iio channel
by iio_channel_get_all() and release it by calling
iio_channel_release_all().
Add resource managed version (devm_*) of these APIs so that if client
calls the devm_iio_channel_get_all() then it need not to release it
explicitly, it can be done by managed device framework when driver
get un-binded.
This reduces the code in error path and also need of .remove callback in
some cases.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'include/linux/iio')
-rw-r--r-- | include/linux/iio/consumer.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index e1e033d6a81f..3d672f72e7ec 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h @@ -92,6 +92,32 @@ struct iio_channel *iio_channel_get_all(struct device *dev); */ void iio_channel_release_all(struct iio_channel *chan); +/** + * devm_iio_channel_get_all() - Resource managed version of + * iio_channel_get_all(). + * @dev: Pointer to consumer device. + * + * Returns a pointer to negative errno if it is not able to get the iio channel + * otherwise returns an array of iio_channel structures terminated with one with + * null iio_dev pointer. + * + * This function is used by fairly generic consumers to get all the + * channels registered as having this consumer. + * + * The allocated iio channels are automatically released when the device is + * unbounded. + */ +struct iio_channel *devm_iio_channel_get_all(struct device *dev); + +/** + * devm_iio_channel_release_all() - Resource managed version of + * iio_channel_release_all(). + * @dev: Pointer to consumer device for which resource + * is allocared. + * @chan: Array channel to be released. + */ +void devm_iio_channel_release_all(struct device *dev, struct iio_channel *chan); + struct iio_cb_buffer; /** * iio_channel_get_all_cb() - register callback for triggered capture |