Re: [PATCH v2 1/7] iio: temperature: ltc2983: Fix macro parenthesization and rename
From: Jonathan Cameron
Date: Sat May 16 2026 - 12:43:41 EST
On Thu, 14 May 2026 17:46:48 +0300
Liviu Stan <liviu.stan@xxxxxxxxxx> wrote:
> 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.
>
> Fixes: f110f3188e5639c81c457b2b831d40dfe3891bdb ("iio: temperature: Add support for LTC2983")
Firstly 12 chars of the hash is enough.
Secondly why a fix at all?
Looks like a readability improvement but not something we'd backport.
Also as Sashiko points out you need to mention the additional parameter.
https://sashiko.dev/#/patchset/20260514144712.64374-1-liviu.stan%40analog.com
Also, build your series one patch at a time. This looks like it won't build.
Jonathan
> Signed-off-by: Liviu Stan <liviu.stan@xxxxxxxxxx>
> ---
> Changes in v2:
> - New patch.
>
> drivers/iio/temperature/ltc2983.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
> index 38e6f8dfd3b8..a292274e6ff0 100644
> --- a/drivers/iio/temperature/ltc2983.c
> +++ b/drivers/iio/temperature/ltc2983.c
> @@ -56,10 +56,10 @@
> #define LTC2983_EEPROM_WRITE_TIME_MS 2600
> #define LTC2983_EEPROM_READ_TIME_MS 20
>
> -#define LTC2983_CHAN_START_ADDR(chan) \
> - (((chan - 1) * 4) + LTC2983_CHAN_ASSIGN_START_REG)
> -#define LTC2983_CHAN_RES_ADDR(chan) \
> - (((chan - 1) * 4) + LTC2983_TEMP_RES_START_REG)
> +#define LTC2983_CHAN_ASSIGN_ADDR(chan) \
> + ((((chan) - 1) * 4) + LTC2983_CHAN_ASSIGN_START_REG)
> +#define LTC2983_RESULT_ADDR(chan, base) \
> + ((((chan) - 1) * 4) + (base))
> #define LTC2983_THERMOCOUPLE_DIFF_MASK BIT(3)
> #define LTC2983_THERMOCOUPLE_SGL(x) \
> FIELD_PREP(LTC2983_THERMOCOUPLE_DIFF_MASK, x)
> @@ -351,7 +351,7 @@ static int __ltc2983_chan_assign_common(struct ltc2983_data *st,
> const struct ltc2983_sensor *sensor,
> u32 chan_val)
> {
> - u32 reg = LTC2983_CHAN_START_ADDR(sensor->chan);
> + u32 reg = LTC2983_CHAN_ASSIGN_ADDR(sensor->chan);
>
> chan_val |= LTC2983_CHAN_TYPE(sensor->type);
> dev_dbg(&st->spi->dev, "Assign reg:0x%04X, val:0x%08X\n", reg,
> @@ -1197,7 +1197,7 @@ static int ltc2983_chan_read(struct ltc2983_data *st,
> }
>
> /* read the converted data */
> - ret = regmap_bulk_read(st->regmap, LTC2983_CHAN_RES_ADDR(sensor->chan),
> + ret = regmap_bulk_read(st->regmap, LTC2983_RESULT_ADDR(sensor->chan, base_reg),
> &st->temp, sizeof(st->temp));
> if (ret)
> return ret;