Commit 3b3b0cf4 authored by Vasileios Amoiridis's avatar Vasileios Amoiridis Committed by Jonathan Cameron

iio: pressure: bmp280: Make error checks consistent

The form 'if (ret)' is used in this driver in order to check
for returned error values. There are also some places that
'if (ret < 0)' is used but for no specific reason. Change
them to 'if (ret)' to make the driver more consistent.
Signed-off-by: default avatarVasileios Amoiridis <vassilisamir@gmail.com>
Link: https://lore.kernel.org/r/20240508165207.145554-4-vassilisamir@gmail.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 6047c11e
...@@ -184,7 +184,7 @@ static int bmp280_read_calib(struct bmp280_data *data) ...@@ -184,7 +184,7 @@ static int bmp280_read_calib(struct bmp280_data *data)
ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_TEMP_START, ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_TEMP_START,
data->bmp280_cal_buf, data->bmp280_cal_buf,
sizeof(data->bmp280_cal_buf)); sizeof(data->bmp280_cal_buf));
if (ret < 0) { if (ret) {
dev_err(data->dev, dev_err(data->dev,
"failed to read calibration parameters\n"); "failed to read calibration parameters\n");
return ret; return ret;
...@@ -222,7 +222,7 @@ static int bme280_read_calib(struct bmp280_data *data) ...@@ -222,7 +222,7 @@ static int bme280_read_calib(struct bmp280_data *data)
/* Load shared calibration params with bmp280 first */ /* Load shared calibration params with bmp280 first */
ret = bmp280_read_calib(data); ret = bmp280_read_calib(data);
if (ret < 0) if (ret)
return ret; return ret;
/* /*
...@@ -234,7 +234,7 @@ static int bme280_read_calib(struct bmp280_data *data) ...@@ -234,7 +234,7 @@ static int bme280_read_calib(struct bmp280_data *data)
*/ */
ret = regmap_read(data->regmap, BME280_REG_COMP_H1, &tmp); ret = regmap_read(data->regmap, BME280_REG_COMP_H1, &tmp);
if (ret < 0) { if (ret) {
dev_err(dev, "failed to read H1 comp value\n"); dev_err(dev, "failed to read H1 comp value\n");
return ret; return ret;
} }
...@@ -242,14 +242,14 @@ static int bme280_read_calib(struct bmp280_data *data) ...@@ -242,14 +242,14 @@ static int bme280_read_calib(struct bmp280_data *data)
ret = regmap_bulk_read(data->regmap, BME280_REG_COMP_H2, ret = regmap_bulk_read(data->regmap, BME280_REG_COMP_H2,
&data->le16, sizeof(data->le16)); &data->le16, sizeof(data->le16));
if (ret < 0) { if (ret) {
dev_err(dev, "failed to read H2 comp value\n"); dev_err(dev, "failed to read H2 comp value\n");
return ret; return ret;
} }
calib->H2 = sign_extend32(le16_to_cpu(data->le16), 15); calib->H2 = sign_extend32(le16_to_cpu(data->le16), 15);
ret = regmap_read(data->regmap, BME280_REG_COMP_H3, &tmp); ret = regmap_read(data->regmap, BME280_REG_COMP_H3, &tmp);
if (ret < 0) { if (ret) {
dev_err(dev, "failed to read H3 comp value\n"); dev_err(dev, "failed to read H3 comp value\n");
return ret; return ret;
} }
...@@ -257,7 +257,7 @@ static int bme280_read_calib(struct bmp280_data *data) ...@@ -257,7 +257,7 @@ static int bme280_read_calib(struct bmp280_data *data)
ret = regmap_bulk_read(data->regmap, BME280_REG_COMP_H4, ret = regmap_bulk_read(data->regmap, BME280_REG_COMP_H4,
&data->be16, sizeof(data->be16)); &data->be16, sizeof(data->be16));
if (ret < 0) { if (ret) {
dev_err(dev, "failed to read H4 comp value\n"); dev_err(dev, "failed to read H4 comp value\n");
return ret; return ret;
} }
...@@ -266,14 +266,14 @@ static int bme280_read_calib(struct bmp280_data *data) ...@@ -266,14 +266,14 @@ static int bme280_read_calib(struct bmp280_data *data)
ret = regmap_bulk_read(data->regmap, BME280_REG_COMP_H5, ret = regmap_bulk_read(data->regmap, BME280_REG_COMP_H5,
&data->le16, sizeof(data->le16)); &data->le16, sizeof(data->le16));
if (ret < 0) { if (ret) {
dev_err(dev, "failed to read H5 comp value\n"); dev_err(dev, "failed to read H5 comp value\n");
return ret; return ret;
} }
calib->H5 = sign_extend32(FIELD_GET(BME280_COMP_H5_MASK, le16_to_cpu(data->le16)), 11); calib->H5 = sign_extend32(FIELD_GET(BME280_COMP_H5_MASK, le16_to_cpu(data->le16)), 11);
ret = regmap_read(data->regmap, BME280_REG_COMP_H6, &tmp); ret = regmap_read(data->regmap, BME280_REG_COMP_H6, &tmp);
if (ret < 0) { if (ret) {
dev_err(dev, "failed to read H6 comp value\n"); dev_err(dev, "failed to read H6 comp value\n");
return ret; return ret;
} }
...@@ -370,7 +370,7 @@ static int bmp280_read_temp(struct bmp280_data *data, ...@@ -370,7 +370,7 @@ static int bmp280_read_temp(struct bmp280_data *data,
ret = regmap_bulk_read(data->regmap, BMP280_REG_TEMP_MSB, ret = regmap_bulk_read(data->regmap, BMP280_REG_TEMP_MSB,
data->buf, sizeof(data->buf)); data->buf, sizeof(data->buf));
if (ret < 0) { if (ret) {
dev_err(data->dev, "failed to read temperature\n"); dev_err(data->dev, "failed to read temperature\n");
return ret; return ret;
} }
...@@ -404,12 +404,12 @@ static int bmp280_read_press(struct bmp280_data *data, ...@@ -404,12 +404,12 @@ static int bmp280_read_press(struct bmp280_data *data,
/* Read and compensate temperature so we get a reading of t_fine. */ /* Read and compensate temperature so we get a reading of t_fine. */
ret = bmp280_read_temp(data, NULL, NULL); ret = bmp280_read_temp(data, NULL, NULL);
if (ret < 0) if (ret)
return ret; return ret;
ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB, ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB,
data->buf, sizeof(data->buf)); data->buf, sizeof(data->buf));
if (ret < 0) { if (ret) {
dev_err(data->dev, "failed to read pressure\n"); dev_err(data->dev, "failed to read pressure\n");
return ret; return ret;
} }
...@@ -436,12 +436,12 @@ static int bme280_read_humid(struct bmp280_data *data, int *val, int *val2) ...@@ -436,12 +436,12 @@ static int bme280_read_humid(struct bmp280_data *data, int *val, int *val2)
/* Read and compensate temperature so we get a reading of t_fine. */ /* Read and compensate temperature so we get a reading of t_fine. */
ret = bmp280_read_temp(data, NULL, NULL); ret = bmp280_read_temp(data, NULL, NULL);
if (ret < 0) if (ret)
return ret; return ret;
ret = regmap_bulk_read(data->regmap, BME280_REG_HUMIDITY_MSB, ret = regmap_bulk_read(data->regmap, BME280_REG_HUMIDITY_MSB,
&data->be16, sizeof(data->be16)); &data->be16, sizeof(data->be16));
if (ret < 0) { if (ret) {
dev_err(data->dev, "failed to read humidity\n"); dev_err(data->dev, "failed to read humidity\n");
return ret; return ret;
} }
...@@ -775,7 +775,7 @@ static int bmp280_chip_config(struct bmp280_data *data) ...@@ -775,7 +775,7 @@ static int bmp280_chip_config(struct bmp280_data *data)
BMP280_OSRS_PRESS_MASK | BMP280_OSRS_PRESS_MASK |
BMP280_MODE_MASK, BMP280_MODE_MASK,
osrs | BMP280_MODE_NORMAL); osrs | BMP280_MODE_NORMAL);
if (ret < 0) { if (ret) {
dev_err(data->dev, "failed to write ctrl_meas register\n"); dev_err(data->dev, "failed to write ctrl_meas register\n");
return ret; return ret;
} }
...@@ -783,7 +783,7 @@ static int bmp280_chip_config(struct bmp280_data *data) ...@@ -783,7 +783,7 @@ static int bmp280_chip_config(struct bmp280_data *data)
ret = regmap_update_bits(data->regmap, BMP280_REG_CONFIG, ret = regmap_update_bits(data->regmap, BMP280_REG_CONFIG,
BMP280_FILTER_MASK, BMP280_FILTER_MASK,
BMP280_FILTER_4X); BMP280_FILTER_4X);
if (ret < 0) { if (ret) {
dev_err(data->dev, "failed to write config register\n"); dev_err(data->dev, "failed to write config register\n");
return ret; return ret;
} }
...@@ -839,7 +839,7 @@ static int bme280_chip_config(struct bmp280_data *data) ...@@ -839,7 +839,7 @@ static int bme280_chip_config(struct bmp280_data *data)
*/ */
ret = regmap_update_bits(data->regmap, BME280_REG_CTRL_HUMIDITY, ret = regmap_update_bits(data->regmap, BME280_REG_CTRL_HUMIDITY,
BME280_OSRS_HUMIDITY_MASK, osrs); BME280_OSRS_HUMIDITY_MASK, osrs);
if (ret < 0) { if (ret) {
dev_err(data->dev, "failed to set humidity oversampling"); dev_err(data->dev, "failed to set humidity oversampling");
return ret; return ret;
} }
...@@ -1856,7 +1856,7 @@ static int bmp180_read_calib(struct bmp280_data *data) ...@@ -1856,7 +1856,7 @@ static int bmp180_read_calib(struct bmp280_data *data)
ret = regmap_bulk_read(data->regmap, BMP180_REG_CALIB_START, ret = regmap_bulk_read(data->regmap, BMP180_REG_CALIB_START,
data->bmp180_cal_buf, sizeof(data->bmp180_cal_buf)); data->bmp180_cal_buf, sizeof(data->bmp180_cal_buf));
if (ret < 0) { if (ret) {
dev_err(data->dev, "failed to read calibration parameters\n"); dev_err(data->dev, "failed to read calibration parameters\n");
return ret; return ret;
} }
...@@ -2177,7 +2177,7 @@ int bmp280_common_probe(struct device *dev, ...@@ -2177,7 +2177,7 @@ int bmp280_common_probe(struct device *dev,
data->regmap = regmap; data->regmap = regmap;
ret = regmap_read(regmap, data->chip_info->id_reg, &chip_id); ret = regmap_read(regmap, data->chip_info->id_reg, &chip_id);
if (ret < 0) { if (ret) {
dev_err(data->dev, "failed to read chip id\n"); dev_err(data->dev, "failed to read chip id\n");
return ret; return ret;
} }
...@@ -2200,7 +2200,7 @@ int bmp280_common_probe(struct device *dev, ...@@ -2200,7 +2200,7 @@ int bmp280_common_probe(struct device *dev,
} }
ret = data->chip_info->chip_config(data); ret = data->chip_info->chip_config(data);
if (ret < 0) if (ret)
return ret; return ret;
dev_set_drvdata(dev, indio_dev); dev_set_drvdata(dev, indio_dev);
...@@ -2213,7 +2213,7 @@ int bmp280_common_probe(struct device *dev, ...@@ -2213,7 +2213,7 @@ int bmp280_common_probe(struct device *dev,
if (data->chip_info->read_calib) { if (data->chip_info->read_calib) {
ret = data->chip_info->read_calib(data); ret = data->chip_info->read_calib(data);
if (ret < 0) if (ret)
return dev_err_probe(data->dev, ret, return dev_err_probe(data->dev, ret,
"failed to read calibration coefficients\n"); "failed to read calibration coefficients\n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment