summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTimo Alho <talho@nvidia.com>2014-01-24 13:35:18 +0200
committerJuha Tukkinen <jtukkinen@nvidia.com>2014-01-30 03:59:20 -0800
commitd7fea349fde271a50670455588330f0f04b6e7b2 (patch)
tree6001c4ef5e0571e1ece1693e34729aaf46453d22 /drivers
parenta37ca473bdddc664aa1049b5c4ce965052ec8441 (diff)
edp: sysedp: fix ibat for negative temperatures
Negative temperatures where incorrectly handled when calculating maximum battery current. This patch fixes the issue. Change-Id: I446c2b9b6cf5586fbba11a4fe0906a38a7c654d1 Signed-off-by: Timo Alho <talho@nvidia.com> Reviewed-on: http://git-master/r/359854 (cherry picked from commit f63a5fa0d51a04befc2e113df91c076e0cab8e83) Reviewed-on: http://git-master/r/361476 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/edp/sysedp_batmon_calc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/edp/sysedp_batmon_calc.c b/drivers/edp/sysedp_batmon_calc.c
index 77bc9edc7807..feb961eb7142 100644
--- a/drivers/edp/sysedp_batmon_calc.c
+++ b/drivers/edp/sysedp_batmon_calc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -175,7 +175,7 @@ static s64 calc_ibat_esr(s64 ocv, s64 esr)
}
/* Calc IBAT for a given temperature */
-static int calc_ibat(unsigned int temp)
+static int calc_ibat(int temp)
{
struct sysedp_batmon_ibat_lut *p;
struct sysedp_batmon_ibat_lut *q;
@@ -185,13 +185,13 @@ static int calc_ibat(unsigned int temp)
while (p->ibat && p->temp > temp)
p++;
- if (p == pdata->ibat_lut || !p->ibat)
+ if (p == pdata->ibat_lut)
return p->ibat;
q = p - 1;
ibat = interpolate(temp, p->temp, p->ibat, q->temp, q->ibat);
- return ibat;
+ return ibat > 0 ? ibat : 0;
}
static s64 calc_pbat(s64 ocv, s64 ibat, s64 esr)