[PATCH v2 2/9] iio: common: scmi_sensors: simplify timestamp channel definition
David Lechner
dlechner at baylibre.com
Sun May 24 18:38:34 PDT 2026
Use IIO_CHAN_SOFT_TIMESTAMP() to define the timestamp channel instead of
manually filling in the struct iio_chan_spec fields. This makes the code
less verbose and mistake-prone.
In fact, there was an error here as the sign should be 's' instead of
'u' which is now changed to 's' by using IIO_CHAN_SOFT_TIMESTAMP().
If we find that this breaks userspace, we will have to revert this
change, but seems unlikely since the timestamp channel is well-known to
be a signed 64-bit integer globally.
Signed-off-by: David Lechner <dlechner at baylibre.com>
---
drivers/iio/common/scmi_sensors/scmi_iio.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c
index 5136ad9ada04..442b40ef27cf 100644
--- a/drivers/iio/common/scmi_sensors/scmi_iio.c
+++ b/drivers/iio/common/scmi_sensors/scmi_iio.c
@@ -419,17 +419,6 @@ static const struct iio_chan_spec_ext_info scmi_iio_ext_info[] = {
{ }
};
-static void scmi_iio_set_timestamp_channel(struct iio_chan_spec *iio_chan,
- int scan_index)
-{
- iio_chan->type = IIO_TIMESTAMP;
- iio_chan->channel = -1;
- iio_chan->scan_index = scan_index;
- iio_chan->scan_type.sign = 'u';
- iio_chan->scan_type.realbits = 64;
- iio_chan->scan_type.storagebits = 64;
-}
-
static void scmi_iio_set_data_channel(struct iio_chan_spec *iio_chan,
enum iio_chan_type type,
enum iio_modifier mod, int scan_index)
@@ -629,7 +618,7 @@ scmi_alloc_iiodev(struct scmi_device *sdev,
"Error in registering sensor update notifier for sensor %s\n",
sensor->sensor_info->name);
- scmi_iio_set_timestamp_channel(&iio_channels[i], i);
+ iio_channels[i] = IIO_CHAN_SOFT_TIMESTAMP(i);
iiodev->channels = iio_channels;
return iiodev;
}
--
2.43.0
More information about the linux-arm-kernel
mailing list