* [PATCH] iio: temperature: mlx90614 Refactoring available filter attributes
@ 2022-09-06 11:26 cmo
2022-09-15 14:11 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: cmo @ 2022-09-06 11:26 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, Crt Mori
From: Crt Mori <cmo@melexis.com>
Change/refactor to the new way of defining available attribute values.
Signed-off-by: Crt Mori <cmo@melexis.com>
---
drivers/iio/temperature/mlx90614.c | 41 ++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index c253a5315988..3157416be912 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -79,16 +79,15 @@ struct mlx90614_data {
/* Bandwidth values for IIR filtering */
static const int mlx90614_iir_values[] = {77, 31, 20, 15, 723, 153, 110, 86};
-static IIO_CONST_ATTR(in_temp_object_filter_low_pass_3db_frequency_available,
- "0.15 0.20 0.31 0.77 0.86 1.10 1.53 7.23");
-
-static struct attribute *mlx90614_attributes[] = {
- &iio_const_attr_in_temp_object_filter_low_pass_3db_frequency_available.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group mlx90614_attr_group = {
- .attrs = mlx90614_attributes,
+static const int mlx90614_freqs[][2] = {
+ {0, 150000},
+ {0, 200000},
+ {0, 310000},
+ {0, 770000},
+ {0, 860000},
+ {1, 100000},
+ {1, 530000},
+ {7, 230000}
};
/*
@@ -373,6 +372,22 @@ static int mlx90614_write_raw_get_fmt(struct iio_dev *indio_dev,
}
}
+static int mlx90614_read_avail(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ const int **vals, int *type, int *length,
+ long mask)
+{
+ switch (mask) {
+ case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
+ *vals = (int *)mlx90614_freqs;
+ *type = IIO_VAL_INT_PLUS_MICRO;
+ *length = 2 * ARRAY_SIZE(mlx90614_freqs);
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
+
static const struct iio_chan_spec mlx90614_channels[] = {
{
.type = IIO_TEMP,
@@ -389,6 +404,8 @@ static const struct iio_chan_spec mlx90614_channels[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) |
BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE),
},
@@ -401,6 +418,8 @@ static const struct iio_chan_spec mlx90614_channels[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) |
BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
+ .info_mask_separate_available =
+ BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE),
},
@@ -410,7 +429,7 @@ static const struct iio_info mlx90614_info = {
.read_raw = mlx90614_read_raw,
.write_raw = mlx90614_write_raw,
.write_raw_get_fmt = mlx90614_write_raw_get_fmt,
- .attrs = &mlx90614_attr_group,
+ .read_avail = mlx90614_read_avail,
};
#ifdef CONFIG_PM
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: temperature: mlx90614 Refactoring available filter attributes
2022-09-06 11:26 [PATCH] iio: temperature: mlx90614 Refactoring available filter attributes cmo
@ 2022-09-15 14:11 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-09-15 14:11 UTC (permalink / raw)
To: cmo; +Cc: linux-iio, linux-kernel
On Tue, 6 Sep 2022 13:26:32 +0200
cmo@melexis.com wrote:
> From: Crt Mori <cmo@melexis.com>
>
> Change/refactor to the new way of defining available attribute values.
>
> Signed-off-by: Crt Mori <cmo@melexis.com>
Applied. thanks
> ---
> drivers/iio/temperature/mlx90614.c | 41 ++++++++++++++++++++++--------
> 1 file changed, 30 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
> index c253a5315988..3157416be912 100644
> --- a/drivers/iio/temperature/mlx90614.c
> +++ b/drivers/iio/temperature/mlx90614.c
> @@ -79,16 +79,15 @@ struct mlx90614_data {
>
> /* Bandwidth values for IIR filtering */
> static const int mlx90614_iir_values[] = {77, 31, 20, 15, 723, 153, 110, 86};
> -static IIO_CONST_ATTR(in_temp_object_filter_low_pass_3db_frequency_available,
> - "0.15 0.20 0.31 0.77 0.86 1.10 1.53 7.23");
> -
> -static struct attribute *mlx90614_attributes[] = {
> - &iio_const_attr_in_temp_object_filter_low_pass_3db_frequency_available.dev_attr.attr,
> - NULL,
> -};
> -
> -static const struct attribute_group mlx90614_attr_group = {
> - .attrs = mlx90614_attributes,
> +static const int mlx90614_freqs[][2] = {
> + {0, 150000},
> + {0, 200000},
> + {0, 310000},
> + {0, 770000},
> + {0, 860000},
> + {1, 100000},
> + {1, 530000},
> + {7, 230000}
> };
>
> /*
> @@ -373,6 +372,22 @@ static int mlx90614_write_raw_get_fmt(struct iio_dev *indio_dev,
> }
> }
>
> +static int mlx90614_read_avail(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + const int **vals, int *type, int *length,
> + long mask)
> +{
> + switch (mask) {
> + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> + *vals = (int *)mlx90614_freqs;
> + *type = IIO_VAL_INT_PLUS_MICRO;
> + *length = 2 * ARRAY_SIZE(mlx90614_freqs);
> + return IIO_AVAIL_LIST;
> + default:
> + return -EINVAL;
> + }
> +}
> +
> static const struct iio_chan_spec mlx90614_channels[] = {
> {
> .type = IIO_TEMP,
> @@ -389,6 +404,8 @@ static const struct iio_chan_spec mlx90614_channels[] = {
> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) |
> BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
> + .info_mask_separate_available =
> + BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
> BIT(IIO_CHAN_INFO_SCALE),
> },
> @@ -401,6 +418,8 @@ static const struct iio_chan_spec mlx90614_channels[] = {
> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) |
> BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
> + .info_mask_separate_available =
> + BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
> BIT(IIO_CHAN_INFO_SCALE),
> },
> @@ -410,7 +429,7 @@ static const struct iio_info mlx90614_info = {
> .read_raw = mlx90614_read_raw,
> .write_raw = mlx90614_write_raw,
> .write_raw_get_fmt = mlx90614_write_raw_get_fmt,
> - .attrs = &mlx90614_attr_group,
> + .read_avail = mlx90614_read_avail,
> };
>
> #ifdef CONFIG_PM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-15 14:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06 11:26 [PATCH] iio: temperature: mlx90614 Refactoring available filter attributes cmo
2022-09-15 14:11 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).