]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: common: scmi_sensors: simplify timestamp channel definition
authorDavid Lechner <dlechner@baylibre.com>
Mon, 25 May 2026 01:38:34 +0000 (20:38 -0500)
committerJonathan Cameron <jic23@kernel.org>
Sun, 31 May 2026 10:01:48 +0000 (11:01 +0100)
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@baylibre.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/common/scmi_sensors/scmi_iio.c

index 5136ad9ada0409a9a76fc2ce0a415210734dc43c..442b40ef27cf515ca663abbba76ecb00bd51d4f4 100644 (file)
@@ -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;
 }