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

Commit a54f83c3 authored by Nicholas Troast's avatar Nicholas Troast Committed by Harry Yang
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 a331def2
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -927,3 +927,21 @@ ssize_t iio_write_channel_ext_info(struct iio_channel *chan, const char *attr,
			       chan->channel, buf, len);
}
EXPORT_SYMBOL_GPL(iio_write_channel_ext_info);

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(iio_write_channel_processed);
+9 −0
Original line number Diff line number Diff line
@@ -252,6 +252,15 @@ int iio_read_max_channel_raw(struct iio_channel *chan, int *val);
 */
int iio_read_avail_channel_raw(struct iio_channel *chan,
			       const int **vals, int *length);
/**
 * 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