diff options
author | Philip Rakity <prakity@marvell.com> | 2011-08-12 21:18:18 -0700 |
---|---|---|
committer | Anton Vorontsov <cbouatmailru@gmail.com> | 2011-08-19 21:03:27 +0400 |
commit | 4cfa892c03b35f3c61d93e0d8d97ff8db074818f (patch) | |
tree | 81cc2a49230854abe1f7de1d78ce9ab1bb57bdb8 /drivers | |
parent | 45d116ec2503c4255374e11c2c48f81cdf6d0f1d (diff) |
max17042_battery: Divide by 0 crash because r_sns init too late
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>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | 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 98bfab35b8e..462845025ca 100644 --- a/drivers/power/max17042_battery.c +++ b/drivers/power/max17042_battery.c @@ -209,6 +209,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"); @@ -225,9 +228,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; |