On Tue, Jun 02, 2026 at 05:33:59PM +0100, Rodrigo Alencar via B4 Relay wrote:
> 
> Most of the supported devices rely on a GAIN pin to control a 2x
> multiplier applied to the output voltage. Other devices, e.g. the
> single-channel ones, provides a gain control through a bit field in the
> control register. Some designs might have the GAIN pin hardwired to
> VDD/VLOGIC or GND, which would still be fine for this patch, that allows
> the scale property to be configurable with two available options.

...

> +     case IIO_CHAN_INFO_SCALE:
> +             if (val == st->scale_avail[0] && val2 == st->scale_avail[1])
> +                     st->double_scale = false;
> +             else if (val == st->scale_avail[2] && val2 == 
> st->scale_avail[3])
> +                     st->double_scale = true;
> +             else
> +                     return -EINVAL;
> +
> +             switch (st->chip_info->regmap_type) {
> +             case AD5310_REGMAP:
> +                     return ad5310_control_sync(st);
> +             case AD5683_REGMAP:
> +                     return ad5683_control_sync(st);
> +             case AD5686_REGMAP:
> +                     /*
> +                      * even if the gain pin is hardwired on the board, the

Even

> +                      * user is able to control the scale such that it
> +                      * matches the actual gain setting.
> +                      */
> +                     gpiod_set_value_cansleep(st->gain_gpio,
> +                                              st->double_scale ? 1 : 0);
> +                     return 0;
> +             default:
> +                     return -EINVAL;
> +             }

...

> @@ -138,9 +143,12 @@ struct ad5686_state {

Have you run `pahole`? It seems to me that those bools can be combined with
vref_mv to reduce 4 bytes gap.

>       const struct ad5686_chip_info   *chip_info;
>       const struct ad5686_bus_ops     *ops;
>       struct gpio_desc                *ldac_gpio;
> +     struct gpio_desc                *gain_gpio;
>       unsigned short                  vref_mv;
>       unsigned int                    pwr_down_mask;
>       unsigned int                    pwr_down_mode;
> +     int                             scale_avail[4];
> +     bool                            double_scale;
>       bool                            use_internal_vref;
>       struct mutex                    lock;
>       void                            *bus_data;

-- 
With Best Regards,
Andy Shevchenko



Reply via email to