summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorRobert Chiras <robert.chiras@nxp.com>2017-03-16 12:20:45 +0200
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:26:05 +0800
commit1f497f31f35bd3a2ee9e4908b5dc7e8e0d78d1a5 (patch)
tree29ab9d388f3cbdea8f2271d77e7c1e52414f870b /drivers/power
parentad42ef75e6ea73f8ffcb44956a4bfefca591914c (diff)
MLK-14473: touchscreen: Fix return type
The touchscreen driver, max11801, which is on 12c2 bus, won't be probed when using the hdcp specific DTS (this is disabling 12c2, since it will acquire it for DDC communications). Since this driver won't be probed, it will spam the dmesg with the pr_err from max11801_read_adc() function. This function is periodically called by the battery driver. For this reason, I removed the pr_err() call. Also, to be noticed that the function signature is u32, but in case of an error it will return a negative integer. In order to correctly propagate errors, I changed the function signature to int. This is safe, since the read value from i2c is on 16 bits (MSB and LSB on 8 bits). Also, the function calibration_voltage is calling max11801_read_adc from touchscreen driverm which can return negative values in case of an error. I case of an error, just stop reading ADC data and return 0 as voltage_data. Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/sabresd_battery.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/power/supply/sabresd_battery.c b/drivers/power/supply/sabresd_battery.c
index 042ee5b1c37f..5f479f83525a 100644
--- a/drivers/power/supply/sabresd_battery.c
+++ b/drivers/power/supply/sabresd_battery.c
@@ -193,7 +193,7 @@ static enum power_supply_property max8903_battery_props[] = {
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
};
-extern u32 max11801_read_adc(void);
+extern int max11801_read_adc(void);
static void max8903_charger_update_status(struct max8903_data *data)
{
@@ -227,6 +227,7 @@ static void max8903_charger_update_status(struct max8903_data *data)
u32 calibration_voltage(struct max8903_data *data)
{
u32 voltage_data = 0;
+ int adc_val = 0;
int i;
int offset;
@@ -238,8 +239,13 @@ u32 calibration_voltage(struct max8903_data *data)
offset = offset_charger;
/* simple average */
- for (i = 0; i < ADC_SAMPLE_COUNT; i++)
- voltage_data += max11801_read_adc()-offset;
+ for (i = 0; i < ADC_SAMPLE_COUNT; i++) {
+ adc_val = max11801_read_adc();
+ /* Check if touch driver is probed */
+ if (max11801_read_adc() < 0)
+ break;
+ voltage_data += adc_val - offset;
+ }
voltage_data = voltage_data / ADC_SAMPLE_COUNT;
dev_dbg(data->dev, "volt: %d\n", voltage_data);