Re: [PATCH v3 1/5] iio: adc: qcom-spmi-adc5: Add battery thermal channels
From: Luca Weiss
Date: Mon Nov 16 2026 - 10:44:03 EST
Hi Andy,
On Fri Nov 13, 2026 at 5:24 PM CET, Andy Shevchenko wrote:
> On Fri, Nov 13, 2026 at 04:56:42PM +0100, Luca Weiss wrote:
>> Add the BAT_THERM channels with millivolt as output, which can then be
>> used along with information regarding the NTC in the battery, to get the
>> actual battery temperature.
>>
>> A static lookup table in the ADC driver won't work since different
>> devices have different Ohm and Beta values in their battery NTCs, for
>> example a NTC can be 10kOhm & B=3435K.
>
> ...
>
>> +static int qcom_vadc_scale_hw_calib_therm_volt(
>
> This is broken indentation. Was `clang-format` being used to achieve that?
This is how the rest of the file is formatted, I didn't deviate from
that.
>
>> + const struct u32_fract *prescale,
>> + const struct adc5_data *data,
>> + u16 adc_code, int *result_uv)
>
> result_uV
As Sashiko pointed out, this is labelled wrong, the result is millivolt.
The rest of the driver consistently uses "mv" for that, should I deviate
and use result_mV?
>
>> +{
>> + *result_uv = qcom_vadc_scale_code_voltage_factor(adc_code,
>> + prescale, data, 1000);
>
> 1000 is odd, can you use something from units.h or combination of those
> to show what this multiplier is for?
This is converting microvolt to millivolt.
Shall I use "(MICRO / MILLI)" as used in plenty other drivers? Two
drivers in the tree also have "#define MILLI_TO_MICRO 1000"
Regards
Luca
>
>> + return 0;
>> +}