power: max170xx: Fix CGAIN Conversion

If CGAIN is set to Max then the Sense Resistnace should
be doubled to account for 200% gain.

This will make hte reported Current Now data to be valid.

Change-Id: Iafad42d0470dd71ebfc16fb5135ff415f9d1f2b3
Signed-off-by: Kenny Kessler <kenny.kessler@motorola.com>
Reviewed-on: https://gerrit.mot.com/1256824
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Kenneth Kessler <kennykessler@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Kenny Kessler 2018-10-16 16:19:30 -05:00 • committed by Kenneth Kessler
commit 54d94ccc5d

View file

@ -2258,6 +2258,7 @@ static const struct power_supply_desc max17042_no_current_sense_psy_desc = {
.num_properties = ARRAY_SIZE(max17042_battery_props) - 2,
};
#define MAX_CGAIN 0x7FFF
static int max17042_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@ -2312,6 +2313,14 @@ static int max17042_probe(struct i2c_client *client,
if (chip->pdata->r_sns == 0)
chip->pdata->r_sns = MAX17042_DEFAULT_SNS_RESISTOR;
if (chip->pdata->config_data->cgain == MAX_CGAIN) {
dev_err(&client->dev, "RSNS is %d uOhm\n",
chip->pdata->r_sns);
chip->pdata->r_sns *= 2;
dev_err(&client->dev, "MAX CGAIN RSNS now %d uOhm\n",
chip->pdata->r_sns);
}
chip->fctr_uah_bit = 5000 / (chip->pdata->r_sns / 1000);
if (chip->pdata->init_data)