diff mbox series

[v6,6/6] iio: filter: admv8818: Support frequencies >= 2^32

Message ID 20250307150216.374643-6-sam.winchenbach@framepointer.org (mailing list archive)
State New
Headers show
Series [v6,1/6] dt-bindings: iio: filter: Add lpf/hpf freq margins | expand

Commit Message

Sam Winchenbach March 7, 2025, 3:02 p.m. UTC
From: Brian Pellegrino <bpellegrino@arka.org>

This patch allows writing u64 values to the ADMV8818's high and low-pass
filter frequencies. It includes the following changes:

- Rejects negative frequencies in admv8818_write_raw.
- Adds a write_raw_get_fmt function to admv8818's iio_info, returning
  IIO_VAL_INT_64 for the high and low-pass filter 3dB frequency channels.

Fixes: f34fe888ad05 ("iio:filter:admv8818: add support for ADMV8818")
Signed-off-by: Brian Pellegrino <bpellegrino@arka.org>
Signed-off-by: Sam Winchenbach <sam.winchenbach@framepointer.org>
---
 drivers/iio/filter/admv8818.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Jonathan Cameron March 8, 2025, 2:01 p.m. UTC | #1
On Fri,  7 Mar 2025 10:02:16 -0500
Sam Winchenbach <sam.winchenbach@framepointer.org> wrote:

> From: Brian Pellegrino <bpellegrino@arka.org>
> 
> This patch allows writing u64 values to the ADMV8818's high and low-pass
> filter frequencies. It includes the following changes:
> 
> - Rejects negative frequencies in admv8818_write_raw.
> - Adds a write_raw_get_fmt function to admv8818's iio_info, returning
>   IIO_VAL_INT_64 for the high and low-pass filter 3dB frequency channels.
> 
> Fixes: f34fe888ad05 ("iio:filter:admv8818: add support for ADMV8818")
> Signed-off-by: Brian Pellegrino <bpellegrino@arka.org>
> Signed-off-by: Sam Winchenbach <sam.winchenbach@framepointer.org>
I only have that minor comment on patch 5.  If nothing else comes up
and the dt binding ack comes in I may just tidy that up whilst applying.

> ---
>  drivers/iio/filter/admv8818.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/iio/filter/admv8818.c b/drivers/iio/filter/admv8818.c
> index e9602bfd4af7..9785533d0cdd 100644
> --- a/drivers/iio/filter/admv8818.c
> +++ b/drivers/iio/filter/admv8818.c
> @@ -402,6 +402,19 @@ static int admv8818_read_lpf_freq(struct admv8818_state *st, u64 *lpf_freq)
>  	return ret;
>  }
>  
> +static int admv8818_write_raw_get_fmt(struct iio_dev *indio_dev,
> +								struct iio_chan_spec const *chan,
> +								long mask)
> +{
> +	switch (mask) {
> +	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> +	case IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY:
> +		return IIO_VAL_INT_64;
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
>  static int admv8818_write_raw(struct iio_dev *indio_dev,
>  			      struct iio_chan_spec const *chan,
>  			      int val, int val2, long info)
> @@ -410,6 +423,9 @@ static int admv8818_write_raw(struct iio_dev *indio_dev,
>  
>  	u64 freq = ((u64)val2 << 32 | (u32)val);
>  
> +	if ((s64)freq < 0)
> +		return -EINVAL;
> +
>  	switch (info) {
>  	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
>  		return admv8818_lpf_select(st, freq);
> @@ -571,6 +587,7 @@ static int admv8818_set_mode(struct iio_dev *indio_dev,
>  
>  static const struct iio_info admv8818_info = {
>  	.write_raw = admv8818_write_raw,
> +	.write_raw_get_fmt = admv8818_write_raw_get_fmt,
>  	.read_raw = admv8818_read_raw,
>  	.debugfs_reg_access = &admv8818_reg_access,
>  };
Sam Winchenbach March 12, 2025, 12:16 p.m. UTC | #2
On Sat, Mar 08, 2025 at 02:01:43PM +0000, Jonathan Cameron wrote:
> On Fri,  7 Mar 2025 10:02:16 -0500
> Sam Winchenbach <sam.winchenbach@framepointer.org> wrote:
> 
> > From: Brian Pellegrino <bpellegrino@arka.org>
> > 
> > This patch allows writing u64 values to the ADMV8818's high and low-pass
> > filter frequencies. It includes the following changes:
> > 
> > - Rejects negative frequencies in admv8818_write_raw.
> > - Adds a write_raw_get_fmt function to admv8818's iio_info, returning
> >   IIO_VAL_INT_64 for the high and low-pass filter 3dB frequency channels.
> > 
> > Fixes: f34fe888ad05 ("iio:filter:admv8818: add support for ADMV8818")
> > Signed-off-by: Brian Pellegrino <bpellegrino@arka.org>
> > Signed-off-by: Sam Winchenbach <sam.winchenbach@framepointer.org>
> I only have that minor comment on patch 5.  If nothing else comes up
> and the dt binding ack comes in I may just tidy that up whilst applying.
> 

Sounds good. If given the opportunity I would like to submit
the patchset once more; I would like to use my work email
for author and signoff, and use the framepointer address
as an envelope. If I do this, I can update patch 5 as noted.
Would that be ok?

Thanks,
-Sam

> > ---
> >  drivers/iio/filter/admv8818.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> > 
> > diff --git a/drivers/iio/filter/admv8818.c b/drivers/iio/filter/admv8818.c
> > index e9602bfd4af7..9785533d0cdd 100644
> > --- a/drivers/iio/filter/admv8818.c
> > +++ b/drivers/iio/filter/admv8818.c
> > @@ -402,6 +402,19 @@ static int admv8818_read_lpf_freq(struct admv8818_state *st, u64 *lpf_freq)
> >  	return ret;
> >  }
> >  
> > +static int admv8818_write_raw_get_fmt(struct iio_dev *indio_dev,
> > +								struct iio_chan_spec const *chan,
> > +								long mask)
> > +{
> > +	switch (mask) {
> > +	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> > +	case IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY:
> > +		return IIO_VAL_INT_64;
> > +	default:
> > +		return -EINVAL;
> > +	}
> > +}
> > +
> >  static int admv8818_write_raw(struct iio_dev *indio_dev,
> >  			      struct iio_chan_spec const *chan,
> >  			      int val, int val2, long info)
> > @@ -410,6 +423,9 @@ static int admv8818_write_raw(struct iio_dev *indio_dev,
> >  
> >  	u64 freq = ((u64)val2 << 32 | (u32)val);
> >  
> > +	if ((s64)freq < 0)
> > +		return -EINVAL;
> > +
> >  	switch (info) {
> >  	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> >  		return admv8818_lpf_select(st, freq);
> > @@ -571,6 +587,7 @@ static int admv8818_set_mode(struct iio_dev *indio_dev,
> >  
> >  static const struct iio_info admv8818_info = {
> >  	.write_raw = admv8818_write_raw,
> > +	.write_raw_get_fmt = admv8818_write_raw_get_fmt,
> >  	.read_raw = admv8818_read_raw,
> >  	.debugfs_reg_access = &admv8818_reg_access,
> >  };
>
diff mbox series

Patch

diff --git a/drivers/iio/filter/admv8818.c b/drivers/iio/filter/admv8818.c
index e9602bfd4af7..9785533d0cdd 100644
--- a/drivers/iio/filter/admv8818.c
+++ b/drivers/iio/filter/admv8818.c
@@ -402,6 +402,19 @@  static int admv8818_read_lpf_freq(struct admv8818_state *st, u64 *lpf_freq)
 	return ret;
 }
 
+static int admv8818_write_raw_get_fmt(struct iio_dev *indio_dev,
+								struct iio_chan_spec const *chan,
+								long mask)
+{
+	switch (mask) {
+	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
+	case IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY:
+		return IIO_VAL_INT_64;
+	default:
+		return -EINVAL;
+	}
+}
+
 static int admv8818_write_raw(struct iio_dev *indio_dev,
 			      struct iio_chan_spec const *chan,
 			      int val, int val2, long info)
@@ -410,6 +423,9 @@  static int admv8818_write_raw(struct iio_dev *indio_dev,
 
 	u64 freq = ((u64)val2 << 32 | (u32)val);
 
+	if ((s64)freq < 0)
+		return -EINVAL;
+
 	switch (info) {
 	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
 		return admv8818_lpf_select(st, freq);
@@ -571,6 +587,7 @@  static int admv8818_set_mode(struct iio_dev *indio_dev,
 
 static const struct iio_info admv8818_info = {
 	.write_raw = admv8818_write_raw,
+	.write_raw_get_fmt = admv8818_write_raw_get_fmt,
 	.read_raw = admv8818_read_raw,
 	.debugfs_reg_access = &admv8818_reg_access,
 };