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: accel: adxl345: introduce adxl345_push_event function

Move the fifo handling into a separate function. This is a preparation
for a generic handling of the interrupt status register results. The
function is supposed to handle particular sensor events, and later to
forward them to the iio channel. This is needed to read out the interrupt
status register.

The function shall return occurring errors, if any, or 0 in case of
handled events or read fifo content. Thus migrate fifo read-out and push
fifo content to iio channels into this function to be built up with
additional event handling.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250414184245.100280-2-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Lothar Rubusch and committed by
Jonathan Cameron
5aec2b6e 1851c0f2

+19 -9
+19 -9
drivers/iio/accel/adxl345_core.c
··· 416 416 return 0; 417 417 } 418 418 419 + static int adxl345_push_event(struct iio_dev *indio_dev, int int_stat) 420 + { 421 + struct adxl345_state *st = iio_priv(indio_dev); 422 + int samples; 423 + 424 + if (FIELD_GET(ADXL345_INT_WATERMARK, int_stat)) { 425 + samples = adxl345_get_samples(st); 426 + if (samples < 0) 427 + return -EINVAL; 428 + 429 + if (adxl345_fifo_push(indio_dev, samples) < 0) 430 + return -EINVAL; 431 + } 432 + 433 + return 0; 434 + } 435 + 419 436 /** 420 437 * adxl345_irq_handler() - Handle irqs of the ADXL345. 421 438 * @irq: The irq being handled. ··· 445 428 struct iio_dev *indio_dev = p; 446 429 struct adxl345_state *st = iio_priv(indio_dev); 447 430 int int_stat; 448 - int samples; 449 431 450 432 if (regmap_read(st->regmap, ADXL345_REG_INT_SOURCE, &int_stat)) 451 433 return IRQ_NONE; 452 434 453 - if (FIELD_GET(ADXL345_INT_WATERMARK, int_stat)) { 454 - samples = adxl345_get_samples(st); 455 - if (samples < 0) 456 - goto err; 457 - 458 - if (adxl345_fifo_push(indio_dev, samples) < 0) 459 - goto err; 460 - } 435 + if (adxl345_push_event(indio_dev, int_stat)) 436 + goto err; 461 437 462 438 if (FIELD_GET(ADXL345_INT_OVERRUN, int_stat)) 463 439 goto err;