Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <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>

+6 -13
+6 -13
drivers/iio/light/acpi-als.c
··· 49 49 IIO_CHAN_SOFT_TIMESTAMP(1), 50 50 }; 51 51 52 - /* 53 - * The event buffer contains timestamp and all the data from 54 - * the ACPI0008 block. There are multiple, but so far we only 55 - * support _ALI (illuminance): One channel, padding and timestamp. 56 - */ 57 - #define ACPI_ALS_EVT_BUFFER_SIZE \ 58 - (sizeof(s32) + sizeof(s32) + sizeof(s64)) 59 - 60 52 struct acpi_als { 61 53 struct acpi_device *device; 62 54 struct mutex lock; 63 55 struct iio_trigger *trig; 64 - 65 - s32 evt_buffer[ACPI_ALS_EVT_BUFFER_SIZE / sizeof(s32)] __aligned(8); 66 56 }; 67 57 68 58 /* ··· 142 152 struct iio_poll_func *pf = p; 143 153 struct iio_dev *indio_dev = pf->indio_dev; 144 154 struct acpi_als *als = iio_priv(indio_dev); 145 - s32 *buffer = als->evt_buffer; 155 + struct { 156 + s32 light; 157 + aligned_s64 ts; 158 + } scan = { }; 146 159 s32 val; 147 160 int ret; 148 161 ··· 154 161 ret = acpi_als_read_value(als, ACPI_ALS_ILLUMINANCE, &val); 155 162 if (ret < 0) 156 163 goto out; 157 - *buffer = val; 164 + scan.light = val; 158 165 159 166 /* 160 167 * When coming from own trigger via polls, set polling function ··· 167 174 if (!pf->timestamp) 168 175 pf->timestamp = iio_get_time_ns(indio_dev); 169 176 170 - iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp); 177 + iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp); 171 178 out: 172 179 mutex_unlock(&als->lock); 173 180 iio_trigger_notify_done(indio_dev->trig);