From c51ca38cc845bf0d471a766abcd0f79c7f545b30 Mon Sep 17 00:00:00 2001 From: Tao Huang Date: Wed, 28 Jun 2023 11:41:57 +0800 Subject: [PATCH] iio: imu: lsm6dsr: make use of devm_iio_kfifo_buffer_setup() helper According to commit 17395ce29921 ("iio: make use of devm_iio_kfifo_buffer_setup() helper") and commit f67c6c73cb07 ("iio: core: Simplify the registration of kfifo buffers"). Also fixes the following warning: drivers/iio/imu/st_lsm6dsr/st_lsm6dsr_buffer.c:992:19: error: implicit declaration of function 'of_property_read_bool' [-Werror=implicit-function-declaration] Signed-off-by: Tao Huang Change-Id: Ia8229b4fe1d22c6455ea8b1eeb410a925f71e785 --- drivers/iio/imu/st_lsm6dsr/st_lsm6dsr_buffer.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsr/st_lsm6dsr_buffer.c b/drivers/iio/imu/st_lsm6dsr/st_lsm6dsr_buffer.c index d4db6b7b7e5a..80b6d470013e 100644 --- a/drivers/iio/imu/st_lsm6dsr/st_lsm6dsr_buffer.c +++ b/drivers/iio/imu/st_lsm6dsr/st_lsm6dsr_buffer.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "st_lsm6dsr.h" #define ST_LSM6DSR_REG_EMB_FUNC_STATUS_MAINPAGE 0x35 @@ -976,7 +977,6 @@ int st_lsm6dsr_buffers_setup(struct st_lsm6dsr_hw *hw) { struct device_node *np = hw->dev->of_node; struct st_lsm6dsr_sensor *sensor; - struct iio_buffer *buffer; struct iio_dev *iio_dev; unsigned long irq_type; int i, err; @@ -1014,13 +1014,10 @@ int st_lsm6dsr_buffers_setup(struct st_lsm6dsr_hw *hw) if (!hw->iio_devs[i]) continue; - buffer = devm_iio_kfifo_allocate(hw->dev); - if (!buffer) - return -ENOMEM; - - iio_device_attach_buffer(hw->iio_devs[i], buffer); - hw->iio_devs[i]->modes |= INDIO_BUFFER_SOFTWARE; - hw->iio_devs[i]->setup_ops = &st_lsm6dsr_fifo_ops; + err = devm_iio_kfifo_buffer_setup(hw->dev, hw->iio_devs[i], + &st_lsm6dsr_fifo_ops); + if (err) + return err; } err = st_lsm6dsr_fifo_init(hw);