From: Vasileios Amoiridis <vassilisamir@gmail.com>
To: jic23@kernel.org
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,
Vasileios Amoiridis <vassilisamir@gmail.com>
Subject: [PATCH v6 3/9] iio: pressure: bmp280: Make error checks consistent
Date: Wed, 8 May 2024 18:52:01 +0200 [thread overview]
Message-ID: <20240508165207.145554-4-vassilisamir@gmail.com> (raw)
In-Reply-To: <20240508165207.145554-1-vassilisamir@gmail.com>
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: Vasileios Amoiridis <vassilisamir@gmail.com>
---
drivers/iio/pressure/bmp280-core.c | 40 +++++++++++++++---------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 0aa16fb135c1..f05ea754f53a 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -184,7 +184,7 @@ static int bmp280_read_calib(struct bmp280_data *data)
ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_TEMP_START,
data->bmp280_cal_buf,
sizeof(data->bmp280_cal_buf));
- if (ret < 0) {
+ if (ret) {
dev_err(data->dev,
"failed to read calibration parameters\n");
return ret;
@@ -222,7 +222,7 @@ static int bme280_read_calib(struct bmp280_data *data)
/* Load shared calibration params with bmp280 first */
ret = bmp280_read_calib(data);
- if (ret < 0)
+ if (ret)
return ret;
/*
@@ -234,7 +234,7 @@ static int bme280_read_calib(struct bmp280_data *data)
*/
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");
return ret;
}
@@ -242,14 +242,14 @@ static int bme280_read_calib(struct bmp280_data *data)
ret = regmap_bulk_read(data->regmap, BME280_REG_COMP_H2,
&data->le16, sizeof(data->le16));
- if (ret < 0) {
+ if (ret) {
dev_err(dev, "failed to read H2 comp value\n");
return ret;
}
calib->H2 = sign_extend32(le16_to_cpu(data->le16), 15);
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");
return ret;
}
@@ -257,7 +257,7 @@ static int bme280_read_calib(struct bmp280_data *data)
ret = regmap_bulk_read(data->regmap, BME280_REG_COMP_H4,
&data->be16, sizeof(data->be16));
- if (ret < 0) {
+ if (ret) {
dev_err(dev, "failed to read H4 comp value\n");
return ret;
}
@@ -266,14 +266,14 @@ static int bme280_read_calib(struct bmp280_data *data)
ret = regmap_bulk_read(data->regmap, BME280_REG_COMP_H5,
&data->le16, sizeof(data->le16));
- if (ret < 0) {
+ if (ret) {
dev_err(dev, "failed to read H5 comp value\n");
return ret;
}
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);
- if (ret < 0) {
+ if (ret) {
dev_err(dev, "failed to read H6 comp value\n");
return ret;
}
@@ -370,7 +370,7 @@ static int bmp280_read_temp(struct bmp280_data *data,
ret = regmap_bulk_read(data->regmap, BMP280_REG_TEMP_MSB,
data->buf, sizeof(data->buf));
- if (ret < 0) {
+ if (ret) {
dev_err(data->dev, "failed to read temperature\n");
return ret;
}
@@ -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. */
ret = bmp280_read_temp(data, NULL, NULL);
- if (ret < 0)
+ if (ret)
return ret;
ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB,
data->buf, sizeof(data->buf));
- if (ret < 0) {
+ if (ret) {
dev_err(data->dev, "failed to read pressure\n");
return ret;
}
@@ -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. */
ret = bmp280_read_temp(data, NULL, NULL);
- if (ret < 0)
+ if (ret)
return ret;
ret = regmap_bulk_read(data->regmap, BME280_REG_HUMIDITY_MSB,
&data->be16, sizeof(data->be16));
- if (ret < 0) {
+ if (ret) {
dev_err(data->dev, "failed to read humidity\n");
return ret;
}
@@ -775,7 +775,7 @@ static int bmp280_chip_config(struct bmp280_data *data)
BMP280_OSRS_PRESS_MASK |
BMP280_MODE_MASK,
osrs | BMP280_MODE_NORMAL);
- if (ret < 0) {
+ if (ret) {
dev_err(data->dev, "failed to write ctrl_meas register\n");
return ret;
}
@@ -783,7 +783,7 @@ static int bmp280_chip_config(struct bmp280_data *data)
ret = regmap_update_bits(data->regmap, BMP280_REG_CONFIG,
BMP280_FILTER_MASK,
BMP280_FILTER_4X);
- if (ret < 0) {
+ if (ret) {
dev_err(data->dev, "failed to write config register\n");
return ret;
}
@@ -839,7 +839,7 @@ 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) {
dev_err(data->dev, "failed to set humidity oversampling");
return ret;
}
@@ -1856,7 +1856,7 @@ 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) {
dev_err(data->dev, "failed to read calibration parameters\n");
return ret;
}
@@ -2177,7 +2177,7 @@ 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) {
dev_err(data->dev, "failed to read chip id\n");
return ret;
}
@@ -2200,7 +2200,7 @@ int bmp280_common_probe(struct device *dev,
}
ret = data->chip_info->chip_config(data);
- if (ret < 0)
+ if (ret)
return ret;
dev_set_drvdata(dev, indio_dev);
@@ -2213,7 +2213,7 @@ int bmp280_common_probe(struct device *dev,
if (data->chip_info->read_calib) {
ret = data->chip_info->read_calib(data);
- if (ret < 0)
+ if (ret)
return dev_err_probe(data->dev, ret,
"failed to read calibration coefficients\n");
}
--
2.25.1
next prev parent reply other threads:[~2024-05-08 16:52 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
2024-05-08 16:52 ` Vasileios Amoiridis [this message]
2024-05-12 12:11 ` [PATCH v6 3/9] iio: pressure: bmp280: Make error checks consistent 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=20240508165207.145554-4-vassilisamir@gmail.com \
--to=vassilisamir@gmail.com \
--cc=579lpy@gmail.com \
--cc=ak@it-klinger.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ang.iglesiasg@gmail.com \
--cc=jic23@kernel.org \
--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 \
/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