From bbc1308de79368879580635ded6df51d232845ef Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Sat, 6 Mar 2021 18:28:34 +0200 Subject: iio: kfifo: mask flags without zero-check in devm_iio_kfifo_buffer_setup() As pointed by Lars, this doesn't require a zero-check. Also, while looking at this a little closer at it (again), the masking can be done later, as there is a zero-check for 'mode_flags' anyway, which returns -EINVAL. And we only need the 'mode_flags' later in the logic. This change is more of a tweak. Fixes: e36db6a06937 ("iio: kfifo: add devm_iio_kfifo_buffer_setup() helper") Cc: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210306162834.7339-1-ardeleanalex@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/buffer/kfifo_buf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/iio/buffer/kfifo_buf.c') diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c index 34289ce12f20..4ecfa0ec3016 100644 --- a/drivers/iio/buffer/kfifo_buf.c +++ b/drivers/iio/buffer/kfifo_buf.c @@ -225,9 +225,6 @@ int devm_iio_kfifo_buffer_setup(struct device *dev, { struct iio_buffer *buffer; - if (mode_flags) - mode_flags &= kfifo_access_funcs.modes; - if (!mode_flags) return -EINVAL; @@ -235,6 +232,8 @@ int devm_iio_kfifo_buffer_setup(struct device *dev, if (!buffer) return -ENOMEM; + mode_flags &= kfifo_access_funcs.modes; + indio_dev->modes |= mode_flags; indio_dev->setup_ops = setup_ops; -- cgit v1.2.3-59-g8ed1b