Commit 6047c11e authored by Vasileios Amoiridis's avatar Vasileios Amoiridis Committed by Jonathan Cameron

iio: pressure: bmp280: Remove, add and update error messages

Remove duplicate error messages, add missing error messages and
update redundant ones.

Add one missing error check.
Signed-off-by: default avatarVasileios Amoiridis <vassilisamir@gmail.com>
Link: https://lore.kernel.org/r/20240508165207.145554-3-vassilisamir@gmail.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 081cea88
......@@ -222,10 +222,8 @@ static int bme280_read_calib(struct bmp280_data *data)
/* Load shared calibration params with bmp280 first */
ret = bmp280_read_calib(data);
if (ret < 0) {
dev_err(dev, "failed to read calibration parameters\n");
if (ret < 0)
return ret;
}
/*
* Read humidity calibration values.
......@@ -841,8 +839,10 @@ static int bme280_chip_config(struct bmp280_data *data)
*/
ret = regmap_update_bits(data->regmap, BME280_REG_CTRL_HUMIDITY,
BME280_OSRS_HUMIDITY_MASK, osrs);
if (ret < 0)
if (ret < 0) {
dev_err(data->dev, "failed to set humidity oversampling");
return ret;
}
return bmp280_chip_config(data);
}
......@@ -1071,7 +1071,7 @@ static int bmp380_read_calib(struct bmp280_data *data)
sizeof(data->bmp380_cal_buf));
if (ret) {
dev_err(data->dev,
"failed to read temperature calibration parameters\n");
"failed to read calibration parameters\n");
return ret;
}
......@@ -1609,20 +1609,24 @@ static int bmp580_preinit(struct bmp280_data *data)
/* Post powerup sequence */
ret = regmap_read(data->regmap, BMP580_REG_CHIP_ID, &reg);
if (ret)
if (ret) {
dev_err(data->dev, "failed to establish comms with the chip\n");
return ret;
}
/* Print warn message if we don't know the chip id */
if (reg != BMP580_CHIP_ID && reg != BMP580_CHIP_ID_ALT)
dev_warn(data->dev, "preinit: unexpected chip_id\n");
dev_warn(data->dev, "unexpected chip_id\n");
ret = regmap_read(data->regmap, BMP580_REG_STATUS, &reg);
if (ret)
if (ret) {
dev_err(data->dev, "failed to read nvm status\n");
return ret;
}
/* Check nvm status */
if (!(reg & BMP580_STATUS_NVM_RDY_MASK) || (reg & BMP580_STATUS_NVM_ERR_MASK)) {
dev_err(data->dev, "preinit: nvm error on powerup sequence\n");
dev_err(data->dev, "nvm error on powerup sequence\n");
return -EIO;
}
......@@ -1657,6 +1661,10 @@ static int bmp580_chip_config(struct bmp280_data *data)
BMP580_DSP_COMP_MASK |
BMP580_DSP_SHDW_IIR_TEMP_EN |
BMP580_DSP_SHDW_IIR_PRESS_EN, reg_val);
if (ret) {
dev_err(data->dev, "failed to change DSP mode settings\n");
return ret;
}
/* Configure oversampling */
reg_val = FIELD_PREP(BMP580_OSR_TEMP_MASK, data->oversampling_temp) |
......@@ -1778,8 +1786,10 @@ static int bmp180_wait_for_eoc(struct bmp280_data *data, u8 ctrl_meas)
reinit_completion(&data->done);
ret = regmap_write(data->regmap, BMP280_REG_CTRL_MEAS, ctrl_meas);
if (ret)
if (ret) {
dev_err(data->dev, "failed to write crtl_meas register\n");
return ret;
}
if (data->use_eoc) {
/*
......@@ -1802,12 +1812,16 @@ static int bmp180_wait_for_eoc(struct bmp280_data *data, u8 ctrl_meas)
}
ret = regmap_read(data->regmap, BMP280_REG_CTRL_MEAS, &ctrl);
if (ret)
if (ret) {
dev_err(data->dev, "failed to read ctrl_meas register\n");
return ret;
}
/* The value of this bit reset to "0" after conversion is complete */
if (ctrl & BMP180_MEAS_SCO)
if (ctrl & BMP180_MEAS_SCO) {
dev_err(data->dev, "conversion didn't complete\n");
return -EIO;
}
return 0;
}
......@@ -1824,8 +1838,10 @@ static int bmp180_read_adc_temp(struct bmp280_data *data, int *val)
ret = regmap_bulk_read(data->regmap, BMP180_REG_OUT_MSB,
&data->be16, sizeof(data->be16));
if (ret)
if (ret) {
dev_err(data->dev, "failed to read temperature\n");
return ret;
}
*val = be16_to_cpu(data->be16);
......@@ -1840,9 +1856,10 @@ static int bmp180_read_calib(struct bmp280_data *data)
ret = regmap_bulk_read(data->regmap, BMP180_REG_CALIB_START,
data->bmp180_cal_buf, sizeof(data->bmp180_cal_buf));
if (ret < 0)
if (ret < 0) {
dev_err(data->dev, "failed to read calibration parameters\n");
return ret;
}
/* None of the words has the value 0 or 0xFFFF */
for (i = 0; i < ARRAY_SIZE(data->bmp180_cal_buf); i++) {
......@@ -1925,8 +1942,10 @@ static int bmp180_read_adc_press(struct bmp280_data *data, int *val)
ret = regmap_bulk_read(data->regmap, BMP180_REG_OUT_MSB,
data->buf, sizeof(data->buf));
if (ret)
if (ret) {
dev_err(data->dev, "failed to read pressure\n");
return ret;
}
*val = get_unaligned_be24(data->buf) >> (8 - oss);
......@@ -2158,8 +2177,10 @@ int bmp280_common_probe(struct device *dev,
data->regmap = regmap;
ret = regmap_read(regmap, data->chip_info->id_reg, &chip_id);
if (ret < 0)
if (ret < 0) {
dev_err(data->dev, "failed to read chip id\n");
return ret;
}
for (i = 0; i < data->chip_info->num_chip_id; i++) {
if (chip_id == data->chip_info->chip_id[i]) {
......
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