[PATCH v3 next 2/6] iio: sca3000: reuse device pointer for devm helpers

Harshit Mogalapalli posted 6 patches 6 days, 21 hours ago
There is a newer version of this series
[PATCH v3 next 2/6] iio: sca3000: reuse device pointer for devm helpers
Posted by Harshit Mogalapalli 6 days, 21 hours ago
Cache struct device *dev and feed it to the devm helpers to simplify
the probe function. No functional changes.

Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
v2 -> v3: Split this dev caching into a separate patch [Thanks David for
the suggestion ]
---
 drivers/iio/accel/sca3000.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index a0b431aff024..afe6ef61a53b 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -1440,11 +1440,12 @@ static const struct iio_info sca3000_info = {
 static int sca3000_probe(struct spi_device *spi)
 {
 	const struct spi_device_id *id = spi_get_device_id(spi);
+	struct device *dev = &spi->dev;
 	struct sca3000_state *st;
 	struct iio_dev *indio_dev;
 	int ret;
 
-	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
 	if (!indio_dev)
 		return -ENOMEM;
 
@@ -1466,7 +1467,7 @@ static int sca3000_probe(struct spi_device *spi)
 	}
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	ret = devm_iio_kfifo_buffer_setup(&spi->dev, indio_dev,
+	ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
 					  &sca3000_ring_setup_ops);
 	if (ret)
 		return ret;
-- 
2.47.3
Re: [PATCH v3 next 2/6] iio: sca3000: reuse device pointer for devm helpers
Posted by Andy Shevchenko 6 days, 18 hours ago
On Tue, Feb 03, 2026 at 04:20:46AM -0800, Harshit Mogalapalli wrote:
> Cache struct device *dev and feed it to the devm helpers to simplify
> the probe function. No functional changes.

With or without below being addressed,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

...

> -	ret = devm_iio_kfifo_buffer_setup(&spi->dev, indio_dev,
> +	ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
>  					  &sca3000_ring_setup_ops);

Now make it a single line, it's just 83 characters.

>  	if (ret)

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v3 next 2/6] iio: sca3000: reuse device pointer for devm helpers
Posted by Harshit Mogalapalli 6 days, 17 hours ago
On 03/02/26 20:47, Andy Shevchenko wrote:
> On Tue, Feb 03, 2026 at 04:20:46AM -0800, Harshit Mogalapalli wrote:
>> Cache struct device *dev and feed it to the devm helpers to simplify
>> the probe function. No functional changes.
> 
> With or without below being addressed,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 
> ...
> 
>> -	ret = devm_iio_kfifo_buffer_setup(&spi->dev, indio_dev,
>> +	ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
>>   					  &sca3000_ring_setup_ops);
> 
> Now make it a single line, it's just 83 characters.
> 

Sure, will do. I thought the wrap limit is 80, but there are other 
instances in this file where the columns exceeded 80. Will address this 
in my next version.

Thanks!

Regards,
Harshit



>>   	if (ret)
>