hwmon: qpnp-adc: Add check for wrong calib data
Add check when adc calibration data are similar
for both reference channels and return error to
avoid division by zero errors.
Change-Id: Id884eb79f606fb7361fc47a96e7a6f009a113869
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
diff --git a/drivers/hwmon/qpnp-adc-common.c b/drivers/hwmon/qpnp-adc-common.c
index 6a52aa3..7bc8773 100644
--- a/drivers/hwmon/qpnp-adc-common.c
+++ b/drivers/hwmon/qpnp-adc-common.c
@@ -496,7 +496,8 @@
if (!chan_properties || !chan_properties->offset_gain_numerator ||
!chan_properties->offset_gain_denominator || !adc_properties
- || !adc_chan_result)
+ || !adc_chan_result
+ || !chan_properties->adc_graph[CALIB_ABSOLUTE].dy)
return -EINVAL;
pmic_voltage = (adc_code -