Skip to content

Commit c73b6d7

Browse files
dlechjic23
authored andcommitted
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 <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 8a2f9c4 commit c73b6d7

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

drivers/iio/common/scmi_sensors/scmi_iio.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -419,17 +419,6 @@ static const struct iio_chan_spec_ext_info scmi_iio_ext_info[] = {
419419
{ }
420420
};
421421

422-
static void scmi_iio_set_timestamp_channel(struct iio_chan_spec *iio_chan,
423-
int scan_index)
424-
{
425-
iio_chan->type = IIO_TIMESTAMP;
426-
iio_chan->channel = -1;
427-
iio_chan->scan_index = scan_index;
428-
iio_chan->scan_type.sign = 'u';
429-
iio_chan->scan_type.realbits = 64;
430-
iio_chan->scan_type.storagebits = 64;
431-
}
432-
433422
static void scmi_iio_set_data_channel(struct iio_chan_spec *iio_chan,
434423
enum iio_chan_type type,
435424
enum iio_modifier mod, int scan_index)
@@ -629,7 +618,7 @@ scmi_alloc_iiodev(struct scmi_device *sdev,
629618
"Error in registering sensor update notifier for sensor %s\n",
630619
sensor->sensor_info->name);
631620

632-
scmi_iio_set_timestamp_channel(&iio_channels[i], i);
621+
iio_channels[i] = IIO_CHAN_SOFT_TIMESTAMP(i);
633622
iiodev->channels = iio_channels;
634623
return iiodev;
635624
}

0 commit comments

Comments
 (0)