From: Chanwoo Choi <cw00.choi@samsung.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/2] extcon: max14577: Use common error handling code in max14577_muic_set_path()
Date: Mon, 23 Oct 2017 00:57:22 +0000 [thread overview]
Message-ID: <59ED3E72.7010401@samsung.com> (raw)
In-Reply-To: <5cdefd84-066d-5379-43c8-76f5d3b8f7c4@users.sourceforge.net>
Hi,
As you commented, this patch might remove the redundant error message.
But, it makes the code more complicated in side of readability.
If max1577_muic_set_path() have to handle the additional core and exception handling
int the future, this patch might make it more difficult. So, I prefer existing code.
Thanks for your effort.
Regards,
Chanwoo Choi
On 2017년 10월 23일 02:51, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 22 Oct 2017 19:33:58 +0200
>
> 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>
> ---
> drivers/extcon/extcon-max14577.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
> index f6414b7fa5bc..3d4bf5d23236 100644
> --- a/drivers/extcon/extcon-max14577.c
> +++ b/drivers/extcon/extcon-max14577.c
> @@ -211,10 +211,8 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
> ret = max14577_update_reg(info->max14577->regmap,
> MAX14577_MUIC_REG_CONTROL1,
> CLEAR_IDBEN_MICEN_MASK, CTRL1_SW_OPEN);
> - if (ret < 0) {
> - dev_err(info->dev, "failed to update MUIC register\n");
> - return ret;
> - }
> + if (ret < 0)
> + goto report_failure;
>
> if (attached)
> ctrl1 = val;
> @@ -224,10 +222,8 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
> ret = max14577_update_reg(info->max14577->regmap,
> MAX14577_MUIC_REG_CONTROL1,
> CLEAR_IDBEN_MICEN_MASK, ctrl1);
> - if (ret < 0) {
> - dev_err(info->dev, "failed to update MUIC register\n");
> - return ret;
> - }
> + if (ret < 0)
> + goto report_failure;
>
> if (attached)
> ctrl2 |= CTRL2_CPEN_MASK; /* LowPwr=0, CPEn=1 */
> @@ -237,16 +233,18 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
> ret = max14577_update_reg(info->max14577->regmap,
> MAX14577_REG_CONTROL2,
> CTRL2_LOWPWR_MASK | CTRL2_CPEN_MASK, ctrl2);
> - if (ret < 0) {
> - dev_err(info->dev, "failed to update MUIC register\n");
> - return ret;
> - }
> + if (ret < 0)
> + goto report_failure;
>
> dev_dbg(info->dev,
> "CONTROL1 : 0x%02x, CONTROL2 : 0x%02x, state : %s\n",
> ctrl1, ctrl2, attached ? "attached" : "detached");
>
> return 0;
> +
> +report_failure:
> + dev_err(info->dev, "failed to update MUIC register\n");
> + return ret;
> }
>
> /*
>
next prev parent reply other threads:[~2017-10-23 0:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-22 17:50 [PATCH 0/2] extcon-max14577: Fine-tuning for max14577_muic_set_path() SF Markus Elfring
2017-10-22 17:51 ` [PATCH 1/2] extcon: max14577: Use common error handling code in max14577_muic_set_path() SF Markus Elfring
2017-10-22 18:59 ` Krzysztof Kozlowski
2017-10-22 20:15 ` SF Markus Elfring
2017-10-22 20:15 ` SF Markus Elfring
2017-10-23 0:57 ` Chanwoo Choi [this message]
2017-10-23 5:45 ` SF Markus Elfring
2017-10-23 5:45 ` SF Markus Elfring
2017-10-23 5:54 ` Chanwoo Choi
2017-10-23 5:54 ` Chanwoo Choi
2017-10-23 5:57 ` SF Markus Elfring
2017-10-23 5:57 ` SF Markus Elfring
2017-10-23 6:03 ` Chanwoo Choi
2017-10-23 6:03 ` Chanwoo Choi
2017-10-23 6:08 ` SF Markus Elfring
2017-10-23 6:08 ` 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=59ED3E72.7010401@samsung.com \
--to=cw00.choi@samsung.com \
--cc=kernel-janitors@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 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.