Re: [PATCH v4 2/4] iio: adc: mcp3911: simplify usage of spi->dev in probe function
From: Andy Shevchenko
Date: Tue Aug 08 2023 - 13:28:39 EST
On Tue, Aug 08, 2023 at 01:04:30PM +0200, Marcus Folkesson wrote:
> Replace the usage of adc->spi->dev with spi->dev to make the code prettier.
Suggested-by: ?
> Signed-off-by: Marcus Folkesson <marcus.folkesson@xxxxxxxxx>
...
> - adc->vref = devm_regulator_get_optional(&adc->spi->dev, "vref");
> + adc->vref = devm_regulator_get_optional(&spi->dev, "vref");
Why not
struct device *dev = &spi->dev;
and all the rest accordingly?
> if (IS_ERR(adc->vref)) {
> if (PTR_ERR(adc->vref) == -ENODEV) {
> adc->vref = NULL;
> } else {
> - dev_err(&adc->spi->dev,
> + dev_err(&spi->dev,
> "failed to get regulator (%ld)\n",
> PTR_ERR(adc->vref));
> return PTR_ERR(adc->vref);
Actually, you may first to switch to dev_err_probe() with the above introduced
struct device *dev = &spi->dev;
...
return dev_err_probe(dev, PTR_ERR(adc->vref),
"failed to get regulator\n",
and in the second patch do what you are doing here.
Will be much less changes and neater code at the end.
--
With Best Regards,
Andy Shevchenko