From: Jonathan Cameron <jic23@kernel.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Jacek Anaszewski <j.anaszewski@samsung.com>,
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/light/gp2ap020a00f: Use common error handling code in gp2ap020a00f_adjust_lux_mode()
Date: Thu, 26 Oct 2017 16:31:13 +0000 [thread overview]
Message-ID: <20171026173113.371995f3@archlinux> (raw)
In-Reply-To: <06da0424-1ec9-209e-a433-48288c49132b@users.sourceforge.net>
On Thu, 26 Oct 2017 10:00:21 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Oct 2017 09:50:21 +0200
>
> * Add jump targets so that two error messages are 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>
Same issue - readability is worse than without the patch so it is always
going to be rejected.
Hence I am not going to take this or anything similar, and I doubt anyone
else in the kernel will either...
Jonathan
> ---
> drivers/iio/light/gp2ap020a00f.c | 37 +++++++++++++++++--------------------
> 1 file changed, 17 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c
> index 44b13fbcd093..ae29bce660ac 100644
> --- a/drivers/iio/light/gp2ap020a00f.c
> +++ b/drivers/iio/light/gp2ap020a00f.c
> @@ -741,19 +741,13 @@ static bool gp2ap020a00f_adjust_lux_mode(struct gp2ap020a00f_data *data,
> */
> err = gp2ap020a00f_write_event_threshold(data,
> GP2AP020A00F_THRESH_TH, false);
> - if (err < 0) {
> - dev_err(&data->client->dev,
> - "Clearing als threshold register failed.\n");
> - return false;
> - }
> + if (err)
> + goto report_clearing_failure;
>
> err = gp2ap020a00f_write_event_threshold(data,
> GP2AP020A00F_THRESH_TL, false);
> - if (err < 0) {
> - dev_err(&data->client->dev,
> - "Clearing als threshold register failed.\n");
> - return false;
> - }
> + if (err)
> + goto report_clearing_failure;
>
> /* Change lux mode */
> err = regmap_update_bits(data->regmap,
> @@ -793,27 +787,30 @@ static bool gp2ap020a00f_adjust_lux_mode(struct gp2ap020a00f_data *data,
> if (test_bit(GP2AP020A00F_FLAG_ALS_RISING_EV, &data->flags)) {
> err = gp2ap020a00f_write_event_threshold(data,
> GP2AP020A00F_THRESH_TH, true);
> - if (err < 0) {
> - dev_err(&data->client->dev,
> - "Adjusting als threshold value failed.\n");
> - return false;
> - }
> + if (err)
> + goto report_adjustment_failure;
> }
>
> if (test_bit(GP2AP020A00F_FLAG_ALS_FALLING_EV, &data->flags)) {
> err = gp2ap020a00f_write_event_threshold(data,
> GP2AP020A00F_THRESH_TL, true);
> - if (err < 0) {
> - dev_err(&data->client->dev,
> - "Adjusting als threshold value failed.\n");
> - return false;
> - }
> + if (err)
> + goto report_adjustment_failure;
> }
>
> return true;
> }
>
> return false;
> +
> +report_clearing_failure:
> + dev_err(&data->client->dev,
> + "Clearing als threshold register failed.\n");
> + return false;
> +
> +report_adjustment_failure:
> + dev_err(&data->client->dev, "Adjusting als threshold value failed.\n");
> + return false;
> }
>
> static void gp2ap020a00f_output_to_lux(struct gp2ap020a00f_data *data,
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, Hartmut Knaack <knaack.h@gmx.de>,
Jacek Anaszewski <j.anaszewski@samsung.com>,
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/light/gp2ap020a00f: Use common error handling code in gp2ap020a00f_adjust_lux_mode()
Date: Thu, 26 Oct 2017 17:31:13 +0100 [thread overview]
Message-ID: <20171026173113.371995f3@archlinux> (raw)
In-Reply-To: <06da0424-1ec9-209e-a433-48288c49132b@users.sourceforge.net>
On Thu, 26 Oct 2017 10:00:21 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Oct 2017 09:50:21 +0200
>
> * Add jump targets so that two error messages are 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>
Same issue - readability is worse than without the patch so it is always
going to be rejected.
Hence I am not going to take this or anything similar, and I doubt anyone
else in the kernel will either...
Jonathan
> ---
> drivers/iio/light/gp2ap020a00f.c | 37 +++++++++++++++++--------------------
> 1 file changed, 17 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c
> index 44b13fbcd093..ae29bce660ac 100644
> --- a/drivers/iio/light/gp2ap020a00f.c
> +++ b/drivers/iio/light/gp2ap020a00f.c
> @@ -741,19 +741,13 @@ static bool gp2ap020a00f_adjust_lux_mode(struct gp2ap020a00f_data *data,
> */
> err = gp2ap020a00f_write_event_threshold(data,
> GP2AP020A00F_THRESH_TH, false);
> - if (err < 0) {
> - dev_err(&data->client->dev,
> - "Clearing als threshold register failed.\n");
> - return false;
> - }
> + if (err)
> + goto report_clearing_failure;
>
> err = gp2ap020a00f_write_event_threshold(data,
> GP2AP020A00F_THRESH_TL, false);
> - if (err < 0) {
> - dev_err(&data->client->dev,
> - "Clearing als threshold register failed.\n");
> - return false;
> - }
> + if (err)
> + goto report_clearing_failure;
>
> /* Change lux mode */
> err = regmap_update_bits(data->regmap,
> @@ -793,27 +787,30 @@ static bool gp2ap020a00f_adjust_lux_mode(struct gp2ap020a00f_data *data,
> if (test_bit(GP2AP020A00F_FLAG_ALS_RISING_EV, &data->flags)) {
> err = gp2ap020a00f_write_event_threshold(data,
> GP2AP020A00F_THRESH_TH, true);
> - if (err < 0) {
> - dev_err(&data->client->dev,
> - "Adjusting als threshold value failed.\n");
> - return false;
> - }
> + if (err)
> + goto report_adjustment_failure;
> }
>
> if (test_bit(GP2AP020A00F_FLAG_ALS_FALLING_EV, &data->flags)) {
> err = gp2ap020a00f_write_event_threshold(data,
> GP2AP020A00F_THRESH_TL, true);
> - if (err < 0) {
> - dev_err(&data->client->dev,
> - "Adjusting als threshold value failed.\n");
> - return false;
> - }
> + if (err)
> + goto report_adjustment_failure;
> }
>
> return true;
> }
>
> return false;
> +
> +report_clearing_failure:
> + dev_err(&data->client->dev,
> + "Clearing als threshold register failed.\n");
> + return false;
> +
> +report_adjustment_failure:
> + dev_err(&data->client->dev, "Adjusting als threshold value failed.\n");
> + return false;
> }
>
> static void gp2ap020a00f_output_to_lux(struct gp2ap020a00f_data *data,
next prev parent reply other threads:[~2017-10-26 16:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 8:00 [PATCH] iio/light/gp2ap020a00f: Use common error handling code in gp2ap020a00f_adjust_lux_mode() SF Markus Elfring
2017-10-26 8:00 ` SF Markus Elfring
2017-10-26 16:31 ` Jonathan Cameron [this message]
2017-10-26 16:31 ` Jonathan Cameron
2017-10-27 13:12 ` SF Markus Elfring
2017-10-27 13:12 ` 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=20171026173113.371995f3@archlinux \
--to=jic23@kernel.org \
--cc=elfring@users.sourceforge.net \
--cc=j.anaszewski@samsung.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.