Re: [PATCH v2 3/6] iio: dac: ad3552r: add model data structure

From: Nuno Sá
Date: Thu May 23 2024 - 08:43:44 EST


On Wed, 2024-05-22 at 17:01 +0200, Angelo Dureghello wrote:
> From: Angelo Dureghello <adureghello@xxxxxxxxxxxx>
>
> Add a "model data" structure to keep useful hardware-related
> information as from datasheet, avoiding id-based conditional
> choices later on.
>
> Removed id-based checks and filled model-specific structures
> with device specific features, In particular, num_hw_channels
> is introduced to keep the number of hardware implemented
> channels, since 1-channel versions of the DACs are added
> in this same patchset.
>
> Signed-off-by: Angelo Dureghello <adureghello@xxxxxxxxxxxx>
> ---
> Changes for v2:
> - patch added in v2
> ---
>  drivers/iio/dac/ad3552r.c | 98 +++++++++++++++++++++++----------------
>  1 file changed, 59 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/iio/dac/ad3552r.c b/drivers/iio/dac/ad3552r.c
> index a492e8f2fc0f..6a40c7eece1f 100644
> --- a/drivers/iio/dac/ad3552r.c
> +++ b/drivers/iio/dac/ad3552r.c
> @@ -261,7 +261,17 @@ struct ad3552r_ch_data {
>   bool range_override;
>  };
>  
> +struct ad3552r_model_data {
> + const char *model_name;
> + enum ad3542r_id chip_id;
> + unsigned int num_hw_channels;
> + const s32 (*ranges_table)[2];
> + int num_ranges;
> + bool requires_output_range;
> +};
> +

nit: we often would call this (in IIO) ad3552r_chip_info. Then...
>  struct ad3552r_desc {
> + const struct ad3552r_model_data *model_data;

*chip_info;

Anyways, not really something worth a re-spin. But if you need one, something to
consider :)

- Nuno Sá