Re: [PATCH v2 2/9] thermal: qcom: tsens-8916: Add support for 8916 family of SoCs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rajendra Nayak <rnayak@xxxxxxxxxxxxxx> writes:

> On 09/21/2015 09:58 AM, Rajendra Nayak wrote:
>> []..
>> 
>>>> +static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s)
>>>> +{
>>>> +    int degc, num, den;
>>>> +
>>>> +    num = (adc_code * SLOPE_FACTOR) - s->offset;
>>>> +    den = s->slope;
>>>> +
>>>> +    if (num > 0)
>>>> +        degc = num + (den / 2);
>>>> +    else if (num < 0)
>>>> +        degc = num - (den / 2);
>>>> +    else
>>>> +        degc = num;
>>>> +
>>>> +    degc /= den;
>>>> +
>>>> +    return degc;
>>>> +}
>>>> +
>>>> +int get_temp_common(struct tsens_device *tmdev, int id, int *temp)
>>>> +{
>>>> +    struct tsens_sensor *s = &tmdev->sensor[id];
>>>> +    u32 code;
>>>> +    unsigned int sensor_addr;
>>>> +    int last_temp = 0, ret;
>>>> +
>>>> +    sensor_addr = S0_ST_ADDR + s->hw_id * SN_ADDR_OFFSET;
>>>> +    ret = regmap_read(tmdev->map, sensor_addr, &code);
>>>> +    if (ret)
>>>> +        return ret;
>>>> +    last_temp = code & SN_ST_TEMP_MASK;
>>>> +
>>>> +    *temp = code_to_degc(last_temp, s) * 1000;
>>>> +
>>>> +    return 0;
>>>> +}
>>>
>>> The way this function is coded the temperature will only ever change by
>>> 1C (i.e., 1000mC). Is there a chance that you're losing precision in the
>>> code_to_degc conversion that could be preserved perhaps?
>>>
>>> This is useful in scenarios where you use the power allocator governor
>>> and the greater precision allows better power budget estimation.
>> 
>> I'll take a look to see if we can get better precision. Thanks.
>
> I checked, and it does not look like these devices can support better precision
> than degC.

Ah well. Thanks for checking!
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux