+static int bh1745_set_trigger_state(struct iio_trigger *trig, bool state)
+{
+ int ret;
Why is value initialized here? If regmap returns an error, you will not
use value anyway. I caught my eye because it is initialized here, and
not in the other functions where you use the same pattern.
+ int value = 0;
+ struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
+ struct bh1745_data *data = iio_priv(indio_dev);
+
+ guard(mutex)(&data->lock);
+ if (state) {
+ ret = regmap_read(data->regmap, BH1745_INTR, &value);
+ if (ret)
+ return ret;
+ // Latch is always set when enabling interrupt
+ value |= BH1745_INT_ENABLE |
+ FIELD_PREP(BH1745_INT_SIGNAL_LATCHED, 1) |
+ FIELD_PREP(BH1745_INT_SOURCE_MASK, data->int_src);
+ return regmap_write(data->regmap, BH1745_INTR, value);
+ }
+
+ return regmap_write(data->regmap, BH1745_INTR, value);
+}
Best regards,
Javier Carrasco