From: Jonathan Cameron Date: Sat, 2 Aug 2025 16:44:26 +0000 (+0100) Subject: iio: light: acpi-als: Use a structure for layout of data to push to buffer. X-Git-Tag: v6.18-rc1~74^2~7^2~118 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=783efeb58fefb13911a3f47d6e38a32780359f10;p=thirdparty%2Fkernel%2Fstable.git iio: light: acpi-als: Use a structure for layout of data to push to buffer. 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 Link: https://patch.msgid.link/20250802164436.515988-7-jic23@kernel.org Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko --- diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c index 032e6cae8b805..511ed37e783ed 100644 --- a/drivers/iio/light/acpi-als.c +++ b/drivers/iio/light/acpi-als.c @@ -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);