From: Jonathan Cameron <jic23@kernel.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-iio@vger.kernel.org,
Alison Schofield <amsfield22@gmail.com>,
"H. Nikolaus Schaller" <hns@goldelico.com>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio/adc/palmas: Use common error handling code in palmas_gpadc_calibrate()
Date: Thu, 26 Oct 2017 16:33:14 +0000 [thread overview]
Message-ID: <20171026173314.0bd5fd27@archlinux> (raw)
In-Reply-To: <0ae3662d-6a74-622c-0423-e8552ea79bca@users.sourceforge.net>
On Thu, 26 Oct 2017 08:08:49 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Oct 2017 07:58:03 +0200
>
> * Add a jump target so that a specific error message is stored only once
> at the end of this function implementation.
>
> * Adjust condition checks.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Markus,
You need to a apply a check in these cases. If the code is harder
to read afterwards and hence more prone to bugs being introduced
now or in future, it is not a good change.
As such I won't be taking this sort of change.
Jonathan
> ---
> drivers/iio/adc/palmas_gpadc.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
> index 69b9affeef1e..5e6566692d46 100644
> --- a/drivers/iio/adc/palmas_gpadc.c
> +++ b/drivers/iio/adc/palmas_gpadc.c
> @@ -304,17 +304,13 @@ static int palmas_gpadc_calibrate(struct palmas_gpadc *adc, int adc_chan)
>
> ret = palmas_read(adc->palmas, PALMAS_TRIM_GPADC_BASE,
> adc->adc_info[adc_chan].trim1_reg, &d1);
> - if (ret < 0) {
> - dev_err(adc->dev, "TRIM read failed: %d\n", ret);
> - goto scrub;
> - }
> + if (ret)
> + goto report_failure;
>
> ret = palmas_read(adc->palmas, PALMAS_TRIM_GPADC_BASE,
> adc->adc_info[adc_chan].trim2_reg, &d2);
> - if (ret < 0) {
> - dev_err(adc->dev, "TRIM read failed: %d\n", ret);
> - goto scrub;
> - }
> + if (ret)
> + goto report_failure;
>
> /* gain error calculation */
> k = (1000 + (1000 * (d2 - d1)) / (x2 - x1));
> @@ -329,6 +325,10 @@ static int palmas_gpadc_calibrate(struct palmas_gpadc *adc, int adc_chan)
>
> scrub:
> return ret;
> +
> +report_failure:
This makes for complex code flow where it is not needed. As such I am
not going to even think about taking this sort of patch.
> + dev_err(adc->dev, "TRIM read failed: %d\n", ret);
> + goto scrub;
> }
>
> static int palmas_gpadc_start_conversion(struct palmas_gpadc *adc, int adc_chan)
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@kernel.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-iio@vger.kernel.org,
Alison Schofield <amsfield22@gmail.com>,
"H. Nikolaus Schaller" <hns@goldelico.com>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio/adc/palmas: Use common error handling code in palmas_gpadc_calibrate()
Date: Thu, 26 Oct 2017 17:33:14 +0100 [thread overview]
Message-ID: <20171026173314.0bd5fd27@archlinux> (raw)
In-Reply-To: <0ae3662d-6a74-622c-0423-e8552ea79bca@users.sourceforge.net>
On Thu, 26 Oct 2017 08:08:49 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Oct 2017 07:58:03 +0200
>
> * Add a jump target so that a specific error message is stored only once
> at the end of this function implementation.
>
> * Adjust condition checks.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Markus,
You need to a apply a check in these cases. If the code is harder
to read afterwards and hence more prone to bugs being introduced
now or in future, it is not a good change.
As such I won't be taking this sort of change.
Jonathan
> ---
> drivers/iio/adc/palmas_gpadc.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
> index 69b9affeef1e..5e6566692d46 100644
> --- a/drivers/iio/adc/palmas_gpadc.c
> +++ b/drivers/iio/adc/palmas_gpadc.c
> @@ -304,17 +304,13 @@ static int palmas_gpadc_calibrate(struct palmas_gpadc *adc, int adc_chan)
>
> ret = palmas_read(adc->palmas, PALMAS_TRIM_GPADC_BASE,
> adc->adc_info[adc_chan].trim1_reg, &d1);
> - if (ret < 0) {
> - dev_err(adc->dev, "TRIM read failed: %d\n", ret);
> - goto scrub;
> - }
> + if (ret)
> + goto report_failure;
>
> ret = palmas_read(adc->palmas, PALMAS_TRIM_GPADC_BASE,
> adc->adc_info[adc_chan].trim2_reg, &d2);
> - if (ret < 0) {
> - dev_err(adc->dev, "TRIM read failed: %d\n", ret);
> - goto scrub;
> - }
> + if (ret)
> + goto report_failure;
>
> /* gain error calculation */
> k = (1000 + (1000 * (d2 - d1)) / (x2 - x1));
> @@ -329,6 +325,10 @@ static int palmas_gpadc_calibrate(struct palmas_gpadc *adc, int adc_chan)
>
> scrub:
> return ret;
> +
> +report_failure:
This makes for complex code flow where it is not needed. As such I am
not going to even think about taking this sort of patch.
> + dev_err(adc->dev, "TRIM read failed: %d\n", ret);
> + goto scrub;
> }
>
> static int palmas_gpadc_start_conversion(struct palmas_gpadc *adc, int adc_chan)
next prev parent reply other threads:[~2017-10-26 16:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 6:08 [PATCH] iio/adc/palmas: Use common error handling code in palmas_gpadc_calibrate() SF Markus Elfring
2017-10-26 6:08 ` SF Markus Elfring
2017-10-26 16:33 ` Jonathan Cameron [this message]
2017-10-26 16:33 ` Jonathan Cameron
2017-10-27 13:43 ` SF Markus Elfring
2017-10-27 13:43 ` SF Markus Elfring
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=20171026173314.0bd5fd27@archlinux \
--to=jic23@kernel.org \
--cc=amsfield22@gmail.com \
--cc=elfring@users.sourceforge.net \
--cc=hns@goldelico.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.