]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iio: adc: at91_adc: simplify timestamp channel definition
authorDavid Lechner <dlechner@baylibre.com>
Mon, 25 May 2026 01:38:36 +0000 (20:38 -0500)
committerJonathan Cameron <jic23@kernel.org>
Sun, 31 May 2026 10:01:49 +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.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/at91_adc.c

index 6e1930f7c65d9eb954aea94841d23e080a7dafec..f610ad729bf31c6a0fc0b9f88e01dbab0a12381a 100644 (file)
@@ -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;