[PATCH] drivers: staging: iio: frequency: ad9832.h: Fixed TODO note.

Abdalla Al-Dalleh posted 1 patch 3 months, 1 week ago
drivers/staging/iio/frequency/ad9832.c |  3 +--
drivers/staging/iio/frequency/ad9832.h | 23 ------------------
include/linux/iio/dac/ad9832.h         | 33 ++++++++++++++++++++++++++
3 files changed, 34 insertions(+), 25 deletions(-)
create mode 100644 include/linux/iio/dac/ad9832.h
[PATCH] drivers: staging: iio: frequency: ad9832.h: Fixed TODO note.
Posted by Abdalla Al-Dalleh 3 months, 1 week ago
- drivers/staging/iio/frequency/ad9832.c: Changed .h file location
- drivers/staging/iio/frequency/ad9832.h: Removed struct definition
- include/linux/iio/dac/ad9832.h: Added header file according to the
  TODO note.

Signed-off-by: Abdalla Al-Dalleh <abdalla.ahmad@sesame.org.jo>
---
 drivers/staging/iio/frequency/ad9832.c |  3 +--
 drivers/staging/iio/frequency/ad9832.h | 23 ------------------
 include/linux/iio/dac/ad9832.h         | 33 ++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 25 deletions(-)
 create mode 100644 include/linux/iio/dac/ad9832.h

diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index 49388da5a684..4c7d618b2572 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -22,8 +22,7 @@
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
-
-#include "ad9832.h"
+#include <linux/iio/dac/ad9832.h>
 
 #include "dds.h"
 
diff --git a/drivers/staging/iio/frequency/ad9832.h b/drivers/staging/iio/frequency/ad9832.h
index d0d840edb8d2..a0819042a81e 100644
--- a/drivers/staging/iio/frequency/ad9832.h
+++ b/drivers/staging/iio/frequency/ad9832.h
@@ -7,27 +7,4 @@
 #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_ */
diff --git a/include/linux/iio/dac/ad9832.h b/include/linux/iio/dac/ad9832.h
new file mode 100644
index 000000000000..8259a0b0f981
--- /dev/null
+++ b/include/linux/iio/dac/ad9832.h
@@ -0,0 +1,33 @@
+/* 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_
+
+/*
+ * struct ad9832_platform_data moved from drivers/staging/iio/frequency/
+ */
+
+/**
+ * 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: [PATCH] drivers: staging: iio: frequency: ad9832.h: Fixed TODO note.
Posted by Greg Kroah-Hartman 3 months, 1 week ago
On Fri, Jun 27, 2025 at 08:51:14PM +0300, Abdalla Al-Dalleh wrote:
> - drivers/staging/iio/frequency/ad9832.c: Changed .h file location
> - drivers/staging/iio/frequency/ad9832.h: Removed struct definition
> - include/linux/iio/dac/ad9832.h: Added header file according to the
>   TODO note.
> 
> Signed-off-by: Abdalla Al-Dalleh <abdalla.ahmad@sesame.org.jo>
> ---
>  drivers/staging/iio/frequency/ad9832.c |  3 +--
>  drivers/staging/iio/frequency/ad9832.h | 23 ------------------
>  include/linux/iio/dac/ad9832.h         | 33 ++++++++++++++++++++++++++

Staging drivers need to be "self-contained" for now.

Why do you even need a .h file for a single .c file anyway?  Why not
just remove it?

thanks,

greg k-h
Re: [PATCH] drivers: staging: iio: frequency: ad9832.h: Fixed TODO note.
Posted by Jonathan Cameron 3 months, 1 week ago
On Sat, 28 Jun 2025 07:08:46 +0100
Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:

> On Fri, Jun 27, 2025 at 08:51:14PM +0300, Abdalla Al-Dalleh wrote:
> > - drivers/staging/iio/frequency/ad9832.c: Changed .h file location
> > - drivers/staging/iio/frequency/ad9832.h: Removed struct definition
> > - include/linux/iio/dac/ad9832.h: Added header file according to the
> >   TODO note.
> > 
> > Signed-off-by: Abdalla Al-Dalleh <abdalla.ahmad@sesame.org.jo>
> > ---
> >  drivers/staging/iio/frequency/ad9832.c |  3 +--
> >  drivers/staging/iio/frequency/ad9832.h | 23 ------------------
> >  include/linux/iio/dac/ad9832.h         | 33 ++++++++++++++++++++++++++  
> 
> Staging drivers need to be "self-contained" for now.
> 
> Why do you even need a .h file for a single .c file anyway?  Why not
> just remove it?
> 

Better yet would be to switch away from platform data as that belongs
to a long gone era.

However in this case it's all a bit pointless as we don't normally support 'power
up settings' of things like this. Power up state until someone opts in
should be to output nothing at all. That should be same as before the driver
loads if the device doesn't have non volatile storage to save a requested
setup from a previous boot.

The policy decision on what to output is a user space script problem, not
something that we should provide from firmware.

Jonathan


> thanks,
> 
> greg k-h
Re: [PATCH] drivers: staging: iio: frequency: ad9832.h: Fixed TODO note.
Posted by Andy Shevchenko 3 months, 1 week ago
On Fri, Jun 27, 2025 at 08:51:14PM +0300, Abdalla Al-Dalleh wrote:
> - drivers/staging/iio/frequency/ad9832.c: Changed .h file location
> - drivers/staging/iio/frequency/ad9832.h: Removed struct definition

Nothing of the above explains "why you are doing this".

> - include/linux/iio/dac/ad9832.h: Added header file according to the
>   TODO note.

Also it sounds like you put three different things in one basket.

...

>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> -

This blank line should stay. It will delimit the groups of headers.

> -#include "ad9832.h"
> +#include <linux/iio/dac/ad9832.h>
>  
>  #include "dds.h"

> +++ b/include/linux/iio/dac/ad9832.h
> @@ -0,0 +1,33 @@

Haven't you added -M -C when preparing the patch? This will make sure you are
really copying / moving the context and show only the differences.

...

> +struct ad9832_platform_data {
> +	unsigned long		freq0;
> +	unsigned long		freq1;
> +	unsigned short		phase0;
> +	unsigned short		phase1;
> +	unsigned short		phase2;
> +	unsigned short		phase3;
> +};

Ideally this should be dropped from any global header file. If one needs
something like this, it can be propagated via software nodes.

-- 
With Best Regards,
Andy Shevchenko