* [PATCH] power: max17042: divide by 0 Crash because r_sns init too late
@ 2011-08-13 4:18 Philip Rakity
0 siblings, 0 replies; 3+ messages in thread
From: Philip Rakity @ 2011-08-13 4:18 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org
Cc: Anton Vorontsov, Kyungmin Park, myungjoo.ham@samsung.com
On MMP2 brownstone divide by 0 error since probe sets r_sns
after calling power_supply_register.
Move the code up a few lines. r_sns comes from the platform
data.
PROP_CURRENT_AVG and PROP_CURRENT divide the result by r_sns.
Signed-off-by: Philip Rakity <prakity@marvell.com>
---
drivers/power/max17042_battery.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
index 9f0183c..4245806 100644
--- a/drivers/power/max17042_battery.c
+++ b/drivers/power/max17042_battery.c
@@ -210,6 +210,9 @@ static int __devinit max17042_probe(struct i2c_client *client,
if (!chip->pdata->enable_current_sense)
chip->battery.num_properties -= 2;
+ if (chip->pdata->r_sns == 0)
+ chip->pdata->r_sns = MAX17042_DEFAULT_SNS_RESISTOR;
+
ret = power_supply_register(&client->dev, &chip->battery);
if (ret) {
dev_err(&client->dev, "failed: power supply register\n");
@@ -226,9 +229,6 @@ static int __devinit max17042_probe(struct i2c_client *client,
max17042_write_reg(client, MAX17042_CGAIN, 0x0000);
max17042_write_reg(client, MAX17042_MiscCFG, 0x0003);
max17042_write_reg(client, MAX17042_LearnCFG, 0x0007);
- } else {
- if (chip->pdata->r_sns == 0)
- chip->pdata->r_sns = MAX17042_DEFAULT_SNS_RESISTOR;
}
return 0;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] power: max17042: divide by 0 Crash because r_sns init too late
@ 2011-08-16 6:10 MyungJoo Ham
2011-08-19 16:49 ` Anton Vorontsov
0 siblings, 1 reply; 3+ messages in thread
From: MyungJoo Ham @ 2011-08-16 6:10 UTC (permalink / raw)
To: Philip Rakity, linux-kernel@vger.kernel.org
Cc: Anton Vorontsov, 박경민
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=euc-kr, Size: 1825 bytes --]
Philip Rakity<prakity@marvell.com> Date : 2011-08-13 13:18 (GMT+09:00)
> On MMP2 brownstone divide by 0 error since probe sets r_sns
> after calling power_supply_register.
>
> Move the code up a few lines. r_sns comes from the platform
> data.
>
> PROP_CURRENT_AVG and PROP_CURRENT divide the result by r_sns.
>
> Signed-off-by: Philip Rakity
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
> ---
> drivers/power/max17042_battery.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
> index 9f0183c..4245806 100644
> --- a/drivers/power/max17042_battery.c
> +++ b/drivers/power/max17042_battery.c
> @@ -210,6 +210,9 @@ static int __devinit max17042_probe(struct i2c_client *client,
> if (!chip->pdata->enable_current_sense)
> chip->battery.num_properties -= 2;
>
> + if (chip->pdata->r_sns == 0)
> + chip->pdata->r_sns = MAX17042_DEFAULT_SNS_RESISTOR;
> +
> ret = power_supply_register(&client->dev, &chip->battery);
> if (ret) {
> dev_err(&client->dev, "failed: power supply register\n");
> @@ -226,9 +229,6 @@ static int __devinit max17042_probe(struct i2c_client *client,
> max17042_write_reg(client, MAX17042_CGAIN, 0x0000);
> max17042_write_reg(client, MAX17042_MiscCFG, 0x0003);
> max17042_write_reg(client, MAX17042_LearnCFG, 0x0007);
> - } else {
> - if (chip->pdata->r_sns == 0)
> - chip->pdata->r_sns = MAX17042_DEFAULT_SNS_RESISTOR;
> }
>
> return 0;
> --
> 1.7.0.4
>
>
MyungJoo Ham (ÇÔ¸íÁÖ)
Mobile Software Platform Lab,
Digital Media and Communications (DMC) Business
Samsung Electronics
cell: +82-10-6714-2858 / office: +82-31-279-8033ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] power: max17042: divide by 0 Crash because r_sns init too late
2011-08-16 6:10 [PATCH] power: max17042: divide by 0 Crash because r_sns init too late MyungJoo Ham
@ 2011-08-19 16:49 ` Anton Vorontsov
0 siblings, 0 replies; 3+ messages in thread
From: Anton Vorontsov @ 2011-08-19 16:49 UTC (permalink / raw)
To: MyungJoo Ham
Cc: Philip Rakity, linux-kernel@vger.kernel.org,
박경민
On Tue, Aug 16, 2011 at 06:10:13AM +0000, MyungJoo Ham wrote:
> Philip Rakity<prakity@marvell.com> Date : 2011-08-13 13:18 (GMT+09:00)
> > On MMP2 brownstone divide by 0 error since probe sets r_sns
> > after calling power_supply_register.
> >
> > Move the code up a few lines. r_sns comes from the platform
> > data.
> >
> > PROP_CURRENT_AVG and PROP_CURRENT divide the result by r_sns.
> >
> > Signed-off-by: Philip Rakity
>
> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Applied, thanks.
--
Anton Vorontsov
Email: cbouatmailru@gmail.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-19 16:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-16 6:10 [PATCH] power: max17042: divide by 0 Crash because r_sns init too late MyungJoo Ham
2011-08-19 16:49 ` Anton Vorontsov
-- strict thread matches above, loose matches on Subject: below --
2011-08-13 4:18 Philip Rakity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox