Skip to content

Commit 0d01361

Browse files
Jeppe Odgaardkartben
authored andcommitted
drivers: sensor: ti: tmp11x: reuse variable
Reuse `value` variable in `tmp11x_attr_set` to reduce the number of local variables. Signed-off-by: Jeppe Odgaard <[email protected]>
1 parent ec02138 commit 0d01361

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/sensor/ti/tmp11x/tmp11x.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ static int tmp11x_attr_set(const struct device *dev,
350350
const struct tmp11x_dev_config *cfg = dev->config;
351351
struct tmp11x_data *drv_data = dev->data;
352352
int16_t value;
353-
uint16_t avg;
354353
int res = 0;
355354
bool store;
356355
int store_res = 0;
@@ -394,19 +393,19 @@ static int tmp11x_attr_set(const struct device *dev,
394393
/* sensor supports averaging 1, 8, 32 and 64 samples */
395394
switch (val->val1) {
396395
case 1:
397-
avg = TMP11X_AVG_1_SAMPLE;
396+
value = TMP11X_AVG_1_SAMPLE;
398397
break;
399398

400399
case 8:
401-
avg = TMP11X_AVG_8_SAMPLES;
400+
value = TMP11X_AVG_8_SAMPLES;
402401
break;
403402

404403
case 32:
405-
avg = TMP11X_AVG_32_SAMPLES;
404+
value = TMP11X_AVG_32_SAMPLES;
406405
break;
407406

408407
case 64:
409-
avg = TMP11X_AVG_64_SAMPLES;
408+
value = TMP11X_AVG_64_SAMPLES;
410409
break;
411410

412411
default:
@@ -415,7 +414,7 @@ static int tmp11x_attr_set(const struct device *dev,
415414
}
416415

417416
if (res == 0) {
418-
res = tmp11x_write_config(dev, TMP11X_CFGR_AVG, avg);
417+
res = tmp11x_write_config(dev, TMP11X_CFGR_AVG, value);
419418
}
420419

421420
break;

0 commit comments

Comments
 (0)