[PATCH RFC v4 6/6] iio: osf: register IIO devices from capabilities
From: Jinseob Kim
Date: Sun Jun 07 2026 - 19:46:59 EST
Clean up the IIO sample push path.
Drop the redundant temperature scan mask.
Signed-off-by: Jinseob Kim <kimjinseob88@xxxxxxxxx>
---
drivers/iio/opensensorfusion/osf_core.c | 9 +++++----
drivers/iio/opensensorfusion/osf_iio.c | 15 +++------------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/iio/opensensorfusion/osf_core.c b/drivers/iio/opensensorfusion/osf_core.c
index e0a12de01..61ef55646 100644
--- a/drivers/iio/opensensorfusion/osf_core.c
+++ b/drivers/iio/opensensorfusion/osf_core.c
@@ -293,10 +293,11 @@ int osf_core_read_latest_sample(struct osf_device *osf, u16 sensor_type,
latest->sensor_index != sensor_index)
continue;
- if (latest->valid && channel < latest->channel_count) {
- *value = latest->values[channel];
- ret = 0;
- }
+ if (!latest->valid || channel >= latest->channel_count)
+ break;
+
+ *value = latest->values[channel];
+ ret = 0;
break;
}
mutex_unlock(&osf->latest_lock);
diff --git a/drivers/iio/opensensorfusion/osf_iio.c b/drivers/iio/opensensorfusion/osf_iio.c
index 5e5099878..3da3f2bda 100644
--- a/drivers/iio/opensensorfusion/osf_iio.c
+++ b/drivers/iio/opensensorfusion/osf_iio.c
@@ -6,7 +6,6 @@
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/kfifo_buf.h>
-#include <linux/string.h>
#include <linux/types.h>
#include <linux/units.h>
@@ -89,10 +88,6 @@ static const unsigned long osf_3axis_available_scan_masks[] = {
0
};
-static const unsigned long osf_temp_available_scan_masks[] = {
- BIT(0),
- 0
-};
static const struct osf_iio_sensor_spec osf_iio_sensor_specs[] = {
{
@@ -125,7 +120,6 @@ static const struct osf_iio_sensor_spec osf_iio_sensor_specs[] = {
.name = "osf-temp",
.channels = osf_temp_channels,
.num_channels = ARRAY_SIZE(osf_temp_channels),
- .available_scan_masks = osf_temp_available_scan_masks,
},
};
@@ -265,21 +259,18 @@ int osf_iio_push_sample(struct iio_dev *indio_dev, const s32 *values,
unsigned int channel_count)
{
struct osf_iio_state *state = iio_priv(indio_dev);
- s32 scan[OSF_MAX_SAMPLE_CHANNELS] = { };
s64 timestamp;
if (channel_count != state->spec->channel_count)
return -EPROTO;
- memcpy(scan, values, channel_count * sizeof(*values));
-
- /* Buffer state can change here; IIO rechecks it during the push path. */
+ /* This is only a fast path; IIO rechecks buffer state while pushing. */
if (!iio_buffer_enabled(indio_dev))
return 0;
timestamp = iio_get_time_ns(indio_dev);
- return iio_push_to_buffers_with_ts_unaligned(indio_dev, scan,
- channel_count * sizeof(*scan),
+ return iio_push_to_buffers_with_ts_unaligned(indio_dev, values,
+ channel_count * sizeof(*values),
timestamp);
}
--
2.43.0