[PATCH v5 next 7/7] iio: sca3000: manage device registration with devm helper

Harshit Mogalapalli posted 7 patches 4 days, 11 hours ago
[PATCH v5 next 7/7] iio: sca3000: manage device registration with devm helper
Posted by Harshit Mogalapalli 4 days, 11 hours ago
Convert the iio registration to use devm_* helpers so the probe no
longer needs a separate cleanup path and remove callback can also drop
the unregister. After this there is no need for having a remove
callback, so remote it.

No functional change intended.

Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: David Lechner <dlechner@baylibe.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
v4->v5: Add RB from Andy.
---
 drivers/iio/accel/sca3000.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index cfc3353f7ffd..49abe4ece233 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -1510,18 +1510,7 @@ static int sca3000_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	ret = iio_device_register(indio_dev);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
-static void sca3000_remove(struct spi_device *spi)
-{
-	struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
-	iio_device_unregister(indio_dev);
+	return devm_iio_device_register(dev, indio_dev);
 }
 
 static const struct spi_device_id sca3000_id[] = {
@@ -1538,7 +1527,6 @@ static struct spi_driver sca3000_driver = {
 		.name = "sca3000",
 	},
 	.probe = sca3000_probe,
-	.remove = sca3000_remove,
 	.id_table = sca3000_id,
 };
 module_spi_driver(sca3000_driver);
-- 
2.47.3
Re: [PATCH v5 next 7/7] iio: sca3000: manage device registration with devm helper
Posted by Andy Shevchenko 4 days, 7 hours ago
On Thu, Feb 05, 2026 at 05:12:13AM -0800, Harshit Mogalapalli wrote:
> Convert the iio registration to use devm_* helpers so the probe no
> longer needs a separate cleanup path and remove callback can also drop
> the unregister. After this there is no need for having a remove
> callback, so remote it.
> 
> No functional change intended.

...

> -	struct iio_dev *indio_dev = spi_get_drvdata(spi);

Do you still need spi_set_drvdata() or analogue in the ->probe()?

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v5 next 7/7] iio: sca3000: manage device registration with devm helper
Posted by Harshit Mogalapalli 4 days, 7 hours ago
Hi Andy,

On 05/02/26 21:59, Andy Shevchenko wrote:
> On Thu, Feb 05, 2026 at 05:12:13AM -0800, Harshit Mogalapalli wrote:
>> Convert the iio registration to use devm_* helpers so the probe no
>> longer needs a separate cleanup path and remove callback can also drop
>> the unregister. After this there is no need for having a remove
>> callback, so remote it.
>>
>> No functional change intended.
> 
> ...
> 
>> -	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> 
> Do you still need spi_set_drvdata() or analogue in the ->probe()?
> 

That's a great catch, I don't see spi_get_drvdata() anymore after this 
series, so yes I think we should get rid of this.

Should I fold that into this patch in v6, as spi_get_drvdata() is also 
removed in this patch ?

Thanks,
Harshit
Re: [PATCH v5 next 7/7] iio: sca3000: manage device registration with devm helper
Posted by Andy Shevchenko 4 days, 7 hours ago
On Thu, Feb 5, 2026 at 6:51 PM Harshit Mogalapalli
<harshit.m.mogalapalli@oracle.com> wrote:
> On 05/02/26 21:59, Andy Shevchenko wrote:
> > On Thu, Feb 05, 2026 at 05:12:13AM -0800, Harshit Mogalapalli wrote:

...

> >> -    struct iio_dev *indio_dev = spi_get_drvdata(spi);
> >
> > Do you still need spi_set_drvdata() or analogue in the ->probe()?
> >
>
> That's a great catch, I don't see spi_get_drvdata() anymore after this
> series, so yes I think we should get rid of this.
>
> Should I fold that into this patch in v6, as spi_get_drvdata() is also
> removed in this patch ?

Ideally it should be done in this patch, but let's wait for Jonathan.
He usually may tweak these small things when applying.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v5 next 7/7] iio: sca3000: manage device registration with devm helper
Posted by Harshit Mogalapalli 4 days, 7 hours ago
Hi Andy,

On 05/02/26 22:26, Andy Shevchenko wrote:
> On Thu, Feb 5, 2026 at 6:51 PM Harshit Mogalapalli
> <harshit.m.mogalapalli@oracle.com> wrote:
>> On 05/02/26 21:59, Andy Shevchenko wrote:
>>> On Thu, Feb 05, 2026 at 05:12:13AM -0800, Harshit Mogalapalli wrote:
> 
> ...
> 
>>>> -    struct iio_dev *indio_dev = spi_get_drvdata(spi);
>>>
>>> Do you still need spi_set_drvdata() or analogue in the ->probe()?
>>>
>>
>> That's a great catch, I don't see spi_get_drvdata() anymore after this
>> series, so yes I think we should get rid of this.
>>
>> Should I fold that into this patch in v6, as spi_get_drvdata() is also
>> removed in this patch ?
> 
> Ideally it should be done in this patch, but let's wait for Jonathan.
> He usually may tweak these small things when applying.
> 

Also, while checking the patch now, I see I copied a wrong tag(RB with 
missing r in baylibre from [1])

So that's one more thing to fix. Let me know if v6 would be a preferred 
approach, I can do it.

Thanks,
Harshit

[1] 
https://lore.kernel.org/all/a5fa2f97-9ba3-4085-bfaf-a255d24a81f0@baylibre.com/

Re: [PATCH v5 next 7/7] iio: sca3000: manage device registration with devm helper
Posted by Andy Shevchenko 4 days, 7 hours ago
On Thu, Feb 05, 2026 at 10:30:31PM +0530, Harshit Mogalapalli wrote:
> On 05/02/26 22:26, Andy Shevchenko wrote:
> > On Thu, Feb 5, 2026 at 6:51 PM Harshit Mogalapalli
> > <harshit.m.mogalapalli@oracle.com> wrote:
> > > On 05/02/26 21:59, Andy Shevchenko wrote:
> > > > On Thu, Feb 05, 2026 at 05:12:13AM -0800, Harshit Mogalapalli wrote:

...

> > > > > -    struct iio_dev *indio_dev = spi_get_drvdata(spi);
> > > > 
> > > > Do you still need spi_set_drvdata() or analogue in the ->probe()?
> > > > 
> > > 
> > > That's a great catch, I don't see spi_get_drvdata() anymore after this
> > > series, so yes I think we should get rid of this.
> > > 
> > > Should I fold that into this patch in v6, as spi_get_drvdata() is also
> > > removed in this patch ?
> > 
> > Ideally it should be done in this patch, but let's wait for Jonathan.
> > He usually may tweak these small things when applying.
> > 
> 
> Also, while checking the patch now, I see I copied a wrong tag(RB with
> missing r in baylibre from [1])
> 
> So that's one more thing to fix. Let me know if v6 would be a preferred
> approach, I can do it.

Let's not hurry, wait for Jonathan to decide.

> [1] https://lore.kernel.org/all/a5fa2f97-9ba3-4085-bfaf-a255d24a81f0@baylibre.com/

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v5 next 7/7] iio: sca3000: manage device registration with devm helper
Posted by Jonathan Cameron 4 days, 4 hours ago
On Thu, 5 Feb 2026 19:12:50 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Thu, Feb 05, 2026 at 10:30:31PM +0530, Harshit Mogalapalli wrote:
> > On 05/02/26 22:26, Andy Shevchenko wrote:  
> > > On Thu, Feb 5, 2026 at 6:51 PM Harshit Mogalapalli
> > > <harshit.m.mogalapalli@oracle.com> wrote:  
> > > > On 05/02/26 21:59, Andy Shevchenko wrote:  
> > > > > On Thu, Feb 05, 2026 at 05:12:13AM -0800, Harshit Mogalapalli wrote:  
> 
> ...
> 
> > > > > > -    struct iio_dev *indio_dev = spi_get_drvdata(spi);  
> > > > > 
> > > > > Do you still need spi_set_drvdata() or analogue in the ->probe()?
> > > > >   
> > > > 
> > > > That's a great catch, I don't see spi_get_drvdata() anymore after this
> > > > series, so yes I think we should get rid of this.
> > > > 
> > > > Should I fold that into this patch in v6, as spi_get_drvdata() is also
> > > > removed in this patch ?  
> > > 
> > > Ideally it should be done in this patch, but let's wait for Jonathan.
> > > He usually may tweak these small things when applying.
I removed it.
> > >   
> > 
> > Also, while checking the patch now, I see I copied a wrong tag(RB with
> > missing r in baylibre from [1])
Fixed that up.
> > 
> > So that's one more thing to fix. Let me know if v6 would be a preferred
> > approach, I can do it.  
> 
> Let's not hurry, wait for Jonathan to decide.
> 
> > [1] https://lore.kernel.org/all/a5fa2f97-9ba3-4085-bfaf-a255d24a81f0@baylibre.com/  
> 

And applied to the testing branch of iio.git.  Note this will be
rebased after rc1 is out before I push it out as a branch linux-next picks
up.

thanks,

Jonathan
Re: [PATCH v5 next 7/7] iio: sca3000: manage device registration with devm helper
Posted by Harshit Mogalapalli 4 days, 4 hours ago
Hi Jonathan,

On 06/02/26 01:28, Jonathan Cameron wrote:
> And applied to the testing branch of iio.git.  Note this will be
> rebased after rc1 is out before I push it out as a branch linux-next picks
> up.
> 

Thanks a lot !


Regards,
Harshit
> thanks,
> 
> Jonathan