[PATCH v2 7/9] iio: common: cros_ec_sensors: simplify timestamp channel definition

From: David Lechner

Date: Sun May 24 2026 - 21:42:44 EST


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.

Also drop obvious comment while we're at it.

Signed-off-by: David Lechner <dlechner@xxxxxxxxxxxx>
---
drivers/iio/common/cros_ec_sensors/cros_ec_activity.c | 8 +-------
drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 8 +-------
2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_activity.c b/drivers/iio/common/cros_ec_sensors/cros_ec_activity.c
index 6e38d115b6fe..6762685e6876 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_activity.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_activity.c
@@ -279,13 +279,7 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)
channel++;
}

- /* Timestamp */
- channel->scan_index = index;
- channel->type = IIO_TIMESTAMP;
- channel->channel = -1;
- channel->scan_type.sign = 's';
- channel->scan_type.realbits = 64;
- channel->scan_type.storagebits = 64;
+ *channel = IIO_CHAN_SOFT_TIMESTAMP(index);

indio_dev->channels = st->channels;
indio_dev->num_channels = index + 1;
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index f34e2bbba2d1..651632ccfe0d 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -279,13 +279,7 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)
}
}

- /* Timestamp */
- channel->type = IIO_TIMESTAMP;
- channel->channel = -1;
- channel->scan_index = CROS_EC_SENSOR_MAX_AXIS;
- channel->scan_type.sign = 's';
- channel->scan_type.realbits = 64;
- channel->scan_type.storagebits = 64;
+ *channel = IIO_CHAN_SOFT_TIMESTAMP(CROS_EC_SENSOR_MAX_AXIS);

indio_dev->channels = state->channels;
indio_dev->num_channels = CROS_EC_SENSORS_MAX_CHANNELS;

--
2.43.0