Linux-IIO Archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Vasileios Amoiridis <vassilisamir@gmail.com>
Cc: lars@metafoo.de, andriy.shevchenko@linux.intel.com,
	ang.iglesiasg@gmail.com, mazziesaccount@gmail.com,
	ak@it-klinger.de, petre.rodan@subdimension.ro,
	phil@raspberrypi.com, 579lpy@gmail.com, linus.walleij@linaro.org,
	semen.protsenko@linaro.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 2/9] iio: pressure: bmp280: Remove, add and update error messages
Date: Sun, 12 May 2024 13:09:50 +0100	[thread overview]
Message-ID: <20240512130950.4d5ab874@jic23-huawei> (raw)
In-Reply-To: <20240508165207.145554-3-vassilisamir@gmail.com>

On Wed,  8 May 2024 18:52:00 +0200
Vasileios Amoiridis <vassilisamir@gmail.com> wrote:

> Remove duplicate error messages, add missing error messages and
> update redundant ones.
> 
> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Hi Vasileios,

Ideally the one case where you are adding a missing error check should
have been a separate patch, but instead of splitting it I've just
added a note on that to the commit message.

Applied 

Jonathan

> ---
>  drivers/iio/pressure/bmp280-core.c | 55 +++++++++++++++++++++---------
>  1 file changed, 38 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 311a011604da..0aa16fb135c1 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -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]) {


  reply	other threads:[~2024-05-12 12:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08 16:51 [PATCH v6 0/9] iio: pressure: bmp280: Add triggered buffer support and Vasileios Amoiridis
2024-05-08 16:51 ` [PATCH v6 1/9] iio: pressure: bmp280: Remove dead error checks Vasileios Amoiridis
2024-05-12 12:07   ` Jonathan Cameron
2024-05-08 16:52 ` [PATCH v6 2/9] iio: pressure: bmp280: Remove, add and update error messages Vasileios Amoiridis
2024-05-12 12:09   ` Jonathan Cameron [this message]
2024-05-08 16:52 ` [PATCH v6 3/9] iio: pressure: bmp280: Make error checks consistent Vasileios Amoiridis
2024-05-12 12:11   ` Jonathan Cameron
2024-05-08 16:52 ` [PATCH v6 4/9] iio: pressure: bmp280: Use unsigned data types for raw sensor data Vasileios Amoiridis
2024-05-12 12:13   ` Jonathan Cameron
2024-05-08 16:52 ` [PATCH v6 5/9] iio: pressure: bmp280: Refactorize reading functions Vasileios Amoiridis
2024-05-12 12:24   ` Jonathan Cameron
2024-05-12 18:42     ` Vasileios Amoiridis
2024-05-08 16:52 ` [PATCH v6 6/9] iio: pressure: bmp280: Introduce new cleanup routines Vasileios Amoiridis
2024-05-08 16:52 ` [PATCH v6 7/9] iio: pressure: bmp280: Generalize read_{temp,press,humid}() functions Vasileios Amoiridis
2024-05-08 16:52 ` [PATCH v6 8/9] iio: pressure: bmp280: Add SCALE, RAW values in channels and refactorize them Vasileios Amoiridis
2024-05-12 12:29   ` Jonathan Cameron
2024-05-12 18:48     ` Vasileios Amoiridis
2024-05-08 16:52 ` [PATCH v6 9/9] iio: pressure: bmp280: Add triggered buffer support Vasileios Amoiridis
2024-05-12 12:34   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240512130950.4d5ab874@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=579lpy@gmail.com \
    --cc=ak@it-klinger.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ang.iglesiasg@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=petre.rodan@subdimension.ro \
    --cc=phil@raspberrypi.com \
    --cc=semen.protsenko@linaro.org \
    --cc=vassilisamir@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).