lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210610153922.GA3859014@roeck-us.net>
Date:   Thu, 10 Jun 2021 08:39:22 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Robert Marko <robert.marko@...tura.hr>
Cc:     jdelvare@...e.com, linux-hwmon@...r.kernel.org,
        linux-kernel@...r.kernel.org, luka.perkov@...tura.hr
Subject: Re: [PATCH 2/3] hwmon: (tps23861) set current shunt value

On Thu, Jun 10, 2021 at 12:07:27AM +0200, Robert Marko wrote:
> TPS23861 has a configuration bit for setting of the
> current shunt value used on the board.
> Its bit 0 of the General Mask 1 register.
> 
> According to the datasheet bit values are:
> 0 for 255 mOhm (Default)
> 1 for 250 mOhm
> 
> So, configure the bit before registering the hwmon
> device according to the value passed in the DTS or
> default one if none is passed.
> 
> This caused potentially reading slightly skewed values
> due to max current value being 1.02A when 250mOhm shunt
> is used instead of 1.0A when 255mOhm is used.
> 
> Fixes: fff7b8ab2255 ("hwmon: add Texas Instruments TPS23861 driver")
> Signed-off-by: Robert Marko <robert.marko@...tura.hr>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/tps23861.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c
> index fd0be8883829..c3685b7e9e82 100644
> --- a/drivers/hwmon/tps23861.c
> +++ b/drivers/hwmon/tps23861.c
> @@ -99,6 +99,9 @@
>  #define POWER_ENABLE			0x19
>  #define TPS23861_NUM_PORTS		4
>  
> +#define TPS23861_GENERAL_MASK_1		0x17
> +#define TPS23861_CURRENT_SHUNT_MASK	BIT(0)
> +
>  #define TEMPERATURE_LSB			652 /* 0.652 degrees Celsius */
>  #define VOLTAGE_LSB			3662 /* 3.662 mV */
>  #define SHUNT_RESISTOR_DEFAULT		255000 /* 255 mOhm */
> @@ -561,6 +564,15 @@ static int tps23861_probe(struct i2c_client *client)
>  	else
>  		data->shunt_resistor = SHUNT_RESISTOR_DEFAULT;
>  
> +	if (data->shunt_resistor == SHUNT_RESISTOR_DEFAULT)
> +		regmap_clear_bits(data->regmap,
> +				  TPS23861_GENERAL_MASK_1,
> +				  TPS23861_CURRENT_SHUNT_MASK);
> +	else
> +		regmap_set_bits(data->regmap,
> +				TPS23861_GENERAL_MASK_1,
> +				TPS23861_CURRENT_SHUNT_MASK);
> +
>  	hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name,
>  							 data, &tps23861_chip_info,
>  							 NULL);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ