lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 5 May 2012 05:52:11 -0700
From:	Anton Vorontsov <cbouatmailru@...il.com>
To:	Mika Westerberg <mika.westerberg@...ux.intel.com>
Cc:	linux-kernel@...r.kernel.org, alan@...ux.intel.com,
	bruce.e.robertson@...el.com,
	"Pallala, Ramakrishna" <ramakrishna.pallala@...el.com>
Subject: Re: [PATCH 4/4] power-supply: smb347-charger: convert to regmap API

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@...ux.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@...il.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ