Re: [PATCH v7 06/11] iio: adc: hx711: introduce hx711_chip_info structure

From: Jonathan Cameron

Date: Mon May 11 2026 - 10:38:17 EST


On Mon, 11 May 2026 01:19:28 +0530
Piyush Patle <piyushpatle228@xxxxxxxxx> wrote:

> Add a per-variant static configuration structure and populate the IIO
> device fields from it at probe time.
>
> This is a preparatory change for adding support for more HX711-compatible
> hardware variants without duplicating the probe-time setup.
>
> No functional change for existing HX711 users.
>
> Signed-off-by: Piyush Patle <piyushpatle228@xxxxxxxxx>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
Really minor things inline but given you are doing a v8 for the buffer
thing might as well tidy them up!
> ---
> drivers/iio/adc/hx711.c | 41 ++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 36 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c
> index 01097e0fb848..331d47e1bbc4 100644
> --- a/drivers/iio/adc/hx711.c
> +++ b/drivers/iio/adc/hx711.c
> @@ -4,6 +4,8 @@
> *
> * Copyright (c) 2016 Andreas Klinger <ak@xxxxxxxxxxxxx>
> */
> +#include <linux/array_size.h>
> +#include <linux/dev_printk.h>
> #include <linux/err.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> @@ -74,6 +76,20 @@ static int hx711_get_scale_to_gain(const int *gain_scale, int scale)
> return -EINVAL;
> }
>
> +/**
> + * struct hx711_chip_info - per-variant static configuration
> + * @name: IIO device name
> + * @channels: channel specification array
> + * @iio_info: IIO info ops for this variant
> + * @num_channels: number of entries in @channels
> + */
> +struct hx711_chip_info {
> + const char *name;
> + const struct iio_chan_spec *channels;

Trivial but can you swap this and iio_info so that we have channels and
num_channels near each other. Won't change the structure size.
Can we also mark this __counted_by_ptr(num_channels)?
Lets analysis tools and compilers have a tiny bit more info that
can be helpful for detecting some types of bug.


> + const struct iio_info *iio_info;
> + unsigned int num_channels;
> +};
> +