]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: light: acpi-als: Use a structure for layout of data to push to buffer.
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 2 Aug 2025 16:44:26 +0000 (17:44 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 16 Aug 2025 14:49:42 +0000 (15:49 +0100)
Using a structure makes the padding and alignment rules explicit,
removing the need for a comment.

Also move the storage to the stack as it is only 16 bytes.

Cc: Gwendal Grignou <gwendal@chromium.org>
Link: https://patch.msgid.link/20250802164436.515988-7-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
drivers/iio/light/acpi-als.c

index 032e6cae8b80535ff29599c47bbcc1de55072673..511ed37e783ed7196111cfbf8e7d10d78fb06374 100644 (file)
@@ -49,20 +49,10 @@ static const struct iio_chan_spec acpi_als_channels[] = {
        IIO_CHAN_SOFT_TIMESTAMP(1),
 };
 
-/*
- * The event buffer contains timestamp and all the data from
- * the ACPI0008 block. There are multiple, but so far we only
- * support _ALI (illuminance): One channel, padding and timestamp.
- */
-#define ACPI_ALS_EVT_BUFFER_SIZE               \
-       (sizeof(s32) + sizeof(s32) + sizeof(s64))
-
 struct acpi_als {
        struct acpi_device      *device;
        struct mutex            lock;
        struct iio_trigger      *trig;
-
-       s32 evt_buffer[ACPI_ALS_EVT_BUFFER_SIZE / sizeof(s32)]  __aligned(8);
 };
 
 /*
@@ -152,7 +142,10 @@ static irqreturn_t acpi_als_trigger_handler(int irq, void *p)
        struct iio_poll_func *pf = p;
        struct iio_dev *indio_dev = pf->indio_dev;
        struct acpi_als *als = iio_priv(indio_dev);
-       s32 *buffer = als->evt_buffer;
+       struct {
+               s32 light;
+               aligned_s64 ts;
+       } scan = { };
        s32 val;
        int ret;
 
@@ -161,7 +154,7 @@ static irqreturn_t acpi_als_trigger_handler(int irq, void *p)
        ret = acpi_als_read_value(als, ACPI_ALS_ILLUMINANCE, &val);
        if (ret < 0)
                goto out;
-       *buffer = val;
+       scan.light = val;
 
        /*
         * When coming from own trigger via polls, set polling function
@@ -174,7 +167,7 @@ static irqreturn_t acpi_als_trigger_handler(int irq, void *p)
        if (!pf->timestamp)
                pf->timestamp = iio_get_time_ns(indio_dev);
 
-       iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp);
+       iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp);
 out:
        mutex_unlock(&als->lock);
        iio_trigger_notify_done(indio_dev->trig);