[PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function

Rodrigo Alencar via B4 Relay posted 11 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function
Posted by Rodrigo Alencar via B4 Relay 1 month, 2 weeks ago
From: Rodrigo Alencar <rodrigo.alencar@analog.com>

Create local device pointer in the probe function to shorten lines,
making the code easier to read.

Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
 drivers/iio/amplifiers/ad8366.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 6382106ee6c7..3456a31cb1ee 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -240,11 +240,12 @@ static const struct iio_chan_spec ada4961_channels[] = {
 
 static int ad8366_probe(struct spi_device *spi)
 {
+	struct device *dev = &spi->dev;
 	struct iio_dev *indio_dev;
 	struct ad8366_state *st;
 	int ret;
 
-	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
 	if (indio_dev == NULL)
 		return -ENOMEM;
 

-- 
2.43.0
Re: [PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function
Posted by Andy Shevchenko 1 month, 2 weeks ago
On Tue, Feb 10, 2026 at 07:42:04PM +0000, Rodrigo Alencar via B4 Relay wrote:

> Create local device pointer in the probe function to shorten lines,
> making the code easier to read.

Only a single place to convert?

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function
Posted by Andy Shevchenko 1 month, 2 weeks ago
On Tue, Feb 10, 2026 at 09:58:52PM +0200, Andy Shevchenko wrote:
> On Tue, Feb 10, 2026 at 07:42:04PM +0000, Rodrigo Alencar via B4 Relay wrote:
> 
> > Create local device pointer in the probe function to shorten lines,
> > making the code easier to read.
> 
> Only a single place to convert?

*Yes, I understand the intention, you need to explain that in the cover letter
and/or here in the comment block.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function
Posted by Jonathan Cameron 1 month, 2 weeks ago
On Tue, 10 Feb 2026 22:03:11 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Tue, Feb 10, 2026 at 09:58:52PM +0200, Andy Shevchenko wrote:
> > On Tue, Feb 10, 2026 at 07:42:04PM +0000, Rodrigo Alencar via B4 Relay wrote:
> >   
> > > Create local device pointer in the probe function to shorten lines,
> > > making the code easier to read.  
> > 
> > Only a single place to convert?  
> 
> *Yes, I understand the intention, you need to explain that in the cover letter
> and/or here in the comment block.
> 
Consistency matters, so once you have this local variable use it everywhere.

There are a few others in the code as it stands. If you are going to happen to
remove all those lines in later patches, then fair enough to perhaps add a comment
to say that you haven't touched them for reasons of churn avoidance.

If not I'd expect all spi->dev usage in probe to be replaced.

Jonathan