mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Naresh Solanki <naresh.solanki@9elements.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jean Delvare <jdelvare@suse.com>,
	zev@bewilderbeest.net, linux-kernel@vger.kernel.org,
	linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] regulator (max5970): Add hwmon support
Date: Wed, 30 Aug 2023 12:32:14 -0700	[thread overview]
Message-ID: <1efe9234-a97f-6df2-c47d-e153dc362599@roeck-us.net> (raw)
In-Reply-To: <CABqG17ig1VRJYqbrOvPKAYS8iUFwY9J3tYcgYGtnnXw+vrnoRA@mail.gmail.com>

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


  reply	other threads:[~2023-08-30 20:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30 11:13 Naresh Solanki
2023-08-30 15:56 ` Guenter Roeck
2023-08-30 19:14   ` Naresh Solanki
2023-08-30 19:32     ` Guenter Roeck [this message]
2023-08-31  8:56       ` Naresh Solanki
2023-09-01  8:00 ` kernel test robot
2023-09-01  8:11 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1efe9234-a97f-6df2-c47d-e153dc362599@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=broonie@kernel.org \
    --cc=jdelvare@suse.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naresh.solanki@9elements.com \
    --cc=zev@bewilderbeest.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®