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: <20220830192212.28570-18-farbere@amazon.com>
Date:   Tue, 30 Aug 2022 19:22:10 +0000
From:   Eliav Farber <farbere@...zon.com>
To:     <jdelvare@...e.com>, <linux@...ck-us.net>, <robh+dt@...nel.org>,
        <p.zabel@...gutronix.de>, <rtanwar@...linear.com>,
        <linux-hwmon@...r.kernel.org>, <devicetree@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC:     <farbere@...zon.com>, <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>, <dkl@...zon.com>,
        <rahul.tanwar@...ux.intel.com>, <andriy.shevchenko@...el.com>
Subject: [PATCH v3 17/19] hwmon: (mr75203) parse temperature coefficients from device-tree

Use thermal coefficients from the device tree if they exist.
Otherwise, use default values according to the series (5 or 6).
All coefficients can be used or only part of them.

The coefficients shall be used for fine tuning the default values since
coefficients can vary between product and product.

Signed-off-by: Eliav Farber <farbere@...zon.com>
---
 drivers/hwmon/mr75203.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c
index 6a035fd115ca..d9fc5d225868 100644
--- a/drivers/hwmon/mr75203.c
+++ b/drivers/hwmon/mr75203.c
@@ -676,7 +676,8 @@ static int pvt_set_temp_coeff(struct device *dev, struct pvt_device *pvt)
 {
 	struct temp_coeff *ts_coeff = &pvt->ts_coeff;
 	const struct device_node *np = dev->of_node;
-	u32 series;
+	u32 series, coeff_h, coeff_g, coeff_cal5;
+	s32 coeff_j;
 	int ret;
 
 	/* Incase ts-series property is not defined, use default 5. */
@@ -702,6 +703,32 @@ static int pvt_set_temp_coeff(struct device *dev, struct pvt_device *pvt)
 
 	dev_dbg(dev, "temperature sensor series = %u\n", series);
 
+	/* Override ts-coeff-h/g/j/cal5 if they are defined. */
+	ret = of_property_read_u32(np, "moortec,ts-coeff-h", &coeff_h);
+	if (!ret)
+		ts_coeff->h = coeff_h;
+
+	ret = of_property_read_u32(np, "moortec,ts-coeff-g", &coeff_g);
+	if (!ret)
+		ts_coeff->g = coeff_g;
+
+	ret = of_property_read_s32(np, "moortec,ts-coeff-j", &coeff_j);
+	if (!ret)
+		ts_coeff->j = coeff_j;
+
+	ret = of_property_read_u32(np, "moortec,ts-coeff-cal5", &coeff_cal5);
+	if (!ret) {
+		if (coeff_cal5 == 0) {
+			dev_err(dev, "moortec,ts-coeff-cal5 can't be 0\n");
+			return -EINVAL;
+		}
+
+		ts_coeff->cal5 = coeff_cal5;
+	}
+
+	dev_dbg(dev, "ts-coeff: h = %u, g = %u, j = %d, cal5 = %u\n",
+		ts_coeff->h, ts_coeff->g, ts_coeff->j, ts_coeff->cal5);
+
 	return 0;
 }
 
-- 
2.37.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ