Loading drivers/iio/inkern.c +26 −13 Original line number Diff line number Diff line Loading @@ -658,6 +658,31 @@ int iio_convert_raw_to_processed(struct iio_channel *chan, int raw, } EXPORT_SYMBOL_GPL(iio_convert_raw_to_processed); static int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2, enum iio_chan_info_enum attribute) { int ret; mutex_lock(&chan->indio_dev->info_exist_lock); if (chan->indio_dev->info == NULL) { ret = -ENODEV; goto err_unlock; } ret = iio_channel_read(chan, val, val2, attribute); err_unlock: mutex_unlock(&chan->indio_dev->info_exist_lock); return ret; } int iio_read_channel_offset(struct iio_channel *chan, int *val, int *val2) { return iio_read_channel_attribute(chan, val, val2, IIO_CHAN_INFO_OFFSET); } EXPORT_SYMBOL_GPL(iio_read_channel_offset); int iio_read_channel_processed(struct iio_channel *chan, int *val) { int ret; Loading Loading @@ -687,19 +712,7 @@ EXPORT_SYMBOL_GPL(iio_read_channel_processed); int iio_read_channel_scale(struct iio_channel *chan, int *val, int *val2) { int ret; mutex_lock(&chan->indio_dev->info_exist_lock); if (chan->indio_dev->info == NULL) { ret = -ENODEV; goto err_unlock; } ret = iio_channel_read(chan, val, val2, IIO_CHAN_INFO_SCALE); err_unlock: mutex_unlock(&chan->indio_dev->info_exist_lock); return ret; return iio_read_channel_attribute(chan, val, val2, IIO_CHAN_INFO_SCALE); } EXPORT_SYMBOL_GPL(iio_read_channel_scale); Loading include/linux/iio/consumer.h +13 −0 Original line number Diff line number Diff line Loading @@ -235,6 +235,19 @@ int iio_write_channel_raw(struct iio_channel *chan, int val); int iio_get_channel_type(struct iio_channel *channel, enum iio_chan_type *type); /** * iio_read_channel_offset() - read the offset value for a channel * @chan: The channel being queried. * @val: First part of value read back. * @val2: Second part of value read back. * * Note returns a description of what is in val and val2, such * as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val * + val2/1e6 */ int iio_read_channel_offset(struct iio_channel *chan, int *val, int *val2); /** * iio_read_channel_scale() - read the scale value for a channel * @chan: The channel being queried. Loading Loading
drivers/iio/inkern.c +26 −13 Original line number Diff line number Diff line Loading @@ -658,6 +658,31 @@ int iio_convert_raw_to_processed(struct iio_channel *chan, int raw, } EXPORT_SYMBOL_GPL(iio_convert_raw_to_processed); static int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2, enum iio_chan_info_enum attribute) { int ret; mutex_lock(&chan->indio_dev->info_exist_lock); if (chan->indio_dev->info == NULL) { ret = -ENODEV; goto err_unlock; } ret = iio_channel_read(chan, val, val2, attribute); err_unlock: mutex_unlock(&chan->indio_dev->info_exist_lock); return ret; } int iio_read_channel_offset(struct iio_channel *chan, int *val, int *val2) { return iio_read_channel_attribute(chan, val, val2, IIO_CHAN_INFO_OFFSET); } EXPORT_SYMBOL_GPL(iio_read_channel_offset); int iio_read_channel_processed(struct iio_channel *chan, int *val) { int ret; Loading Loading @@ -687,19 +712,7 @@ EXPORT_SYMBOL_GPL(iio_read_channel_processed); int iio_read_channel_scale(struct iio_channel *chan, int *val, int *val2) { int ret; mutex_lock(&chan->indio_dev->info_exist_lock); if (chan->indio_dev->info == NULL) { ret = -ENODEV; goto err_unlock; } ret = iio_channel_read(chan, val, val2, IIO_CHAN_INFO_SCALE); err_unlock: mutex_unlock(&chan->indio_dev->info_exist_lock); return ret; return iio_read_channel_attribute(chan, val, val2, IIO_CHAN_INFO_SCALE); } EXPORT_SYMBOL_GPL(iio_read_channel_scale); Loading
include/linux/iio/consumer.h +13 −0 Original line number Diff line number Diff line Loading @@ -235,6 +235,19 @@ int iio_write_channel_raw(struct iio_channel *chan, int val); int iio_get_channel_type(struct iio_channel *channel, enum iio_chan_type *type); /** * iio_read_channel_offset() - read the offset value for a channel * @chan: The channel being queried. * @val: First part of value read back. * @val2: Second part of value read back. * * Note returns a description of what is in val and val2, such * as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val * + val2/1e6 */ int iio_read_channel_offset(struct iio_channel *chan, int *val, int *val2); /** * iio_read_channel_scale() - read the scale value for a channel * @chan: The channel being queried. Loading