Re: [PATCH v3 2/4] iio: temperature: ltc2983: convert to dev_err_probe()

From: Andy Shevchenko
Date: Thu Jun 06 2024 - 06:18:36 EST


On Thu, Jun 06, 2024 at 09:22:38AM +0200, Nuno Sa wrote:
> Use dev_err_probe() (and variants) in the probe() path. While at it, made
> some simple improvements:
> * Explicitly included the err.h and errno.h headers;
> * Removed some unnecessary line breaks;
> * Removed a redundant 'else';
> * Added some missing \n to prink.

...

> - if (ret) {
> + if (ret)
> /*
> * This would be catched later but we can just return
> * the error right away.
> */
> - dev_err(&st->spi->dev, "Property reg must be given\n");
> - return ERR_PTR(ret);
> - }
> + return dev_err_ptr_probe(&st->spi->dev, ret,
> + "Property reg must be given\n");

Even if it becomes a one line of code, it's still a multiline branch, due to
comment. I think {} is better to be there. What does checkpatch say about this?


...

> + return dev_err_ptr_probe(&st->spi->dev, -EINVAL,

You can make all these lines shorter by using

struct device *dev = &st->spi->dev; // or analogue

at the top of the function.

> + "Invalid chann:%d for RTD\n",
> + sensor->chan);

--
With Best Regards,
Andy Shevchenko