Skip to content

Commit 51ad3d3

Browse files
ubiedanashif
authored andcommitted
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>
1 parent 2258dcb commit 51ad3d3

File tree

4 files changed

+5
-29
lines changed

4 files changed

+5
-29
lines changed

drivers/sensor/vishay/vcnl36825t/vcnl36825t.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -242,26 +242,10 @@ static int vcnl36825t_init_registers(const struct device *dev)
242242
reg_value |= VCNL36825T_PS_IT_1T;
243243
data->meas_timeout_us *= 1 * VCNL36825T_FORCED_FACTOR_SCALE;
244244
break;
245-
case VCNL36825T_PROXIMITY_INTEGRATION_1_5T:
246-
reg_value |= VCNL36825T_PS_IT_1_5T;
247-
data->meas_timeout_us *= 1.5 * VCNL36825T_FORCED_FACTOR_SCALE;
248-
break;
249245
case VCNL36825T_PROXIMITY_INTEGRATION_2T:
250246
reg_value |= VCNL36825T_PS_IT_2T;
251247
data->meas_timeout_us *= 2 * VCNL36825T_FORCED_FACTOR_SCALE;
252248
break;
253-
case VCNL36825T_PROXIMITY_INTEGRATION_2_5T:
254-
reg_value |= VCNL36825T_PS_IT_2_5T;
255-
data->meas_timeout_us *= 2.5 * VCNL36825T_FORCED_FACTOR_SCALE;
256-
break;
257-
case VCNL36825T_PROXIMITY_INTEGRATION_3T:
258-
reg_value |= VCNL36825T_PS_IT_3T;
259-
data->meas_timeout_us *= 3 * VCNL36825T_FORCED_FACTOR_SCALE;
260-
break;
261-
case VCNL36825T_PROXIMITY_INTEGRATION_3_5T:
262-
reg_value |= VCNL36825T_PS_IT_3_5T;
263-
data->meas_timeout_us *= 3.5 * VCNL36825T_FORCED_FACTOR_SCALE;
264-
break;
265249
case VCNL36825T_PROXIMITY_INTEGRATION_4T:
266250
reg_value |= VCNL36825T_PS_IT_4T;
267251
data->meas_timeout_us *= 4 * VCNL36825T_FORCED_FACTOR_SCALE;

drivers/sensor/vishay/vcnl36825t/vcnl36825t.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,9 @@
9191
#define VCNL36825T_MPS_PULSES_8 (4 << VCNL36825T_PS_MPS_POS)
9292

9393
#define VCNL36825T_PS_IT_1T (0 << VCNL36825T_PS_IT_POS)
94-
#define VCNL36825T_PS_IT_1_5T (1 << VCNL36825T_PS_IT_POS)
95-
#define VCNL36825T_PS_IT_2T (2 << VCNL36825T_PS_IT_POS)
96-
#define VCNL36825T_PS_IT_2_5T (3 << VCNL36825T_PS_IT_POS)
97-
#define VCNL36825T_PS_IT_3T (4 << VCNL36825T_PS_IT_POS)
98-
#define VCNL36825T_PS_IT_3_5T (5 << VCNL36825T_PS_IT_POS)
99-
#define VCNL36825T_PS_IT_4T (6 << VCNL36825T_PS_IT_POS)
100-
#define VCNL36825T_PS_IT_8T (7 << VCNL36825T_PS_IT_POS)
94+
#define VCNL36825T_PS_IT_2T (1 << VCNL36825T_PS_IT_POS)
95+
#define VCNL36825T_PS_IT_4T (2 << VCNL36825T_PS_IT_POS)
96+
#define VCNL36825T_PS_IT_8T (3 << VCNL36825T_PS_IT_POS)
10197

10298
/* PS_CONF3 */
10399
#define VCNL36825T_PS_SP_INT_POS 2
@@ -241,11 +237,7 @@ enum vcnl36825t_measurement_period {
241237

242238
enum vcnl36825t_proximity_integration_time {
243239
VCNL36825T_PROXIMITY_INTEGRATION_1T,
244-
VCNL36825T_PROXIMITY_INTEGRATION_1_5T,
245240
VCNL36825T_PROXIMITY_INTEGRATION_2T,
246-
VCNL36825T_PROXIMITY_INTEGRATION_2_5T,
247-
VCNL36825T_PROXIMITY_INTEGRATION_3T,
248-
VCNL36825T_PROXIMITY_INTEGRATION_3_5T,
249241
VCNL36825T_PROXIMITY_INTEGRATION_4T,
250242
VCNL36825T_PROXIMITY_INTEGRATION_8T,
251243
};

dts/bindings/sensor/vishay,vcnl36825t.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ properties:
3939
proximity-it:
4040
type: string
4141
default: "1"
42-
enum: ["1", "1.5", "2", "2.5", "3", "3.5", "4", "8"]
42+
enum: ["1", "2", "4", "8"]
4343
description: |
4444
Proximity integration time in T.
4545
Defaults to sensor reset value.

tests/drivers/build_all/sensor/i2c.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ test_i2c_vishay_vcnl36825t: vcnl36825t@81 {
914914
compatible = "vishay,vcnl36825t";
915915
reg = <0x81>;
916916

917-
proximity-it = "3.5";
917+
proximity-it = "1";
918918
multi-pulse = <8>;
919919

920920
low-power;

0 commit comments

Comments
 (0)