linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-pm@vger.kernel.org, Pali Roh?r <pali.rohar@gmail.com>,
	Sebastian Reichel <sre@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] bq2415x_charger: Use common error handling code in bq2415x_timer_work()
Date: Thu, 9 Nov 2017 13:08:42 +0100	[thread overview]
Message-ID: <20171109120842.GA28552@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <48b34d35-8c41-d25b-0cb7-6257b37c5a44@users.sourceforge.net>

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 30 Oct 2017 21:45:09 +0100
> 
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Better fix would be to display separate messages; user is probably
interested in what failed...
								Pavel

> ---
>  drivers/power/supply/bq2415x_charger.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c
> index c4770a94cc8e..8385e02e1634 100644
> --- a/drivers/power/supply/bq2415x_charger.c
> +++ b/drivers/power/supply/bq2415x_charger.c
> @@ -914,16 +914,12 @@ static void bq2415x_timer_work(struct work_struct *work)
>  	}
>  
>  	boost = bq2415x_exec_command(bq, BQ2415X_BOOST_MODE_STATUS);
> -	if (boost < 0) {
> -		bq2415x_timer_error(bq, "Unknown error");
> -		return;
> -	}
> +	if (boost < 0)
> +		goto report_timer_error;
>  
>  	error = bq2415x_exec_command(bq, BQ2415X_FAULT_STATUS);
> -	if (error < 0) {
> -		bq2415x_timer_error(bq, "Unknown error");
> -		return;
> -	}
> +	if (error < 0)
> +		goto report_timer_error;
>  
>  	if (boost) {
>  		switch (error) {
> @@ -992,6 +988,10 @@ static void bq2415x_timer_work(struct work_struct *work)
>  	}
>  
>  	schedule_delayed_work(&bq->work, BQ2415X_TIMER_TIMEOUT * HZ);
> +	return;
> +
> +report_timer_error:
> +	bq2415x_timer_error(bq, "Unknown error");
>  }
>  
>  /**** power supply interface code ****/

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  reply	other threads:[~2017-11-09 12:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-30 20:50 [PATCH] bq2415x_charger: Use common error handling code in bq2415x_timer_work() SF Markus Elfring
2017-11-09 12:08 ` Pavel Machek [this message]
2017-11-09 13:04   ` SF Markus Elfring
2017-11-09 13:14     ` Pali Rohár
2017-11-09 13:22       ` 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=20171109120842.GA28552@atrey.karlin.mff.cuni.cz \
    --to=pavel@ucw.cz \
    --cc=elfring@users.sourceforge.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    --cc=sre@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;
as well as URLs for NNTP newsgroup(s).