[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220818201359.GA3430651@roeck-us.net>
Date: Thu, 18 Aug 2022 13:13:59 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Eliav Farber <farbere@...zon.com>
Cc: jdelvare@...e.com, robh+dt@...nel.org, mark.rutland@....com,
linux-hwmon@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, talel@...zon.com, hhhawa@...zon.com,
jonnyc@...zon.com, hanochu@...zon.com, ronenk@...zon.com,
itamark@...zon.com, shellykz@...zon.com, shorer@...zon.com,
amitlavi@...zon.com, almogbs@...zon.com, dwmw@...zon.co.uk,
rtanwar@...linear.com
Subject: Re: [PATCH v2 11/16] hwmon: (mr75203) add protection for negative
voltage value
On Wed, Aug 17, 2022 at 05:43:16AM +0000, Eliav Farber wrote:
> This change makes sure the returned voltage vlaue is 0 or positive.
>
> Signed-off-by: Eliav Farber <farbere@...zon.com>
> ---
> drivers/hwmon/mr75203.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c
> index 24a00339cfd8..e3191f590167 100644
> --- a/drivers/hwmon/mr75203.c
> +++ b/drivers/hwmon/mr75203.c
> @@ -218,6 +218,13 @@ static int pvt_read_in(struct device *dev, u32 attr, int channel, long *val)
> return ret;
>
> n &= SAMPLE_DATA_MSK;
> +
> + /* Voltage can't be negative */
Who says, and what does that mean ? Under which conditions would
the value be negative, and why would that be a problem / bug ?
After all, negative voltages do exist.
Guenter
> + if (PVT_N_CONST * n < PVT_R_CONST) {
> + *val = 0;
> + return 0;
> + }
> +
> /* Convert the N bitstream count into voltage */
> *val = pvt->vd[channel].pre_scaler;
> *val *= (PVT_N_CONST * n - PVT_R_CONST);
Powered by blists - more mailing lists