[RFC PATCH 1/3] staging: iio: ad9832: remove platform_data support

Tomas Borquez posted 3 patches 1 week, 3 days ago
[RFC PATCH 1/3] staging: iio: ad9832: remove platform_data support
Posted by Tomas Borquez 1 week, 3 days ago
Remove legacy platform_data support as there are no in tree users and
this approach belongs to a long gone era. The policy decision on what
to output is a userspace problem, not something that should be provided
from firmware.

The driver now initializes the device to a safe state (SLEEP|RESET|CLR)
outputting nothing. Userspace can configure the desired frequencies and
phases via the existing sysfs attributes once the device is ready to be 
used.

Original discussion started here [1].

Link: https://lore.kernel.org/linux-iio/20250628161040.3d21e2c4@jic23-huawei/ [1]
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Tomas Borquez <tomasborquez13@gmail.com>
---
 drivers/staging/iio/frequency/ad9832.c | 32 -------------------------
 drivers/staging/iio/frequency/ad9832.h | 33 --------------------------
 2 files changed, 65 deletions(-)
 delete mode 100644 drivers/staging/iio/frequency/ad9832.h

diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index 49388da5a6..e2ad3e5a7a 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -23,8 +23,6 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 
-#include "ad9832.h"
-
 #include "dds.h"
 
 /* Registers */
@@ -299,16 +297,10 @@ static const struct iio_info ad9832_info = {
 
 static int ad9832_probe(struct spi_device *spi)
 {
-	struct ad9832_platform_data *pdata = dev_get_platdata(&spi->dev);
 	struct iio_dev *indio_dev;
 	struct ad9832_state *st;
 	int ret;
 
-	if (!pdata) {
-		dev_dbg(&spi->dev, "no platform data?\n");
-		return -ENODEV;
-	}
-
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
 	if (!indio_dev)
 		return -ENOMEM;
@@ -379,30 +371,6 @@ static int ad9832_probe(struct spi_device *spi)
 		return ret;
 	}
 
-	ret = ad9832_write_frequency(st, AD9832_FREQ0HM, pdata->freq0);
-	if (ret)
-		return ret;
-
-	ret = ad9832_write_frequency(st, AD9832_FREQ1HM, pdata->freq1);
-	if (ret)
-		return ret;
-
-	ret = ad9832_write_phase(st, AD9832_PHASE0H, pdata->phase0);
-	if (ret)
-		return ret;
-
-	ret = ad9832_write_phase(st, AD9832_PHASE1H, pdata->phase1);
-	if (ret)
-		return ret;
-
-	ret = ad9832_write_phase(st, AD9832_PHASE2H, pdata->phase2);
-	if (ret)
-		return ret;
-
-	ret = ad9832_write_phase(st, AD9832_PHASE3H, pdata->phase3);
-	if (ret)
-		return ret;
-
 	return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
diff --git a/drivers/staging/iio/frequency/ad9832.h b/drivers/staging/iio/frequency/ad9832.h
deleted file mode 100644
index d0d840edb8..0000000000
--- a/drivers/staging/iio/frequency/ad9832.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * AD9832 SPI DDS driver
- *
- * Copyright 2011 Analog Devices Inc.
- */
-#ifndef IIO_DDS_AD9832_H_
-#define IIO_DDS_AD9832_H_
-
-/*
- * TODO: struct ad9832_platform_data needs to go into include/linux/iio
- */
-
-/**
- * struct ad9832_platform_data - platform specific information
- * @freq0:		power up freq0 tuning word in Hz
- * @freq1:		power up freq1 tuning word in Hz
- * @phase0:		power up phase0 value [0..4095] correlates with 0..2PI
- * @phase1:		power up phase1 value [0..4095] correlates with 0..2PI
- * @phase2:		power up phase2 value [0..4095] correlates with 0..2PI
- * @phase3:		power up phase3 value [0..4095] correlates with 0..2PI
- */
-
-struct ad9832_platform_data {
-	unsigned long		freq0;
-	unsigned long		freq1;
-	unsigned short		phase0;
-	unsigned short		phase1;
-	unsigned short		phase2;
-	unsigned short		phase3;
-};
-
-#endif /* IIO_DDS_AD9832_H_ */
-- 
2.43.0
Re: [RFC PATCH 1/3] staging: iio: ad9832: remove platform_data support
Posted by Andy Shevchenko 1 week, 2 days ago
On Fri, Dec 05, 2025 at 05:27:41PM -0300, Tomas Borquez wrote:
> Remove legacy platform_data support as there are no in tree users and
> this approach belongs to a long gone era. The policy decision on what
> to output is a userspace problem, not something that should be provided
> from firmware.
> 
> The driver now initializes the device to a safe state (SLEEP|RESET|CLR)
> outputting nothing. Userspace can configure the desired frequencies and
> phases via the existing sysfs attributes once the device is ready to be 

Tailing space on the above line (and the only line with this issue).

> used.
> 
> Original discussion started here [1].

The change LGTM, Jonathan, can you amend the above and apply it?
(Yes, I have read the discussion about removal the driver, but meanwhile
 the change is good on itself even if we are going to remove the driver.
 It just makes an additional harmless step in my opinion.)

FWIW,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko
Re: [RFC PATCH 1/3] staging: iio: ad9832: remove platform_data support
Posted by Jonathan Cameron 1 week, 1 day ago
On Sat, 6 Dec 2025 18:24:18 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Fri, Dec 05, 2025 at 05:27:41PM -0300, Tomas Borquez wrote:
> > Remove legacy platform_data support as there are no in tree users and
> > this approach belongs to a long gone era. The policy decision on what
> > to output is a userspace problem, not something that should be provided
> > from firmware.
> > 
> > The driver now initializes the device to a safe state (SLEEP|RESET|CLR)
> > outputting nothing. Userspace can configure the desired frequencies and
> > phases via the existing sysfs attributes once the device is ready to be   
> 
> Tailing space on the above line (and the only line with this issue).
> 
> > used.
> > 
> > Original discussion started here [1].  
> 
> The change LGTM, Jonathan, can you amend the above and apply it?
> (Yes, I have read the discussion about removal the driver, but meanwhile
>  the change is good on itself even if we are going to remove the driver.
>  It just makes an additional harmless step in my opinion.)
OK done. Small side note. If adding comments to link tags (e.g. the [1])
then use #[1].

b4 otherwise picks the thing up as two link tags. At least I think that is
what caused:

  [PATCH RFC 1/3] staging: iio: ad9832: remove platform_data support
    + Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
    + Link: ... [1]

Looks like something stripped the extra space anyway when I was applying.
I didn't bother to check what.

Jonathan

> 
> FWIW,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
>