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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211008140331.GA1728738@roeck-us.net>
Date:   Fri, 8 Oct 2021 07:03:31 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Zev Weiss <zev@...ilderbeest.net>
Cc:     Jean Delvare <jdelvare@...e.com>, Jonathan Corbet <corbet@....net>,
        linux-hwmon@...r.kernel.org, linux-doc@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 7/8] hwmon: (pmbus/lm25066) Support configurable sense
 resistor values

On Tue, Sep 28, 2021 at 02:22:41AM -0700, Zev Weiss wrote:
> The appropriate mantissa values for the lm25066 family's direct-format
> current and power readings are a function of the sense resistor
> employed between the SENSE and VIN pins of the chip.  Instead of
> assuming that resistance is always the same 1mOhm as used in the
> datasheet, allow it to be configured via a device-tree property
> ("shunt-resistor-micro-ohms").
> 
> Signed-off-by: Zev Weiss <zev@...ilderbeest.net>
> ---
>  Documentation/hwmon/lm25066.rst |  2 ++
>  drivers/hwmon/pmbus/lm25066.c   | 12 ++++++++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/Documentation/hwmon/lm25066.rst b/Documentation/hwmon/lm25066.rst
> index 9f1d7e4d3ca1..a2098eb24090 100644
> --- a/Documentation/hwmon/lm25066.rst
> +++ b/Documentation/hwmon/lm25066.rst
> @@ -79,6 +79,8 @@ This driver does not auto-detect devices. You will have to instantiate the
>  devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for
>  details.
>  
> +The shunt (sense) resistor value can be configured by a device tree property;
> +see Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml for details.
>  
>  Platform data support
>  ---------------------
> diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
> index 18d5a76f346d..29e848bcd436 100644
> --- a/drivers/hwmon/pmbus/lm25066.c
> +++ b/drivers/hwmon/pmbus/lm25066.c
> @@ -458,6 +458,7 @@ MODULE_DEVICE_TABLE(of, lm25066_of_match);
>  static int lm25066_probe(struct i2c_client *client)
>  {
>  	int config;
> +	u32 shunt;
>  	struct lm25066_data *data;
>  	struct pmbus_driver_info *info;
>  	const struct __coeff *coeff;
> @@ -535,6 +536,17 @@ static int lm25066_probe(struct i2c_client *client)
>  		info->b[PSC_POWER] = coeff[PSC_POWER].b;
>  	}
>  
> +	/*
> +	 * Values in the TI datasheets are normalized for a 1mOhm sense
> +	 * resistor; assume that unless DT specifies a value explicitly.
> +	 */
> +	if (of_property_read_u32(client->dev.of_node,
> +	                         "shunt-resistor-micro-ohms", &shunt))

Space vs. tabs again. Never mind, fixed up and applied.

Thanks,
Guenter

> +		shunt = 1000;
> +
> +	info->m[PSC_CURRENT_IN] = info->m[PSC_CURRENT_IN] * shunt / 1000;
> +	info->m[PSC_POWER] = info->m[PSC_POWER] * shunt / 1000;
> +
>  	return pmbus_do_probe(client, info);
>  }
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ