All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, MyungJoo Ham <myungjoo.ham@samsung.com>,
	Hans de Goede <hdegoede@redhat.com>, Chen-Yu Tsai <wens@csie.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] extcon: fix a missing check of regmap_read
Date: Tue, 19 Mar 2019 09:39:22 +0900	[thread overview]
Message-ID: <b902ff68-3054-80c3-f5c3-658fd0a1920e@samsung.com> (raw)
In-Reply-To: <20190318164121.13838-1-kjlu@umn.edu>

Hi,

On 19. 3. 19. 오전 1:41, Kangjie Lu wrote:
> When regmap_read fails, it doesn't make sense to use the read
> value "val" because it can be uninitialized.
> 
> The fix returns if regmap_read fails.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  drivers/extcon/extcon-axp288.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
> index a983708b77a6..b2ba5f073aa7 100644
> --- a/drivers/extcon/extcon-axp288.c
> +++ b/drivers/extcon/extcon-axp288.c
> @@ -143,6 +143,10 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
>  	int ret;
>  
>  	ret = regmap_read(info->regmap, AXP288_PS_BOOT_REASON_REG, &val);
> +	if (ret) {
> +		dev_dbg(info->dev, "regmap_read error %d\n", ret);

dev_err is correct for handling the error case
instead of dev_dbg. And I recommend that you use following error log
because extcon-axp288.c already used the 'failed to ...' log style.
If there is no special reason, you better to keep the consistency
for the readability.

- dev_err(info->dev, "failed to read BOOT_REASON_REG: %d\n", ret);

> +		return;
> +	}
>  	for (i = 0, rsi = axp288_pwr_up_down_info; *rsi; rsi++, i++) {
>  		if (val & BIT(i)) {
>  			dev_dbg(info->dev, "%s\n", *rsi);
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

  parent reply	other threads:[~2019-03-19  0:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190318164133epcas5p1a539488d8614011bdf4e734d76da4cc3@epcas5p1.samsung.com>
2019-03-18 16:41 ` [PATCH] extcon: fix a missing check of regmap_read Kangjie Lu
2019-03-18 17:30   ` Hans de Goede
2019-03-19  0:39   ` Chanwoo Choi [this message]
2019-03-20  7:35     ` Kangjie Lu
2019-03-20  8:00       ` Chanwoo Choi

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=b902ff68-3054-80c3-f5c3-658fd0a1920e@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=hdegoede@redhat.com \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=pakki001@umn.edu \
    --cc=wens@csie.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.