[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1efe9234-a97f-6df2-c47d-e153dc362599@roeck-us.net>
Date: Wed, 30 Aug 2023 12:32:14 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Naresh Solanki <naresh.solanki@...ements.com>
Cc: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Jean Delvare <jdelvare@...e.com>, zev@...ilderbeest.net,
linux-kernel@...r.kernel.org, linux-hwmon@...r.kernel.org
Subject: Re: [PATCH] regulator (max5970): Add hwmon support
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
Powered by blists - more mailing lists