Messages in this thread | | | Subject | Re: [PATCH v3 15/19] hwmon: (mr75203) add support for series 6 temperature equation | Date | Thu, 1 Sep 2022 15:14:02 +0300 | From | "Farber, Eliav" <> |
| |
On 8/31/2022 3:08 PM, Andy Shevchenko wrote: > On Tue, Aug 30, 2022 at 07:22:08PM +0000, Eliav Farber wrote: >> The current equation used in code is aligned to series 5: >> T = G + H * (n / cal5 - 0.5) + J * F >> Where: >> G = 60, H = 200, cal5 = 4094, J = -0.1, F = frequency clock in MHz >> >> Series 6 has a slightly different equation: >> T = G + H * (n / cal5 - 0.5) >> and a different set of coefficients: >> G = 57.4, H = 249.4, cal5 = 4096 >> >> This change supports equation and coefficients for both series. >> (for series 6, J is set to 0). >> >> The series is determined according to “ts-series” property in device >> tree. >> If absent, series 5 is assumed to be the default. > > ... > >> -#define PVT_H_CONST 200000 >> -#define PVT_G_CONST 60000 >> -#define PVT_J_CONST -100 >> -#define PVT_CAL5_CONST 4094 > > You just introduced them patch before. Please, avoid ping-pong style in > the same series.
Fixed for v4. I now introduce these defines in patch 13 to avoid modifying the above ones and then remove them: /* Temperature coefficients for series 5 */ #define PVT_SERIES5_H_CONST 200000 #define PVT_SERIES5_G_CONST 60000 #define PVT_SERIES5_J_CONST -100 #define PVT_SERIES5_CAL5_CONST 4094
> ... > >> + ret = of_property_read_u32(np, "moortec,ts-series", &series); > > of_ ?! > > Be consistent. Either you use OF everywhere, or device property APIs. >
Fixed for v4. Using device_property_read_u32() instead.
> ... > >> + if (ret) >> + series = TEMPERATURE_SENSOR_SERIES_5; >> + >> + if (series == TEMPERATURE_SENSOR_SERIES_5) { >> + ts_coeff->h = PVT_SERIES5_H_CONST; >> + ts_coeff->g = PVT_SERIES5_G_CONST; >> + ts_coeff->j = PVT_SERIES5_J_CONST; >> + ts_coeff->cal5 = PVT_SERIES5_CAL5_CONST; >> + } else if (series == TEMPERATURE_SENSOR_SERIES_6) { >> + ts_coeff->h = PVT_SERIES6_H_CONST; >> + ts_coeff->g = PVT_SERIES6_G_CONST; >> + ts_coeff->j = PVT_SERIES6_J_CONST; >> + ts_coeff->cal5 = PVT_SERIES6_CAL5_CONST; >> + } else { >> + dev_err(dev, "invalid temperature sensor series (%u)\n", >> + series); >> + return -EINVAL; >> + } > > switch-case?
Changed to switch-case (will be part of v4).
-- Thanks, Eliav
| |