[PATCH v2 4/6] iio: adc: ad7380: use IIO_DECLARE_BUFFER_WITH_TS

David Lechner posted 6 patches 9 months, 3 weeks ago
There is a newer version of this series
[PATCH v2 4/6] iio: adc: ad7380: use IIO_DECLARE_BUFFER_WITH_TS
Posted by David Lechner 9 months, 3 weeks ago
Use IIO_DECLARE_BUFFER_WITH_TS to declare the buffer that gets used with
iio_push_to_buffers_with_ts(). This makes the code a bit easier to read
and understand.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---

As discussed in v1, this one stays u8 because it is used with both 16
and 32-bit word sizes.
---
 drivers/iio/adc/ad7380.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
index f93e6c67766aa89b18c1a7dec02ae8912f65261c..f89b195c644024151c14977fd43e279a67439fb1 100644
--- a/drivers/iio/adc/ad7380.c
+++ b/drivers/iio/adc/ad7380.c
@@ -909,8 +909,8 @@ struct ad7380_state {
 	 * Make the buffer large enough for MAX_NUM_CHANNELS 32-bit samples and
 	 * one 64-bit aligned 64-bit timestamp.
 	 */
-	u8 scan_data[ALIGN(MAX_NUM_CHANNELS * sizeof(u32), sizeof(s64))
-			   + sizeof(s64)] __aligned(IIO_DMA_MINALIGN);
+	IIO_DECLARE_BUFFER_WITH_TS(u8, scan_data, MAX_NUM_CHANNELS * sizeof(u32))
+		__aligned(IIO_DMA_MINALIGN);
 	/* buffers for reading/writing registers */
 	u16 tx;
 	u16 rx;

-- 
2.43.0
Re: [PATCH v2 4/6] iio: adc: ad7380: use IIO_DECLARE_BUFFER_WITH_TS
Posted by Andy Shevchenko 9 months, 3 weeks ago
On Wed, Apr 23, 2025 at 1:08 AM David Lechner <dlechner@baylibre.com> wrote:
>
> Use IIO_DECLARE_BUFFER_WITH_TS to declare the buffer that gets used with
> iio_push_to_buffers_with_ts(). This makes the code a bit easier to read
> and understand.

...

> +       IIO_DECLARE_BUFFER_WITH_TS(u8, scan_data, MAX_NUM_CHANNELS * sizeof(u32))

Btw, why not DECLARE_IIO_...() as other DECLARE_*() look like?

> +               __aligned(IIO_DMA_MINALIGN);

Forgot to drop and use the DMA variant?

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 4/6] iio: adc: ad7380: use IIO_DECLARE_BUFFER_WITH_TS
Posted by David Lechner 9 months, 3 weeks ago
On 4/22/25 5:33 PM, Andy Shevchenko wrote:
> On Wed, Apr 23, 2025 at 1:08 AM David Lechner <dlechner@baylibre.com> wrote:
>>
>> Use IIO_DECLARE_BUFFER_WITH_TS to declare the buffer that gets used with
>> iio_push_to_buffers_with_ts(). This makes the code a bit easier to read
>> and understand.
> 
> ...
> 
>> +       IIO_DECLARE_BUFFER_WITH_TS(u8, scan_data, MAX_NUM_CHANNELS * sizeof(u32))
> 
> Btw, why not DECLARE_IIO_...() as other DECLARE_*() look like?

IMHO, namespace should always go first and people who write DECLARE_NS_... are
doing it wrong. :-)

There is not existing DECLARE_IIO_ to match anyway.

> 
>> +               __aligned(IIO_DMA_MINALIGN);
> 
> Forgot to drop and use the DMA variant?
> 

oops!
Re: [PATCH v2 4/6] iio: adc: ad7380: use IIO_DECLARE_BUFFER_WITH_TS
Posted by Andy Shevchenko 9 months, 3 weeks ago
On Wed, Apr 23, 2025 at 1:41 AM David Lechner <dlechner@baylibre.com> wrote:
> On 4/22/25 5:33 PM, Andy Shevchenko wrote:
> > On Wed, Apr 23, 2025 at 1:08 AM David Lechner <dlechner@baylibre.com> wrote:

...

> >> +       IIO_DECLARE_BUFFER_WITH_TS(u8, scan_data, MAX_NUM_CHANNELS * sizeof(u32))
> >
> > Btw, why not DECLARE_IIO_...() as other DECLARE_*() look like?
>
> IMHO, namespace should always go first and people who write DECLARE_NS_... are
> doing it wrong. :-)

Not really. AFAICT it depends on the globality of the macro. Those,
which are defined in types.h are all DECLARE_something(). Which makes
sense. So the Q here is if the IIO macros like these ever go out for a
wider audience. But in any case this can be amended later (with maybe
a bit of additional churn).

> There is not existing DECLARE_IIO_ to match anyway.

True.

-- 
With Best Regards,
Andy Shevchenko