Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5c5b3f3 authored by Nicholas Troast's avatar Nicholas Troast Committed by David Collins
Browse files

iio: support writing processed values to IIO channels



Add a new function to the IIO API which allows consumers to write
processed values to IIO channels.

This is particularly useful for supporting hardware which has
configurable ADC thresholds. A consumer would be able to change an ADC
threshold by providing a processed value instead of calculating a raw
value.

Change-Id: I7d3b22beddb6fd1fda0cc0aefbcb4cf5cb58bf82
Signed-off-by: default avatarNicholas Troast <ntroast@codeaurora.org>
parent 60f54592
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -746,3 +746,21 @@ int iio_write_channel_raw(struct iio_channel *chan, int val)
	return ret;
}
EXPORT_SYMBOL_GPL(iio_write_channel_raw);

int iio_write_channel_processed(struct iio_channel *chan, int val)
{
	int ret;

	mutex_lock(&chan->indio_dev->info_exist_lock);
	if (chan->indio_dev->info == NULL) {
		ret = -ENODEV;
		goto err_unlock;
	}

	ret = iio_channel_write(chan, val, 0, IIO_CHAN_INFO_PROCESSED);
err_unlock:
	mutex_unlock(&chan->indio_dev->info_exist_lock);

	return ret;
}
EXPORT_SYMBOL_GPL(iio_write_channel_processed);
+10 −0
Original line number Diff line number Diff line
@@ -225,6 +225,16 @@ int iio_read_channel_processed(struct iio_channel *chan, int *val);
 */
int iio_write_channel_raw(struct iio_channel *chan, int val);

/**
 * iio_write_channel_processed() - write to a given channel
 * @chan:		The channel being queried.
 * @val:		Value being written.
 *
 * Note processed writes to iio channels are converted to raw
 * values before being written.
 */
int iio_write_channel_processed(struct iio_channel *chan, int val);

/**
 * iio_get_channel_type() - get the type of a channel
 * @channel:		The channel being queried.