sensor: vcnl36825t: fix: Address CID 347083
Coverity found this legitimate issue: the datasheet specifies PS_IT being 2-bits long (1, 2, 4, 8) and this driver assumes more steps are available. Remove extraneous fields so the Proximity integration setting fits in the expected 16-bit value. Signed-off-by: Luis Ubieda <luisf@croxel.com>
This commit is contained in:
parent
2258dcb755
commit
51ad3d34bd
4 changed files with 5 additions and 29 deletions
|
@ -242,26 +242,10 @@ static int vcnl36825t_init_registers(const struct device *dev)
|
|||
reg_value |= VCNL36825T_PS_IT_1T;
|
||||
data->meas_timeout_us *= 1 * VCNL36825T_FORCED_FACTOR_SCALE;
|
||||
break;
|
||||
case VCNL36825T_PROXIMITY_INTEGRATION_1_5T:
|
||||
reg_value |= VCNL36825T_PS_IT_1_5T;
|
||||
data->meas_timeout_us *= 1.5 * VCNL36825T_FORCED_FACTOR_SCALE;
|
||||
break;
|
||||
case VCNL36825T_PROXIMITY_INTEGRATION_2T:
|
||||
reg_value |= VCNL36825T_PS_IT_2T;
|
||||
data->meas_timeout_us *= 2 * VCNL36825T_FORCED_FACTOR_SCALE;
|
||||
break;
|
||||
case VCNL36825T_PROXIMITY_INTEGRATION_2_5T:
|
||||
reg_value |= VCNL36825T_PS_IT_2_5T;
|
||||
data->meas_timeout_us *= 2.5 * VCNL36825T_FORCED_FACTOR_SCALE;
|
||||
break;
|
||||
case VCNL36825T_PROXIMITY_INTEGRATION_3T:
|
||||
reg_value |= VCNL36825T_PS_IT_3T;
|
||||
data->meas_timeout_us *= 3 * VCNL36825T_FORCED_FACTOR_SCALE;
|
||||
break;
|
||||
case VCNL36825T_PROXIMITY_INTEGRATION_3_5T:
|
||||
reg_value |= VCNL36825T_PS_IT_3_5T;
|
||||
data->meas_timeout_us *= 3.5 * VCNL36825T_FORCED_FACTOR_SCALE;
|
||||
break;
|
||||
case VCNL36825T_PROXIMITY_INTEGRATION_4T:
|
||||
reg_value |= VCNL36825T_PS_IT_4T;
|
||||
data->meas_timeout_us *= 4 * VCNL36825T_FORCED_FACTOR_SCALE;
|
||||
|
|
|
@ -91,13 +91,9 @@
|
|||
#define VCNL36825T_MPS_PULSES_8 (4 << VCNL36825T_PS_MPS_POS)
|
||||
|
||||
#define VCNL36825T_PS_IT_1T (0 << VCNL36825T_PS_IT_POS)
|
||||
#define VCNL36825T_PS_IT_1_5T (1 << VCNL36825T_PS_IT_POS)
|
||||
#define VCNL36825T_PS_IT_2T (2 << VCNL36825T_PS_IT_POS)
|
||||
#define VCNL36825T_PS_IT_2_5T (3 << VCNL36825T_PS_IT_POS)
|
||||
#define VCNL36825T_PS_IT_3T (4 << VCNL36825T_PS_IT_POS)
|
||||
#define VCNL36825T_PS_IT_3_5T (5 << VCNL36825T_PS_IT_POS)
|
||||
#define VCNL36825T_PS_IT_4T (6 << VCNL36825T_PS_IT_POS)
|
||||
#define VCNL36825T_PS_IT_8T (7 << VCNL36825T_PS_IT_POS)
|
||||
#define VCNL36825T_PS_IT_2T (1 << VCNL36825T_PS_IT_POS)
|
||||
#define VCNL36825T_PS_IT_4T (2 << VCNL36825T_PS_IT_POS)
|
||||
#define VCNL36825T_PS_IT_8T (3 << VCNL36825T_PS_IT_POS)
|
||||
|
||||
/* PS_CONF3 */
|
||||
#define VCNL36825T_PS_SP_INT_POS 2
|
||||
|
@ -241,11 +237,7 @@ enum vcnl36825t_measurement_period {
|
|||
|
||||
enum vcnl36825t_proximity_integration_time {
|
||||
VCNL36825T_PROXIMITY_INTEGRATION_1T,
|
||||
VCNL36825T_PROXIMITY_INTEGRATION_1_5T,
|
||||
VCNL36825T_PROXIMITY_INTEGRATION_2T,
|
||||
VCNL36825T_PROXIMITY_INTEGRATION_2_5T,
|
||||
VCNL36825T_PROXIMITY_INTEGRATION_3T,
|
||||
VCNL36825T_PROXIMITY_INTEGRATION_3_5T,
|
||||
VCNL36825T_PROXIMITY_INTEGRATION_4T,
|
||||
VCNL36825T_PROXIMITY_INTEGRATION_8T,
|
||||
};
|
||||
|
|
|
@ -39,7 +39,7 @@ properties:
|
|||
proximity-it:
|
||||
type: string
|
||||
default: "1"
|
||||
enum: ["1", "1.5", "2", "2.5", "3", "3.5", "4", "8"]
|
||||
enum: ["1", "2", "4", "8"]
|
||||
description: |
|
||||
Proximity integration time in T.
|
||||
Defaults to sensor reset value.
|
||||
|
|
|
@ -914,7 +914,7 @@ test_i2c_vishay_vcnl36825t: vcnl36825t@81 {
|
|||
compatible = "vishay,vcnl36825t";
|
||||
reg = <0x81>;
|
||||
|
||||
proximity-it = "3.5";
|
||||
proximity-it = "1";
|
||||
multi-pulse = <8>;
|
||||
|
||||
low-power;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue