mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anton Vorontsov <cbouatmailru@gmail.com>
To: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, alan@linux.intel.com,
	bruce.e.robertson@intel.com, "Pallala,
	Ramakrishna" <ramakrishna.pallala@intel.com>
Subject: Re: [PATCH 4/4] power-supply: smb347-charger: convert to regmap API
Date: Sat, 5 May 2012 05:52:11 -0700	[thread overview]
Message-ID: <20120505125211.GA31577@lizard> (raw)
In-Reply-To: <1334566121-8243-4-git-send-email-mika.westerberg@linux.intel.com>

On Mon, Apr 16, 2012 at 11:48:41AM +0300, Mika Westerberg wrote:
> The smb347-charger driver does a lot of read-modify-write to the device
> registers. Instead of open-coding everything we can take advantage of regmap
> API which provides nice functions to do this kind of things.
> 
> In addition there is no need for custom debugfs file for dumping registers as
> this is already provided by the regmap API.
> 
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
[...]
>  static int smb347_set_temp_limits(struct smb347_charger *smb)
> @@ -491,22 +468,13 @@ static int smb347_set_temp_limits(struct smb347_charger *smb)
>  		val = clamp_val(val, 100, 130) - 100;
>  		val /= 10;
>  
> -		ret = smb347_read(smb, CFG_OTG);
> -		if (ret < 0)
> -			return ret;
> -
> -		ret &= ~CFG_OTG_TEMP_THRESHOLD_MASK;
> -		ret |= val << CFG_OTG_TEMP_THRESHOLD_SHIFT;
> -
> -		ret = smb347_write(smb, CFG_OTG, ret);
> +		ret = regmap_update_bits(smb->regmap, CFG_OTG,
> +					 CFG_OTG_TEMP_THRESHOLD_MASK,
> +					 val << CFG_OTG_TEMP_THRESHOLD_SHIFT);
>  		if (ret < 0)
>  			return ret;
>  	}
>  
> -	ret = smb347_read(smb, CFG_TEMP_LIMIT);
> -	if (ret < 0)
> -		return ret;
> -

FYI, removing these hunks causes the following warning:

  CC      drivers/power/smb347-charger.o
  drivers/power/smb347-charger.c: In function ‘smb347_set_temp_limits’:
  drivers/power/smb347-charger.c:462:6: warning: ‘ret’ may be used uninitialized in this function [-Wuninitialized]

I fixed this by the following change:

diff --git a/drivers/power/smb347-charger.c b/drivers/power/smb347-charger.c
index 1f27d21..cf31b31 100644
--- a/drivers/power/smb347-charger.c
+++ b/drivers/power/smb347-charger.c
@@ -459,7 +459,8 @@ static int smb347_set_voltage_limits(struct smb347_charger *smb)
 static int smb347_set_temp_limits(struct smb347_charger *smb)
 {
 	bool enable_therm_monitor = false;
-	int ret, val;
+	int ret = 0;
+	int val;
 
 	if (smb->pdata->chip_temp_threshold) {
 		val = smb->pdata->chip_temp_threshold;

Please check if that's all OK.

Thanks!

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

  reply	other threads:[~2012-05-05 12:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-16  8:48 [PATCH 1/4] power-supply: smb347-charger: convert to use module_i2c_driver() Mika Westerberg
2012-04-16  8:48 ` [PATCH 2/4] power-supply: smb347-charger: rename few functions to match better what they are doing Mika Westerberg
2012-04-16  8:48 ` [PATCH 3/4] power-supply: smb347-charger: move IRQ enabling to the end of probe Mika Westerberg
2012-04-16  8:48 ` [PATCH 4/4] power-supply: smb347-charger: convert to regmap API Mika Westerberg
2012-05-05 12:52   ` Anton Vorontsov [this message]
2012-05-06  6:34     ` Mika Westerberg
2012-05-05 12:56 ` [PATCH 1/4] power-supply: smb347-charger: convert to use module_i2c_driver() Anton Vorontsov

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=20120505125211.GA31577@lizard \
    --to=cbouatmailru@gmail.com \
    --cc=alan@linux.intel.com \
    --cc=bruce.e.robertson@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=ramakrishna.pallala@intel.com \
    /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

Powered by JetHome