Re: [PATCH v3 2/8] iio: temperature: ltc2983: Use local device pointer consistently

From: Jonathan Cameron

Date: Fri May 22 2026 - 09:36:24 EST


On Thu, 21 May 2026 19:42:55 +0300
Liviu Stan <liviu.stan@xxxxxxxxxx> wrote:

> Some functions define a local 'dev' pointer but still use bare
> '&st->spi->dev' in some code paths, and some don't have it at all.
> Replace bare references with the local pointer for consistency.
>
> Signed-off-by: Liviu Stan <liviu.stan@xxxxxxxxxx>

Hi Liviu,

When doing this sort of change, one of the advantages is often that code lines
get shorter. So look at the lines touched and see if the wrapping remains
appropriate.

At least some of the cases I point out below already fitted on one line
under 80 chars but none the less they are now even shorter so that needs
tidying up. Note that a few other cases are just over 80 chars.
Take a look at those and decide if readability is improved much by just
going a few characters over. That line length isn't the hard rule it
used to be!

> ---
> Changes in v3:
> - Dropped the Fixes: tag
> - Fixed one remaining dev_dbg() call in __ltc2983_chan_assign_common()
> that was still using the raw device pointer instead of the dev local
> variable introduced by this patch
>
> drivers/iio/temperature/ltc2983.c | 83 +++++++++++++++++--------------
> 1 file changed, 47 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
> index 67a09934c5bd..d9dcf3e86696 100644
> --- a/drivers/iio/temperature/ltc2983.c
> +++ b/drivers/iio/temperature/ltc2983.c
> @@ -351,10 +351,11 @@ static int __ltc2983_chan_assign_common(struct ltc2983_data *st,
> const struct ltc2983_sensor *sensor,
> u32 chan_val)
> {
> + struct device *dev = &st->spi->dev;
> 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,
> + dev_dbg(dev, "Assign reg:0x%04X, val:0x%08X\n", reg,
> chan_val);

chan_val easily fits on the line above now. It actually did before
but given you are changing this lets tidy it up to;

dev_dbg(dev, "Assign reg:0x%04X, val:0x%08X\n", reg, chan_val);


> st->chan_val = cpu_to_be32(chan_val);
> return regmap_bulk_write(st->regmap, reg, &st->chan_val,




> @@ -1222,11 +1229,12 @@ static int ltc2983_read_raw(struct iio_dev *indio_dev,
> int *val, int *val2, long mask)
> {
> struct ltc2983_data *st = iio_priv(indio_dev);
> + struct device *dev = &st->spi->dev;
> int ret;
>
> /* sanity check */
> if (chan->address >= st->num_channels) {
> - dev_err(&st->spi->dev, "Invalid chan address:%ld",
> + dev_err(dev, "Invalid chan address:%ld",
> chan->address);

dev_err(dev, "Invalid chan address:%ld", chan->address);

> return -EINVAL;
> }

> @@ -1427,6 +1436,7 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st, unsigned int cmd,
> static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio)
> {
> u32 iio_chan_t = 0, iio_chan_v = 0, chan, iio_idx = 0, status;
> + struct device *dev = &st->spi->dev;
> int ret;
>
> /* make sure the device is up: start bit (7) is 0 and done bit (6) is 1 */
> @@ -1434,7 +1444,7 @@ static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio)
> LTC2983_STATUS_UP(status) == 1, 25000,
> 25000 * 10);
> if (ret)
> - return dev_err_probe(&st->spi->dev, ret,
> + return dev_err_probe(dev, ret,
> "Device startup timed out\n");

return dev_err_probe(dev, ret, "Device startup timed out\n");


>
> ret = regmap_update_bits(st->regmap, LTC2983_GLOBAL_CONFIG_REG,
> @@ -1535,12 +1545,13 @@ static const struct iio_info ltc2983_iio_info = {

> @@ -1589,10 +1600,10 @@ static int ltc2983_probe(struct spi_device *spi)
> if (ret)
> return ret;
>
> - ret = devm_request_irq(&spi->dev, spi->irq, ltc2983_irq_handler,
> + ret = devm_request_irq(dev, spi->irq, ltc2983_irq_handler,
> IRQF_TRIGGER_RISING, st->info->name, st);
> if (ret)
> - return dev_err_probe(&spi->dev, ret,
> + return dev_err_probe(dev, ret,
> "failed to request an irq\n");

return dev_err_probe(dev, ret, "failed to request an irq\n");

Thanks,

Jonathan




>