Commit 7cda467c authored by Luis Ubieda's avatar Luis Ubieda Committed by Anas Nashif
Browse files

sensor: vcnl36825t: Scrub redundant scaling on meas_timeout_us

Confirming the Proximity Integration is an integer, we don't need to
pre-apply the Scaling factor to then be accounted for when the actual
meas_timeout_us is calculated.

Signed-off-by: default avatarLuis Ubieda <luisf@croxel.com>
parent 51ad3d34
Loading
Loading
Loading
Loading
+5 −5
Changes for drivers/sensor/vishay/vcnl36825t/vcnl36825t.c: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -240,21 +240,21 @@ static int vcnl36825t_init_registers(const struct device *dev)
	switch (config->proximity_it) {
	case VCNL36825T_PROXIMITY_INTEGRATION_1T:
		reg_value |= VCNL36825T_PS_IT_1T;
		data->meas_timeout_us *= 1 * VCNL36825T_FORCED_FACTOR_SCALE;
		data->meas_timeout_us *= 1;
		break;
	case VCNL36825T_PROXIMITY_INTEGRATION_2T:
		reg_value |= VCNL36825T_PS_IT_2T;
		data->meas_timeout_us *= 2 * VCNL36825T_FORCED_FACTOR_SCALE;
		data->meas_timeout_us *= 2;
		break;
	case VCNL36825T_PROXIMITY_INTEGRATION_4T:
		reg_value |= VCNL36825T_PS_IT_4T;
		data->meas_timeout_us *= 4 * VCNL36825T_FORCED_FACTOR_SCALE;
		data->meas_timeout_us *= 4;
		break;
	case VCNL36825T_PROXIMITY_INTEGRATION_8T:
		__fallthrough;
	default:
		reg_value |= VCNL36825T_PS_IT_8T;
		data->meas_timeout_us *= 8 * VCNL36825T_FORCED_FACTOR_SCALE;
		data->meas_timeout_us *= 8;
		break;
	}

@@ -377,7 +377,7 @@ static int vcnl36825t_init_registers(const struct device *dev)
	 */
	data->meas_timeout_us =
		(data->meas_timeout_us * VCNL36825T_FORCED_FACTOR_SUM) /
			(VCNL36825T_FORCED_FACTOR_SCALE * VCNL36825T_FORCED_FACTOR_SCALE) +
			(VCNL36825T_FORCED_FACTOR_SCALE) +
		1;

	return 0;