Skip to content

Commit 53f4fda

Browse files
leaveyoustunjic23
authored andcommitted
iio: temperature: ltc2983: Fix macro parenthesization and rename
Wrap the 'chan' parameter in LTC2983_CHAN_START_ADDR() and LTC2983_CHAN_RES_ADDR() with parentheses to prevent potential macro argument expansion issues. Also rename LTC2983_CHAN_START_ADDR to LTC2983_CHAN_ASSIGN_ADDR and LTC2983_CHAN_RES_ADDR to LTC2983_RESULT_ADDR, to better reflect the datasheet names and avoid them being confused as related. Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Liviu Stan <liviu.stan@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 5cb9fdb commit 53f4fda

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/iio/temperature/ltc2983.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@
5656
#define LTC2983_EEPROM_WRITE_TIME_MS 2600
5757
#define LTC2983_EEPROM_READ_TIME_MS 20
5858

59-
#define LTC2983_CHAN_START_ADDR(chan) \
60-
(((chan - 1) * 4) + LTC2983_CHAN_ASSIGN_START_REG)
61-
#define LTC2983_CHAN_RES_ADDR(chan) \
62-
(((chan - 1) * 4) + LTC2983_TEMP_RES_START_REG)
59+
#define LTC2983_CHAN_ASSIGN_ADDR(chan) \
60+
((((chan) - 1) * 4) + LTC2983_CHAN_ASSIGN_START_REG)
61+
#define LTC2983_RESULT_ADDR(chan) \
62+
((((chan) - 1) * 4) + LTC2983_TEMP_RES_START_REG)
6363
#define LTC2983_THERMOCOUPLE_DIFF_MASK BIT(3)
6464
#define LTC2983_THERMOCOUPLE_SGL(x) \
6565
FIELD_PREP(LTC2983_THERMOCOUPLE_DIFF_MASK, x)
@@ -351,7 +351,7 @@ static int __ltc2983_chan_assign_common(struct ltc2983_data *st,
351351
const struct ltc2983_sensor *sensor,
352352
u32 chan_val)
353353
{
354-
u32 reg = LTC2983_CHAN_START_ADDR(sensor->chan);
354+
u32 reg = LTC2983_CHAN_ASSIGN_ADDR(sensor->chan);
355355

356356
chan_val |= LTC2983_CHAN_TYPE(sensor->type);
357357
dev_dbg(&st->spi->dev, "Assign reg:0x%04X, val:0x%08X\n", reg,
@@ -1196,7 +1196,7 @@ static int ltc2983_chan_read(struct ltc2983_data *st,
11961196
}
11971197

11981198
/* read the converted data */
1199-
ret = regmap_bulk_read(st->regmap, LTC2983_CHAN_RES_ADDR(sensor->chan),
1199+
ret = regmap_bulk_read(st->regmap, LTC2983_RESULT_ADDR(sensor->chan),
12001200
&st->temp, sizeof(st->temp));
12011201
if (ret)
12021202
return ret;

0 commit comments

Comments
 (0)