power: pm8xxx-ccadc: fix incorrect gain and offset readings
The driver assumed that the gain and offset value can be negative.
gain and offset should always be interpreted as positive
numbers when read from the ccadc.
Change-Id: Iaecb181e0b7c224f24f666928bef3ca87fe6de8d
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
diff --git a/drivers/power/pm8xxx-ccadc.c b/drivers/power/pm8xxx-ccadc.c
index aeaedad..17cf53a 100644
--- a/drivers/power/pm8xxx-ccadc.c
+++ b/drivers/power/pm8xxx-ccadc.c
@@ -258,7 +258,7 @@
static void calib_ccadc_read_offset_and_gain(struct pm8xxx_ccadc_chip *chip,
int *gain, u16 *offset)
{
- s8 data_msb;
+ u8 data_msb;
u8 data_lsb;
int rc;
@@ -539,7 +539,8 @@
the_chip->ccadc_offset);
*voltage_uv = pm8xxx_ccadc_reading_to_microvolt(the_chip->revision,
((s64)result));
- pr_debug("Vsense before gain = %d uV\n", *voltage_uv);
+ pr_debug("Vsense before gain of %d = %d uV\n", the_chip->ccadc_gain_uv,
+ *voltage_uv);
*voltage_uv = pm8xxx_cc_adjust_for_gain(*voltage_uv);
pr_debug("Vsense = %d uV\n", *voltage_uv);