From: David Lechner Date: Mon, 25 May 2026 01:38:34 +0000 (-0500) Subject: iio: common: scmi_sensors: simplify timestamp channel definition X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c73b6d7f0b7f2b2279134746cbacbb880222f374;p=thirdparty%2Flinux.git iio: common: scmi_sensors: simplify timestamp channel definition 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 Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c index 5136ad9ada040..442b40ef27cf5 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; }