Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04e90273 authored by Siddartha Mohanadoss's avatar Siddartha Mohanadoss
Browse files

hwmon: qpnp-adc: use div64_s64 instead of do_div



Fix compiler warning about invalid use of do_div macro.
Use div64_s64 function to divide two signed 64-bit numbers.

Change-Id: I44bc6578584655694ace0bf12fae65a3a9c5cd09
Signed-off-by: default avatarSiddartha Mohanadoss <smohanad@codeaurora.org>
parent 554cec92
Loading
Loading
Loading
Loading
+37 −28
Original line number Diff line number Diff line
@@ -777,7 +777,8 @@ int32_t qpnp_adc_scale_pmic_therm(struct qpnp_vadc_chip *vadc,
		adc_chan_result->measurement = pmic_voltage*
			chan_properties->offset_gain_denominator;

		do_div(adc_chan_result->measurement,
		adc_chan_result->measurement =
			div64_s64(adc_chan_result->measurement,
			chan_properties->offset_gain_numerator * 2);
	} else
		adc_chan_result->measurement = 0;
@@ -805,9 +806,11 @@ int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr(struct qpnp_vadc_chip *chip,

	if (param->adc_tm_hc) {
		low_output *= param->full_scale_code;
		do_div(low_output, (QPNP_VADC_HC_VDD_REFERENCE_MV * 1000));
		low_output = div64_s64(low_output,
				(QPNP_VADC_HC_VDD_REFERENCE_MV * 1000));
		high_output *= param->full_scale_code;
		do_div(high_output, (QPNP_VADC_HC_VDD_REFERENCE_MV * 1000));
		high_output = div64_s64(high_output,
				(QPNP_VADC_HC_VDD_REFERENCE_MV * 1000));
	} else {
		rc = qpnp_get_vadc_gain_and_offset(chip, &btm_param,
							CALIB_ABSOLUTE);
@@ -822,7 +825,7 @@ int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr(struct qpnp_vadc_chip *chip,
			sign = 1;
			low_output = -low_output;
		}
		do_div(low_output, QPNP_ADC_625_UV);
		low_output = div64_s64(low_output, QPNP_ADC_625_UV);
		if (sign)
			low_output = -low_output;
		low_output += btm_param.adc_gnd;
@@ -834,7 +837,7 @@ int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr(struct qpnp_vadc_chip *chip,
			sign = 1;
			high_output = -high_output;
		}
		do_div(high_output, QPNP_ADC_625_UV);
		high_output = div64_s64(high_output, QPNP_ADC_625_UV);
		if (sign)
			high_output = -high_output;
		high_output += btm_param.adc_gnd;
@@ -885,7 +888,7 @@ int32_t qpnp_adc_tdkntcg_therm(struct qpnp_vadc_chip *chip,
			adc_properties, chan_properties, &xo_thm_voltage);

		if (chan_properties->calib_type == CALIB_ABSOLUTE)
			do_div(xo_thm_voltage, 1000);
			xo_thm_voltage = div64_s64(xo_thm_voltage, 1000);

		qpnp_adc_map_voltage_temp(adcmap_100k_104ef_104fb,
			ARRAY_SIZE(adcmap_100k_104ef_104fb),
@@ -1085,7 +1088,7 @@ int32_t qpnp_adc_scale_therm_pu2(struct qpnp_vadc_chip *chip,
			adc_properties, chan_properties, &therm_voltage);

		if (chan_properties->calib_type == CALIB_ABSOLUTE)
			do_div(therm_voltage, 1000);
			therm_voltage = div64_s64(therm_voltage, 1000);

		qpnp_adc_map_voltage_temp(adcmap_100k_104ef_104fb,
			ARRAY_SIZE(adcmap_100k_104ef_104fb),
@@ -1124,7 +1127,7 @@ int32_t qpnp_adc_tm_scale_voltage_therm_pu2(struct qpnp_vadc_chip *chip,
			adc_voltage = -adc_voltage;
		}

		do_div(adc_voltage, param1.dy);
		adc_voltage = div64_s64(adc_voltage, param1.dy);

		qpnp_adc_map_voltage_temp(adcmap_100k_104ef_104fb,
			ARRAY_SIZE(adcmap_100k_104ef_104fb),
@@ -1152,7 +1155,8 @@ int32_t qpnp_adc_tm_scale_therm_voltage_pu2(struct qpnp_vadc_chip *chip,
		if (rc)
			return rc;
		param->low_thr_voltage *= adc_properties->full_scale_code;
		do_div(param->low_thr_voltage, QPNP_VADC_HC_VDD_REFERENCE_MV);
		param->low_thr_voltage = div64_s64(param->low_thr_voltage,
						QPNP_VADC_HC_VDD_REFERENCE_MV);

		rc = qpnp_adc_map_temp_voltage(
			adcmap_100k_104ef_104fb_1875_vref,
@@ -1161,7 +1165,8 @@ int32_t qpnp_adc_tm_scale_therm_voltage_pu2(struct qpnp_vadc_chip *chip,
		if (rc)
			return rc;
		param->high_thr_voltage *= adc_properties->full_scale_code;
		do_div(param->high_thr_voltage, QPNP_VADC_HC_VDD_REFERENCE_MV);
		param->high_thr_voltage = div64_s64(param->high_thr_voltage,
						QPNP_VADC_HC_VDD_REFERENCE_MV);
	} else {
		qpnp_get_vadc_gain_and_offset(chip, &param1, CALIB_RATIOMETRIC);

@@ -1172,7 +1177,8 @@ int32_t qpnp_adc_tm_scale_therm_voltage_pu2(struct qpnp_vadc_chip *chip,
			return rc;

		param->low_thr_voltage *= param1.dy;
		do_div(param->low_thr_voltage, param1.adc_vref);
		param->low_thr_voltage = div64_s64(param->low_thr_voltage,
							param1.adc_vref);
		param->low_thr_voltage += param1.adc_gnd;

		rc = qpnp_adc_map_temp_voltage(adcmap_100k_104ef_104fb,
@@ -1182,7 +1188,8 @@ int32_t qpnp_adc_tm_scale_therm_voltage_pu2(struct qpnp_vadc_chip *chip,
			return rc;

		param->high_thr_voltage *= param1.dy;
		do_div(param->high_thr_voltage, param1.adc_vref);
		param->high_thr_voltage = div64_s64(param->high_thr_voltage,
							param1.adc_vref);
		param->high_thr_voltage += param1.adc_gnd;
	}

@@ -1281,11 +1288,11 @@ int32_t qpnp_adc_usb_scaler(struct qpnp_vadc_chip *chip,
	qpnp_get_vadc_gain_and_offset(chip, &usb_param, CALIB_RATIOMETRIC);

	*low_threshold = param->low_thr * usb_param.dy;
	do_div(*low_threshold, usb_param.adc_vref);
	*low_threshold = div64_s64(*low_threshold, usb_param.adc_vref);
	*low_threshold += usb_param.adc_gnd;

	*high_threshold = param->high_thr * usb_param.dy;
	do_div(*high_threshold, usb_param.adc_vref);
	*high_threshold = div64_s64(*high_threshold, usb_param.adc_vref);
	*high_threshold += usb_param.adc_gnd;

	pr_debug("high_volt:%d, low_volt:%d\n", param->high_thr,
@@ -1306,13 +1313,15 @@ int32_t qpnp_adc_absolute_rthr(struct qpnp_vadc_chip *chip,
		low_thr = (param->low_thr/param->gain_den);
		low_thr *= param->gain_num;
		low_thr *= param->full_scale_code;
		do_div(low_thr, (QPNP_VADC_HC_VDD_REFERENCE_MV * 1000));
		low_thr = div64_s64(low_thr,
				(QPNP_VADC_HC_VDD_REFERENCE_MV * 1000));
		*low_threshold = low_thr;

		high_thr = (param->high_thr/param->gain_den);
		high_thr *= param->gain_num;
		high_thr *= param->full_scale_code;
		do_div(high_thr, (QPNP_VADC_HC_VDD_REFERENCE_MV * 1000));
		high_thr = div64_s64(high_thr,
				(QPNP_VADC_HC_VDD_REFERENCE_MV * 1000));
		*high_threshold = high_thr;
	} else {
		rc = qpnp_get_vadc_gain_and_offset(chip, &vbatt_param,
@@ -1327,7 +1336,7 @@ int32_t qpnp_adc_absolute_rthr(struct qpnp_vadc_chip *chip,
			low_thr = -low_thr;
		}
		low_thr = low_thr * param->gain_num;
		do_div(low_thr, QPNP_ADC_625_UV);
		low_thr = div64_s64(low_thr, QPNP_ADC_625_UV);
		if (sign)
			low_thr = -low_thr;
		*low_threshold = low_thr + vbatt_param.adc_gnd;
@@ -1340,7 +1349,7 @@ int32_t qpnp_adc_absolute_rthr(struct qpnp_vadc_chip *chip,
			high_thr = -high_thr;
		}
		high_thr = high_thr * param->gain_num;
		do_div(high_thr, QPNP_ADC_625_UV);
		high_thr = div64_s64(high_thr, QPNP_ADC_625_UV);
		if (sign)
			high_thr = -high_thr;
		*high_threshold = high_thr + vbatt_param.adc_gnd;
@@ -1387,7 +1396,7 @@ int32_t qpnp_vadc_absolute_rthr(struct qpnp_vadc_chip *chip,
		low_thr = -low_thr;
	}
	low_thr = low_thr * chan_prop->offset_gain_numerator;
	do_div(low_thr, QPNP_ADC_625_UV);
	low_thr = div64_s64(low_thr, QPNP_ADC_625_UV);
	if (sign)
		low_thr = -low_thr;
	*low_threshold = low_thr + vbatt_param.adc_gnd;
@@ -1400,7 +1409,7 @@ int32_t qpnp_vadc_absolute_rthr(struct qpnp_vadc_chip *chip,
		high_thr = -high_thr;
	}
	high_thr = high_thr * chan_prop->offset_gain_numerator;
	do_div(high_thr, QPNP_ADC_625_UV);
	high_thr = div64_s64(high_thr, QPNP_ADC_625_UV);
	if (sign)
		high_thr = -high_thr;
	*high_threshold = high_thr + vbatt_param.adc_gnd;
@@ -1442,7 +1451,7 @@ int32_t qpnp_adc_btm_scaler(struct qpnp_vadc_chip *chip,

	pr_debug("low_output:%lld\n", low_output);
	low_output *= btm_param.dy;
	do_div(low_output, btm_param.adc_vref);
	low_output = div64_s64(low_output, btm_param.adc_vref);
	low_output += btm_param.adc_gnd;

	rc = qpnp_adc_map_voltage_temp(
@@ -1457,7 +1466,7 @@ int32_t qpnp_adc_btm_scaler(struct qpnp_vadc_chip *chip,

	pr_debug("high_output:%lld\n", high_output);
	high_output *= btm_param.dy;
	do_div(high_output, btm_param.adc_vref);
	high_output = div64_s64(high_output, btm_param.adc_vref);
	high_output += btm_param.adc_gnd;

	/* btm low temperature correspondes to high voltage threshold */
@@ -1500,7 +1509,7 @@ int32_t qpnp_adc_qrd_skuh_btm_scaler(struct qpnp_vadc_chip *chip,

	pr_debug("low_output:%lld\n", low_output);
	low_output *= btm_param.dy;
	do_div(low_output, btm_param.adc_vref);
	low_output = div64_s64(low_output, btm_param.adc_vref);
	low_output += btm_param.adc_gnd;

	rc = qpnp_adc_map_voltage_temp(
@@ -1515,7 +1524,7 @@ int32_t qpnp_adc_qrd_skuh_btm_scaler(struct qpnp_vadc_chip *chip,

	pr_debug("high_output:%lld\n", high_output);
	high_output *= btm_param.dy;
	do_div(high_output, btm_param.adc_vref);
	high_output = div64_s64(high_output, btm_param.adc_vref);
	high_output += btm_param.adc_gnd;

	/* btm low temperature correspondes to high voltage threshold */
@@ -1558,7 +1567,7 @@ int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *chip,

	pr_debug("low_output:%lld\n", low_output);
	low_output *= btm_param.dy;
	do_div(low_output, btm_param.adc_vref);
	low_output = div64_s64(low_output, btm_param.adc_vref);
	low_output += btm_param.adc_gnd;

	rc = qpnp_adc_map_voltage_temp(
@@ -1573,7 +1582,7 @@ int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *chip,

	pr_debug("high_output:%lld\n", high_output);
	high_output *= btm_param.dy;
	do_div(high_output, btm_param.adc_vref);
	high_output = div64_s64(high_output, btm_param.adc_vref);
	high_output += btm_param.adc_gnd;

	/* btm low temperature correspondes to high voltage threshold */
@@ -1616,7 +1625,7 @@ int32_t qpnp_adc_smb_btm_rscaler(struct qpnp_vadc_chip *chip,

	pr_debug("low_output:%lld\n", low_output);
	low_output *= btm_param.dy;
	do_div(low_output, btm_param.adc_vref);
	low_output = div64_s64(low_output, btm_param.adc_vref);
	low_output += btm_param.adc_gnd;

	rc = qpnp_adc_map_voltage_temp(
@@ -1631,7 +1640,7 @@ int32_t qpnp_adc_smb_btm_rscaler(struct qpnp_vadc_chip *chip,

	pr_debug("high_output:%lld\n", high_output);
	high_output *= btm_param.dy;
	do_div(high_output, btm_param.adc_vref);
	high_output = div64_s64(high_output, btm_param.adc_vref);
	high_output += btm_param.adc_gnd;

	/* btm low temperature correspondes to high voltage threshold */