[PATCH 1/5] iio: backend: add support for decimation ratio set
From: Pop Ioan Daniel
Date: Mon Mar 24 2025 - 05:11:11 EST
Add backend support for setting the decimation ratio used.
Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@xxxxxxxxxx>
---
drivers/iio/industrialio-backend.c | 18 ++++++++++++++++++
include/linux/iio/backend.h | 3 +++
2 files changed, 21 insertions(+)
diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
index 363281272035..f4db6514944a 100644
--- a/drivers/iio/industrialio-backend.c
+++ b/drivers/iio/industrialio-backend.c
@@ -417,6 +417,24 @@ int iio_backend_test_pattern_set(struct iio_backend *back,
}
EXPORT_SYMBOL_NS_GPL(iio_backend_test_pattern_set, "IIO_BACKEND");
+/**
+ * iio_backend_set_dec_rate - set decimation ratio
+ * @back: Backend device
+ * @rate: Rate in decimal
+
+ * Return:
+ * 0 on success, negative error number on failure.
+ */
+
+int iio_backend_set_dec_rate(struct iio_backend *back, unsigned int rate)
+{
+ if (!rate)
+ return -EINVAL;
+
+ return iio_backend_op_call(back, set_dec_rate, rate);
+}
+EXPORT_SYMBOL_NS_GPL(iio_backend_set_dec_rate, "IIO_BACKEND");
+
/**
* iio_backend_chan_status - Get the channel status
* @back: Backend device
diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h
index 10be00f3b120..e73d7d265a16 100644
--- a/include/linux/iio/backend.h
+++ b/include/linux/iio/backend.h
@@ -80,6 +80,7 @@ enum iio_backend_sample_trigger {
* @data_source_set: Configure the data source for a specific channel.
* @set_sample_rate: Configure the sampling rate for a specific channel.
* @test_pattern_set: Configure a test pattern.
+ * @set_dec_rate: Set decimation ratio
* @chan_status: Get the channel status.
* @iodelay_set: Set digital I/O delay.
* @data_sample_trigger: Control when to sample data.
@@ -111,6 +112,7 @@ struct iio_backend_ops {
int (*test_pattern_set)(struct iio_backend *back,
unsigned int chan,
enum iio_backend_test_pattern pattern);
+ int (*set_dec_rate)(struct iio_backend *back, unsigned int rate);
int (*chan_status)(struct iio_backend *back, unsigned int chan,
bool *error);
int (*iodelay_set)(struct iio_backend *back, unsigned int chan,
@@ -167,6 +169,7 @@ int iio_backend_set_sampling_freq(struct iio_backend *back, unsigned int chan,
int iio_backend_test_pattern_set(struct iio_backend *back,
unsigned int chan,
enum iio_backend_test_pattern pattern);
+int iio_backend_set_dec_rate(struct iio_backend *back, unsigned int rate);
int iio_backend_chan_status(struct iio_backend *back, unsigned int chan,
bool *error);
int iio_backend_iodelay_set(struct iio_backend *back, unsigned int lane,
--
2.34.1