lkml.org 
[lkml]   [2023]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] regulator (max5970): Add hwmon support
From
On 8/30/23 12:14, Naresh Solanki wrote:
> Hi
>
[ ... ]
>>> + /*
>>> + * Calculate voltage from ADC value and MON range.
>>> + * ddata->mon_rng holds the voltage corresponding to the maximum value the
>>> + * 10-bit ADC can measure.
>>> + * To obtain the output, multiply the ADC value by the MON range (in
>>> + * microvolts) and then divide it by the maximum value of the 10-bit ADC.
>>> + */
>>> + *val = mul_u64_u32_shr(*val, ddata->mon_rng[channel], 10);
>>
>> Why do you use mul_u64_u32_shr() here but a direct shift above ?
> There is possibility of overflow due to large value of ddata->mon_rng

Does the right shift guarantee that the result fits into 32 bit ?

Thanks,
Guenter

\
 
 \ /
  Last update: 2023-08-30 22:29    [W:0.067 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site