sensor: tsl2540: add missing return value check

This commit adds a missing return value check. Since the I2C write
failed we release the semaphore and returning immediatly instead of
using goto exit.

Fixes #65352

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
This commit is contained in:
Benjamin Björnsson 2023-11-18 01:59:24 +01:00 committed by Henrik Brix Andersen
parent dc257830a5
commit 445b43d407

View file

@ -162,8 +162,12 @@ static int tsl2540_attr_set(const struct device *dev, enum sensor_channel chan,
k_sem_take(&data->sem, K_FOREVER);
i2c_reg_write_byte_dt(&cfg->i2c_spec, TSL2540_ENABLE_ADDR, TSL2540_ENABLE_MASK &
~TSL2540_ENABLE_CONF);
ret = i2c_reg_write_byte_dt(&cfg->i2c_spec, TSL2540_ENABLE_ADDR, TSL2540_ENABLE_MASK &
~TSL2540_ENABLE_CONF);
if (ret) {
k_sem_give(&data->sem);
return ret;
}
#if CONFIG_TSL2540_TRIGGER
if (chan == SENSOR_CHAN_LIGHT) {