* [PATCH v2 0/9] iio: timestamp declaration cleanup
@ 2026-05-25 1:38 David Lechner
2026-05-25 1:38 ` [PATCH v2 1/9] iio: Convert IIO_CHAN_SOFT_TIMESTAMP() to be compound literal David Lechner
` (8 more replies)
0 siblings, 9 replies; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:38 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: linux-iio, linux-kernel, linux-arm-kernel, linux-stm32,
chrome-platform, David Lechner, Andy Shevchenko
While looking around the code, I noticed that there are a lot of places
were we are manually filling all of the fields of an IIO timestamp.
This is error-prone (as seen in the first patch) and more verbose than
it needs to be.
Thanks to Andy's patch, we can just make the macro a compound literal
so it can be used directly in assignments and initializers.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
Changes in v2:
- Include Andy's compound literal patch.
- Drop explicity compound literal in later patches.
- Link to v1: https://patch.msgid.link/20260517-iio-timestamp-cleanup-v1-0-61fb908c11c7@baylibre.com
---
Andy Shevchenko (1):
iio: Convert IIO_CHAN_SOFT_TIMESTAMP() to be compound literal
David Lechner (8):
iio: common: scmi_sensors: simplify timestamp channel definition
iio: adc: dln2-adc: simplify timestamp channel definition
iio: adc: at91_adc: simplify timestamp channel definition
iio: adc: cc10001_adc: simplify timestamp channel definition
iio: adc: stm32-adc: simplify timestamp channel definition
iio: common: cros_ec_sensors: simplify timestamp channel definition
iio: light: cros_ec_light_prox: simplify timestamp channel definition
iio: pressure: cros_ec_baro: simplify timestamp channel definition
drivers/iio/adc/ad7606.c | 2 +-
drivers/iio/adc/at91_adc.c | 12 +++---------
drivers/iio/adc/cc10001_adc.c | 10 ++--------
drivers/iio/adc/dln2-adc.c | 12 +-----------
drivers/iio/adc/max11410.c | 2 +-
drivers/iio/adc/stm32-adc.c | 10 +---------
drivers/iio/common/cros_ec_sensors/cros_ec_activity.c | 8 +-------
drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 8 +-------
drivers/iio/common/scmi_sensors/scmi_iio.c | 13 +------------
drivers/iio/light/cros_ec_light_prox.c | 8 +-------
drivers/iio/pressure/cros_ec_baro.c | 8 +-------
include/linux/iio/iio.h | 6 +++---
12 files changed, 17 insertions(+), 82 deletions(-)
---
base-commit: e1a29334a9c043defe7a9363fa76d399d3fdfbec
change-id: 20260517-iio-timestamp-cleanup-1ee82f081a70
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 1/9] iio: Convert IIO_CHAN_SOFT_TIMESTAMP() to be compound literal
2026-05-25 1:38 [PATCH v2 0/9] iio: timestamp declaration cleanup David Lechner
@ 2026-05-25 1:38 ` David Lechner
2026-05-25 1:38 ` [PATCH v2 2/9] iio: common: scmi_sensors: simplify timestamp channel definition David Lechner
` (7 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:38 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: linux-iio, linux-kernel, linux-arm-kernel, linux-stm32,
chrome-platform, David Lechner, Andy Shevchenko
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Currently IIO_CHAN_SOFT_TIMESTAMP() can only be used to fill the static
data. In some cases it would be convenient to use it as right value in
the assignment operation. But it can't be done as is, because compiler
has no clue about the data layout. Converting it to be a compound literal
allows the above mentioned usage.
While at it, tidy up the indentation.
We also have to change existing uses of compound literal at the same
time to avoid compiler errors.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: David Lechner <dlechner@baylibre.com> (fixed compile errors)
---
drivers/iio/adc/ad7606.c | 2 +-
drivers/iio/adc/max11410.c | 2 +-
include/linux/iio/iio.h | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index d9271894f091..cebb8ed8dcb1 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -1475,7 +1475,7 @@ static int ad7606_probe_channels(struct iio_dev *indio_dev)
}
if (slow_bus)
- channels[i] = (struct iio_chan_spec)IIO_CHAN_SOFT_TIMESTAMP(i);
+ channels[i] = IIO_CHAN_SOFT_TIMESTAMP(i);
indio_dev->channels = channels;
diff --git a/drivers/iio/adc/max11410.c b/drivers/iio/adc/max11410.c
index 69351f4f10bb..dc1b96356592 100644
--- a/drivers/iio/adc/max11410.c
+++ b/drivers/iio/adc/max11410.c
@@ -804,7 +804,7 @@ static int max11410_parse_channels(struct max11410_state *st,
chan_idx++;
}
- channels[chan_idx] = (struct iio_chan_spec)IIO_CHAN_SOFT_TIMESTAMP(chan_idx);
+ channels[chan_idx] = IIO_CHAN_SOFT_TIMESTAMP(chan_idx);
indio_dev->num_channels = chan_idx + 1;
indio_dev->channels = channels;
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 96b05c86c325..711c00f67371 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -353,15 +353,15 @@ static inline bool iio_channel_has_available(const struct iio_chan_spec *chan,
(chan->info_mask_shared_by_all_available & BIT(type));
}
-#define IIO_CHAN_SOFT_TIMESTAMP(_si) { \
+#define IIO_CHAN_SOFT_TIMESTAMP(_si) (struct iio_chan_spec) { \
.type = IIO_TIMESTAMP, \
.channel = -1, \
.scan_index = _si, \
.scan_type = { \
.sign = 's', \
- .realbits = 64, \
+ .realbits = 64, \
.storagebits = 64, \
- }, \
+ }, \
}
s64 iio_get_time_ns(const struct iio_dev *indio_dev);
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 2/9] iio: common: scmi_sensors: simplify timestamp channel definition
2026-05-25 1:38 [PATCH v2 0/9] iio: timestamp declaration cleanup David Lechner
2026-05-25 1:38 ` [PATCH v2 1/9] iio: Convert IIO_CHAN_SOFT_TIMESTAMP() to be compound literal David Lechner
@ 2026-05-25 1:38 ` David Lechner
2026-05-25 1:38 ` [PATCH v2 3/9] iio: adc: dln2-adc: " David Lechner
` (6 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:38 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: linux-iio, linux-kernel, linux-arm-kernel, linux-stm32,
chrome-platform, David Lechner
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>
---
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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 3/9] iio: adc: dln2-adc: simplify timestamp channel definition
2026-05-25 1:38 [PATCH v2 0/9] iio: timestamp declaration cleanup David Lechner
2026-05-25 1:38 ` [PATCH v2 1/9] iio: Convert IIO_CHAN_SOFT_TIMESTAMP() to be compound literal David Lechner
2026-05-25 1:38 ` [PATCH v2 2/9] iio: common: scmi_sensors: simplify timestamp channel definition David Lechner
@ 2026-05-25 1:38 ` David Lechner
2026-05-25 1:38 ` [PATCH v2 4/9] iio: adc: at91_adc: " David Lechner
` (5 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:38 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: linux-iio, linux-kernel, linux-arm-kernel, linux-stm32,
chrome-platform, David Lechner
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.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/adc/dln2-adc.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c
index eb902a946efe..b01c6f5a73b1 100644
--- a/drivers/iio/adc/dln2-adc.c
+++ b/drivers/iio/adc/dln2-adc.c
@@ -444,16 +444,6 @@ static int dln2_update_scan_mode(struct iio_dev *indio_dev,
lval.scan_type.endianness = IIO_LE; \
}
-/* Assignment version of IIO_CHAN_SOFT_TIMESTAMP */
-#define IIO_CHAN_SOFT_TIMESTAMP_ASSIGN(lval, _si) { \
- lval.type = IIO_TIMESTAMP; \
- lval.channel = -1; \
- lval.scan_index = _si; \
- lval.scan_type.sign = 's'; \
- lval.scan_type.realbits = 64; \
- lval.scan_type.storagebits = 64; \
-}
-
static const struct iio_info dln2_adc_info = {
.read_raw = dln2_adc_read_raw,
.write_raw = dln2_adc_write_raw,
@@ -614,7 +604,7 @@ static int dln2_adc_probe(struct platform_device *pdev)
for (i = 0; i < chans; ++i)
DLN2_ADC_CHAN(dln2->iio_channels[i], i)
- IIO_CHAN_SOFT_TIMESTAMP_ASSIGN(dln2->iio_channels[i], i);
+ dln2->iio_channels[i] = IIO_CHAN_SOFT_TIMESTAMP(i);
indio_dev->name = DLN2_ADC_MOD_NAME;
indio_dev->info = &dln2_adc_info;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 4/9] iio: adc: at91_adc: simplify timestamp channel definition
2026-05-25 1:38 [PATCH v2 0/9] iio: timestamp declaration cleanup David Lechner
` (2 preceding siblings ...)
2026-05-25 1:38 ` [PATCH v2 3/9] iio: adc: dln2-adc: " David Lechner
@ 2026-05-25 1:38 ` David Lechner
2026-05-25 1:38 ` [PATCH v2 5/9] iio: adc: cc10001_adc: " David Lechner
` (4 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:38 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: linux-iio, linux-kernel, linux-arm-kernel, linux-stm32,
chrome-platform, David Lechner
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.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/adc/at91_adc.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 6e1930f7c65d..f610ad729bf3 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -481,7 +481,7 @@ static irqreturn_t at91_adc_9x5_interrupt(int irq, void *private)
static int at91_adc_channel_init(struct iio_dev *idev)
{
struct at91_adc_state *st = iio_priv(idev);
- struct iio_chan_spec *chan_array, *timestamp;
+ struct iio_chan_spec *chan_array;
int bit, idx = 0;
unsigned long rsvd_mask = 0;
@@ -519,14 +519,8 @@ static int at91_adc_channel_init(struct iio_dev *idev)
chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW);
idx++;
}
- timestamp = chan_array + idx;
-
- timestamp->type = IIO_TIMESTAMP;
- timestamp->channel = -1;
- timestamp->scan_index = idx;
- timestamp->scan_type.sign = 's';
- timestamp->scan_type.realbits = 64;
- timestamp->scan_type.storagebits = 64;
+
+ chan_array[idx] = IIO_CHAN_SOFT_TIMESTAMP(idx);
idev->channels = chan_array;
return idev->num_channels;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 5/9] iio: adc: cc10001_adc: simplify timestamp channel definition
2026-05-25 1:38 [PATCH v2 0/9] iio: timestamp declaration cleanup David Lechner
` (3 preceding siblings ...)
2026-05-25 1:38 ` [PATCH v2 4/9] iio: adc: at91_adc: " David Lechner
@ 2026-05-25 1:38 ` David Lechner
2026-05-25 1:38 ` [PATCH v2 6/9] iio: adc: stm32-adc: " David Lechner
` (3 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:38 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: linux-iio, linux-kernel, linux-arm-kernel, linux-stm32,
chrome-platform, David Lechner
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.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/adc/cc10001_adc.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
index 2c51b90b7101..d42b747325aa 100644
--- a/drivers/iio/adc/cc10001_adc.c
+++ b/drivers/iio/adc/cc10001_adc.c
@@ -262,7 +262,7 @@ static const struct iio_info cc10001_adc_info = {
static int cc10001_adc_channel_init(struct iio_dev *indio_dev,
unsigned long channel_map)
{
- struct iio_chan_spec *chan_array, *timestamp;
+ struct iio_chan_spec *chan_array;
unsigned int bit, idx = 0;
indio_dev->num_channels = bitmap_weight(&channel_map,
@@ -289,13 +289,7 @@ static int cc10001_adc_channel_init(struct iio_dev *indio_dev,
idx++;
}
- timestamp = &chan_array[idx];
- timestamp->type = IIO_TIMESTAMP;
- timestamp->channel = -1;
- timestamp->scan_index = idx;
- timestamp->scan_type.sign = 's';
- timestamp->scan_type.realbits = 64;
- timestamp->scan_type.storagebits = 64;
+ chan_array[idx] = IIO_CHAN_SOFT_TIMESTAMP(idx);
indio_dev->channels = chan_array;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 6/9] iio: adc: stm32-adc: simplify timestamp channel definition
2026-05-25 1:38 [PATCH v2 0/9] iio: timestamp declaration cleanup David Lechner
` (4 preceding siblings ...)
2026-05-25 1:38 ` [PATCH v2 5/9] iio: adc: cc10001_adc: " David Lechner
@ 2026-05-25 1:38 ` David Lechner
2026-05-25 1:38 ` [PATCH v2 7/9] iio: common: cros_ec_sensors: " David Lechner
` (2 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:38 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: linux-iio, linux-kernel, linux-arm-kernel, linux-stm32,
chrome-platform, David Lechner
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.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/adc/stm32-adc.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index 46106200bb86..5c5170b19b56 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -2443,15 +2443,7 @@ static int stm32_adc_chan_fw_init(struct iio_dev *indio_dev, bool timestamping)
scan_index = ret;
if (timestamping) {
- struct iio_chan_spec *timestamp = &channels[scan_index];
-
- timestamp->type = IIO_TIMESTAMP;
- timestamp->channel = -1;
- timestamp->scan_index = scan_index;
- timestamp->scan_type.sign = 's';
- timestamp->scan_type.realbits = 64;
- timestamp->scan_type.storagebits = 64;
-
+ channels[scan_index] = IIO_CHAN_SOFT_TIMESTAMP(scan_index);
scan_index++;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 7/9] iio: common: cros_ec_sensors: simplify timestamp channel definition
2026-05-25 1:38 [PATCH v2 0/9] iio: timestamp declaration cleanup David Lechner
` (5 preceding siblings ...)
2026-05-25 1:38 ` [PATCH v2 6/9] iio: adc: stm32-adc: " David Lechner
@ 2026-05-25 1:38 ` David Lechner
2026-05-25 1:38 ` [PATCH v2 8/9] iio: light: cros_ec_light_prox: " David Lechner
2026-05-25 1:46 ` [PATCH] iio: pressure: cros_ec_baro: " David Lechner
8 siblings, 0 replies; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:38 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: linux-iio, linux-kernel, linux-arm-kernel, linux-stm32,
chrome-platform, David Lechner
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@baylibre.com>
---
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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 8/9] iio: light: cros_ec_light_prox: simplify timestamp channel definition
2026-05-25 1:38 [PATCH v2 0/9] iio: timestamp declaration cleanup David Lechner
` (6 preceding siblings ...)
2026-05-25 1:38 ` [PATCH v2 7/9] iio: common: cros_ec_sensors: " David Lechner
@ 2026-05-25 1:38 ` David Lechner
2026-05-25 1:46 ` [PATCH] iio: pressure: cros_ec_baro: " David Lechner
8 siblings, 0 replies; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:38 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: linux-iio, linux-kernel, linux-arm-kernel, linux-stm32,
chrome-platform, David Lechner
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@baylibre.com>
---
drivers/iio/light/cros_ec_light_prox.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
index 815806ceb5c8..d09dea9c0782 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -223,14 +223,8 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)
return -EINVAL;
}
- /* Timestamp */
channel++;
- channel->type = IIO_TIMESTAMP;
- channel->channel = -1;
- channel->scan_index = 1;
- channel->scan_type.sign = 's';
- channel->scan_type.realbits = 64;
- channel->scan_type.storagebits = 64;
+ *channel = IIO_CHAN_SOFT_TIMESTAMP(1);
indio_dev->channels = state->channels;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH] iio: pressure: cros_ec_baro: simplify timestamp channel definition
2026-05-25 1:38 [PATCH v2 0/9] iio: timestamp declaration cleanup David Lechner
` (7 preceding siblings ...)
2026-05-25 1:38 ` [PATCH v2 8/9] iio: light: cros_ec_light_prox: " David Lechner
@ 2026-05-25 1:46 ` David Lechner
2026-05-25 1:49 ` David Lechner
2026-05-28 6:40 ` kernel test robot
8 siblings, 2 replies; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:46 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: David Lechner, linux-iio, linux-kernel, linux-arm-kernel,
linux-stm32, chrome-platform, Andy Shevchenko
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@baylibre.com>
---
drivers/iio/pressure/cros_ec_baro.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
index c6b950c596c1..6cbde48d5be3 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -170,14 +170,8 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
return -EINVAL;
}
- /* Timestamp */
channel++;
- channel->type = IIO_TIMESTAMP;
- channel->channel = -1;
- channel->scan_index = 1;
- channel->scan_type.sign = 's';
- channel->scan_type.realbits = 64;
- channel->scan_type.storagebits = 64;
+ *channel = IIO_CHAN_SOFT_TIMESTAMP(1);
indio_dev->channels = state->channels;
indio_dev->num_channels = CROS_EC_BARO_MAX_CHANNELS;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] iio: pressure: cros_ec_baro: simplify timestamp channel definition
2026-05-25 1:46 ` [PATCH] iio: pressure: cros_ec_baro: " David Lechner
@ 2026-05-25 1:49 ` David Lechner
2026-05-26 18:12 ` Jonathan Cameron
2026-05-28 6:40 ` kernel test robot
1 sibling, 1 reply; 13+ messages in thread
From: David Lechner @ 2026-05-25 1:49 UTC (permalink / raw)
To: Jyoti Bhayana, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: linux-iio, linux-kernel, linux-arm-kernel, linux-stm32,
chrome-platform, Andy Shevchenko
On 5/24/26 8:46 PM, David Lechner wrote:
> 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.
>
FYI, there was a server error when doing b4 send, so this last patch
didn't get sent with the rest. I missed the [PATCH v2 9/9] when editing
it manually to send again.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] iio: pressure: cros_ec_baro: simplify timestamp channel definition
2026-05-25 1:49 ` David Lechner
@ 2026-05-26 18:12 ` Jonathan Cameron
0 siblings, 0 replies; 13+ messages in thread
From: Jonathan Cameron @ 2026-05-26 18:12 UTC (permalink / raw)
To: David Lechner
Cc: Jyoti Bhayana, Nuno Sá, Andy Shevchenko, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea, Maxime Coquelin,
Alexandre Torgue, Benson Leung, Guenter Roeck, linux-iio,
linux-kernel, linux-arm-kernel, linux-stm32, chrome-platform,
Andy Shevchenko
On Sun, 24 May 2026 20:49:11 -0500
David Lechner <dlechner@baylibre.com> wrote:
> On 5/24/26 8:46 PM, David Lechner wrote:
> > 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.
> >
> FYI, there was a server error when doing b4 send, so this last patch
> didn't get sent with the rest. I missed the [PATCH v2 9/9] when editing
> it manually to send again.
>
>
New and exciting way to confuse b4 :) Anyhow easy to work around
with a -v 2 for the first lot and then it thinks this one is v3 anyway.
Applied.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] iio: pressure: cros_ec_baro: simplify timestamp channel definition
2026-05-25 1:46 ` [PATCH] iio: pressure: cros_ec_baro: " David Lechner
2026-05-25 1:49 ` David Lechner
@ 2026-05-28 6:40 ` kernel test robot
1 sibling, 0 replies; 13+ messages in thread
From: kernel test robot @ 2026-05-28 6:40 UTC (permalink / raw)
To: David Lechner, Jyoti Bhayana, Jonathan Cameron, Nuno Sá,
Andy Shevchenko, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Maxime Coquelin, Alexandre Torgue, Benson Leung, Guenter Roeck
Cc: oe-kbuild-all, David Lechner, linux-iio, linux-kernel,
linux-arm-kernel, linux-stm32, chrome-platform
Hi David,
kernel test robot noticed the following build errors:
[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on linus/master v7.1-rc5 next-20260527]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/David-Lechner/iio-pressure-cros_ec_baro-simplify-timestamp-channel-definition/20260525-134550
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link: https://lore.kernel.org/r/20260525014654.2399354-1-dlechner%40baylibre.com
patch subject: [PATCH] iio: pressure: cros_ec_baro: simplify timestamp channel definition
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20260528/202605281432.a64fe4iY-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260528/202605281432.a64fe4iY-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605281432.a64fe4iY-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from include/linux/iio/buffer.h:10,
from drivers/iio/pressure/cros_ec_baro.c:9:
drivers/iio/pressure/cros_ec_baro.c: In function 'cros_ec_baro_probe':
>> include/linux/iio/iio.h:356:38: error: expected expression before '{' token
356 | #define IIO_CHAN_SOFT_TIMESTAMP(_si) { \
| ^
drivers/iio/pressure/cros_ec_baro.c:174:20: note: in expansion of macro 'IIO_CHAN_SOFT_TIMESTAMP'
174 | *channel = IIO_CHAN_SOFT_TIMESTAMP(1);
| ^~~~~~~~~~~~~~~~~~~~~~~
vim +356 include/linux/iio/iio.h
00c5f80c2fad53 include/linux/iio/iio.h Peter Rosin 2016-11-08 355
07d4655b410a4d include/linux/iio/iio.h Jonathan Cameron 2013-11-12 @356 #define IIO_CHAN_SOFT_TIMESTAMP(_si) { \
07d4655b410a4d include/linux/iio/iio.h Jonathan Cameron 2013-11-12 357 .type = IIO_TIMESTAMP, \
07d4655b410a4d include/linux/iio/iio.h Jonathan Cameron 2013-11-12 358 .channel = -1, \
07d4655b410a4d include/linux/iio/iio.h Jonathan Cameron 2013-11-12 359 .scan_index = _si, \
07d4655b410a4d include/linux/iio/iio.h Jonathan Cameron 2013-11-12 360 .scan_type = { \
07d4655b410a4d include/linux/iio/iio.h Jonathan Cameron 2013-11-12 361 .sign = 's', \
07d4655b410a4d include/linux/iio/iio.h Jonathan Cameron 2013-11-12 362 .realbits = 64, \
07d4655b410a4d include/linux/iio/iio.h Jonathan Cameron 2013-11-12 363 .storagebits = 64, \
07d4655b410a4d include/linux/iio/iio.h Jonathan Cameron 2013-11-12 364 }, \
07d4655b410a4d include/linux/iio/iio.h Jonathan Cameron 2013-11-12 365 }
1d892719e70e47 drivers/staging/iio/iio.h Jonathan Cameron 2011-05-18 366
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-05-28 6:41 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-25 1:38 [PATCH v2 0/9] iio: timestamp declaration cleanup David Lechner
2026-05-25 1:38 ` [PATCH v2 1/9] iio: Convert IIO_CHAN_SOFT_TIMESTAMP() to be compound literal David Lechner
2026-05-25 1:38 ` [PATCH v2 2/9] iio: common: scmi_sensors: simplify timestamp channel definition David Lechner
2026-05-25 1:38 ` [PATCH v2 3/9] iio: adc: dln2-adc: " David Lechner
2026-05-25 1:38 ` [PATCH v2 4/9] iio: adc: at91_adc: " David Lechner
2026-05-25 1:38 ` [PATCH v2 5/9] iio: adc: cc10001_adc: " David Lechner
2026-05-25 1:38 ` [PATCH v2 6/9] iio: adc: stm32-adc: " David Lechner
2026-05-25 1:38 ` [PATCH v2 7/9] iio: common: cros_ec_sensors: " David Lechner
2026-05-25 1:38 ` [PATCH v2 8/9] iio: light: cros_ec_light_prox: " David Lechner
2026-05-25 1:46 ` [PATCH] iio: pressure: cros_ec_baro: " David Lechner
2026-05-25 1:49 ` David Lechner
2026-05-26 18:12 ` Jonathan Cameron
2026-05-28 6:40 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox