Re: [PATCH v6 05/11] iio: adc: hx711: move scale computation to per-device storage
From: Andy Shevchenko
Date: Mon May 04 2026 - 10:36:13 EST
On Sun, May 03, 2026 at 05:39:34PM +0530, Piyush Patle wrote:
> The gain-to-scale table is global today, so probe-time scale updates for
> one device overwrite the values used by any earlier device instance.
>
> Fix this by making the gain table const and storing the computed scale
> values per device in hx711_data.
>
> No functional change for single-sensor configurations.
...
> +static const struct hx711_gain_to_scale hx711_gain_to_scale[HX711_GAIN_MAX] = {
> + { 128, 1, 0, },
> + { 32, 2, 1, },
> + { 64, 3, 0, },
In such case the inner trailing commas are not needed. They are needed when the
supplied lists are arrays and may be extended. Here it's a proper data type
with fixed number of arguments. If you want to be even stricter and robust, move
to C99 initialisers (but note, I'm fine with just trailing commas being removed).
{ 128, 1, 0 },
{ 32, 2, 1 },
{ 64, 3, 0 },
> };
...
> @@ -574,4 +575,3 @@ MODULE_AUTHOR("Andreas Klinger <ak@xxxxxxxxxxxxx>");
> MODULE_DESCRIPTION("HX711 bitbanging driver - ADC for weight cells");
> MODULE_LICENSE("GPL");
> MODULE_ALIAS("platform:hx711-gpio");
> -
Stray change.
--
With Best Regards,
Andy Shevchenko