diff options
Diffstat (limited to 'drivers/iio/inkern.c')
-rw-r--r-- | drivers/iio/inkern.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 06ca3f7fcc44..2fb2314548e9 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -1,10 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0-only /* The industrial I/O core in kernel channel mapping * * Copyright (c) 2011 Jonathan Cameron - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. */ #include <linux/err.h> #include <linux/export.h> @@ -733,11 +730,11 @@ static int iio_channel_read_avail(struct iio_channel *chan, vals, type, length, info); } -int iio_read_avail_channel_raw(struct iio_channel *chan, - const int **vals, int *length) +int iio_read_avail_channel_attribute(struct iio_channel *chan, + const int **vals, int *type, int *length, + enum iio_chan_info_enum attribute) { int ret; - int type; mutex_lock(&chan->indio_dev->info_exist_lock); if (!chan->indio_dev->info) { @@ -745,11 +742,23 @@ int iio_read_avail_channel_raw(struct iio_channel *chan, goto err_unlock; } - ret = iio_channel_read_avail(chan, - vals, &type, length, IIO_CHAN_INFO_RAW); + ret = iio_channel_read_avail(chan, vals, type, length, attribute); err_unlock: mutex_unlock(&chan->indio_dev->info_exist_lock); + return ret; +} +EXPORT_SYMBOL_GPL(iio_read_avail_channel_attribute); + +int iio_read_avail_channel_raw(struct iio_channel *chan, + const int **vals, int *length) +{ + int ret; + int type; + + ret = iio_read_avail_channel_attribute(chan, vals, &type, length, + IIO_CHAN_INFO_RAW); + if (ret >= 0 && type != IIO_VAL_INT) /* raw values are assumed to be IIO_VAL_INT */ ret = -EINVAL; |