Re: [PATCH v2 2/2] iio: pressure: ms5637: Add variant specific temperature compensation

From: Louis Adamian

Date: Thu Jun 11 2026 - 15:10:46 EST


On Wed, 10 Jun 2026 21:37:58 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:

> On Tue, Jun 09, 2026 at 10:04:58PM -0400, Louis Adamian wrote:
> > Add correct temperature compensation for ms5637-30BA,
> > MS5803-01BA,02BA, 05BA, 14BA, 30BA, MS5837-30BA. The temperature
> > compensation formula is shared across these sensors but with
> > different constants. Add ms_tp_comp_consts to capture these
> > per-device differences. Add pressure variant specific pressure
> > scale variable.
>
> Is there SPI driver? If so, why only i2c is affected?

As Jonathan noted, there is no SPI driver currently and the
modified function is only used by i2c.

> > + s64 tmp = (s64)temp - 2000;
>
> Why casting?

This is extraneous, I will remove it.

> Overall this all needs a good comment or even comments to explain all
> calculations with the references to the respective sections / tables
> / pages in the datasheet.

I'll add comments here explaining the shared equations. There are
also references to the individual datasheets in the constant structures
because they differ per device.

> > struct ms_tp_dev {
> > struct i2c_client *client;
>
> > const struct ms_tp_hw_data *hw;
> > u16 prom[MS_SENSORS_TP_PROM_WORDS_NB];
> > u8 res_index;
> > + const struct ms_tp_comp_consts *comp_consts;
>
> Please, check with `pahole` if this is the best layout.

I will correct the packing on this per pahole's finding.
> > struct ms_tp_data {
> > const char *name;
> > const struct ms_tp_hw_data *hw;
> > + const struct ms_tp_comp_consts *comp_consts;
> > };
>
> Can this be simply embedded into ms_tp_dev (and copied there if
> required)?

Copying in ms_tp_comp_consts provides no benefit over
referencing the pointer; the values are per-descriptor, not
per-instance and never modified. I'll keep the pointer (same as
ms_tp_hw_data).

> Have you considered to prepare the infrastructure in one patch and add
> the actual compensation data tables in another?

I can split this patch for V3 and I will fix the other formatting
issues.

Thanks,
Louis