From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<lars@metafoo.de>, <Michael.Hennerich@analog.com>,
<dragos.bogdan@analog.com>
Subject: Re: [PATCH 04/10] iio: imu: adis16480: check ret val for non-zero vs less-than-zero
Date: Sun, 3 Nov 2019 10:27:49 +0000 [thread overview]
Message-ID: <20191103102749.7507e410@archlinux> (raw)
In-Reply-To: <20191101093505.9408-5-alexandru.ardelean@analog.com>
On Fri, 1 Nov 2019 11:34:59 +0200
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
> The ADIS library functions return zero on success, and negative values for
> error. Positive values aren't returned, but we only care about the success
> value (which is zero).
>
> This change is mostly needed so that the compiler won't make any inferences
> about some about values being potentially un-initialized. This only
> triggers after making some functions inline, because the compiler can
> better follow return paths.
>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied.
Thanks,
Jonathan
> ---
> drivers/iio/imu/adis16480.c | 28 ++++++++++++++--------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index b99d73887c9f..86801f3c5f0d 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -181,7 +181,7 @@ static ssize_t adis16480_show_firmware_revision(struct file *file,
> int ret;
>
> ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_REV, &rev);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> len = scnprintf(buf, sizeof(buf), "%x.%x\n", rev >> 8, rev & 0xff);
> @@ -206,11 +206,11 @@ static ssize_t adis16480_show_firmware_date(struct file *file,
> int ret;
>
> ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_Y, &year);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_FIRM_DM, &md);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> len = snprintf(buf, sizeof(buf), "%.2x-%.2x-%.4x\n",
> @@ -234,7 +234,7 @@ static int adis16480_show_serial_number(void *arg, u64 *val)
>
> ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_SERIAL_NUM,
> &serial);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> *val = serial;
> @@ -252,7 +252,7 @@ static int adis16480_show_product_id(void *arg, u64 *val)
>
> ret = adis_read_reg_16(&adis16480->adis, ADIS16480_REG_PROD_ID,
> &prod_id);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> *val = prod_id;
> @@ -270,7 +270,7 @@ static int adis16480_show_flash_count(void *arg, u64 *val)
>
> ret = adis_read_reg_32(&adis16480->adis, ADIS16480_REG_FLASH_CNT,
> &flash_count);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> *val = flash_count;
> @@ -359,7 +359,7 @@ static int adis16480_get_freq(struct iio_dev *indio_dev, int *val, int *val2)
> reg = ADIS16480_REG_DEC_RATE;
>
> ret = adis_read_reg_16(&st->adis, reg, &t);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> /*
> @@ -462,7 +462,7 @@ static int adis16480_get_calibbias(struct iio_dev *indio_dev,
> ret = -EINVAL;
> }
>
> - if (ret < 0)
> + if (ret)
> return ret;
>
> return IIO_VAL_INT;
> @@ -489,7 +489,7 @@ static int adis16480_get_calibscale(struct iio_dev *indio_dev,
> int ret;
>
> ret = adis_read_reg_16(&st->adis, reg, &val16);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> *scale = sign_extend32(val16, 15);
> @@ -535,7 +535,7 @@ static int adis16480_get_filter_freq(struct iio_dev *indio_dev,
> enable_mask = BIT(offset + 2);
>
> ret = adis_read_reg_16(&st->adis, reg, &val);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> if (!(val & enable_mask))
> @@ -561,7 +561,7 @@ static int adis16480_set_filter_freq(struct iio_dev *indio_dev,
> enable_mask = BIT(offset + 2);
>
> ret = adis_read_reg_16(&st->adis, reg, &val);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> if (freq == 0) {
> @@ -937,7 +937,7 @@ static int adis16480_enable_irq(struct adis *adis, bool enable)
> int ret;
>
> ret = adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> val &= ~ADIS16480_DRDY_EN_MSK;
> @@ -1115,7 +1115,7 @@ static int adis16480_ext_clk_config(struct adis16480 *st,
> int ret;
>
> ret = adis_read_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, &val);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> pin = adis16480_of_get_ext_clk_pin(st, of_node);
> @@ -1141,7 +1141,7 @@ static int adis16480_ext_clk_config(struct adis16480 *st,
> val |= mode;
>
> ret = adis_write_reg_16(&st->adis, ADIS16480_REG_FNCTIO_CTRL, val);
> - if (ret < 0)
> + if (ret)
> return ret;
>
> return clk_prepare_enable(st->ext_clk);
next prev parent reply other threads:[~2019-11-03 10:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-01 9:34 [PATCH 00/10] iio: adis: cleanups and fixes Alexandru Ardelean
2019-11-01 9:34 ` [PATCH 01/10] iio: gyro: adis16136: check ret val for non-zero vs less-than-zero Alexandru Ardelean
2019-11-03 10:15 ` Jonathan Cameron
2019-11-01 9:34 ` [PATCH 02/10] iio: imu: adis16400: " Alexandru Ardelean
2019-11-03 10:21 ` Jonathan Cameron
2019-11-04 7:40 ` Ardelean, Alexandru
2019-11-01 9:34 ` [PATCH 03/10] iio: imu: adis16460: " Alexandru Ardelean
2019-11-03 10:25 ` Jonathan Cameron
2019-11-01 9:34 ` [PATCH 04/10] iio: imu: adis16480: " Alexandru Ardelean
2019-11-03 10:27 ` Jonathan Cameron [this message]
2019-11-01 9:35 ` [PATCH 05/10] iio: imu: adis: " Alexandru Ardelean
2019-11-03 10:31 ` Jonathan Cameron
2019-11-01 9:35 ` [PATCH 06/10] iio: imu: adis16480: fix indentation of return statement Alexandru Ardelean
2019-11-03 10:35 ` Jonathan Cameron
2019-11-01 9:35 ` [PATCH 07/10] iio: imu: adis16480: prefer `unsigned int` over `unsigned` Alexandru Ardelean
2019-11-03 10:36 ` Jonathan Cameron
2019-11-01 9:35 ` [PATCH 08/10] iio: imu: adis16480: assign bias value only if operation succeeded Alexandru Ardelean
2019-11-03 10:41 ` Jonathan Cameron
2019-11-04 8:50 ` Ardelean, Alexandru
2019-11-01 9:35 ` [PATCH 09/10] iio: imu: adis: assign read val in debugfs hook only if op successful Alexandru Ardelean
2019-11-03 10:46 ` Jonathan Cameron
2019-11-01 9:35 ` [PATCH 10/10] iio: imu: adis: assign value only if return code zero in read funcs Alexandru Ardelean
2019-11-03 10:49 ` 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=20191103102749.7507e410@archlinux \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.ardelean@analog.com \
--cc=dragos.bogdan@analog.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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