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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 30 Jun 2020 17:43:50 +0000
From:   Chu Lin <linchuyuan@...gle.com>
To:     linux@...ck-us.net, jdelvare@...e.com, linchuyuan@...gle.com,
        linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     jasonling@...gle.com, belgaied@...gle.com, zhongqil@...gle.com
Subject: [PATCH] hwmon:max6697: Allow max6581 to set temperature read offset

Per max6581, reg 4d and reg 4e is used for temperature read offset.
This patch will let the user specify the temperature read offset for
max6581. This patch is tested on max6581 and only applies to max6581.

Testing:
dts: temperature-read-offset = <0xde 0x0>;

verify: iotools smbus_read8 <vbus> 0x4d 0x4e
0x6F

Signed-off-by: Chu Lin <linchuyuan@...gle.com>
---
 drivers/hwmon/max6697.c               | 19 +++++++++++++++++--
 include/linux/platform_data/max6697.h |  4 ++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/max6697.c b/drivers/hwmon/max6697.c
index 743752a2467a..16c0f0995a12 100644
--- a/drivers/hwmon/max6697.c
+++ b/drivers/hwmon/max6697.c
@@ -493,8 +493,13 @@ static void max6697_get_config_of(struct device_node *node,
 	}
 	prop = of_get_property(node, "transistor-ideality", &len);
 	if (prop && len == 2 * sizeof(u32)) {
-			pdata->ideality_mask = be32_to_cpu(prop[0]);
-			pdata->ideality_value = be32_to_cpu(prop[1]);
+		pdata->ideality_mask = be32_to_cpu(prop[0]);
+		pdata->ideality_value = be32_to_cpu(prop[1]);
+	}
+	prop = of_get_property(node, "temperature-read-offset", &len);
+	if  (prop && len == 2 * sizeof(u32)) {
+		pdata->offset_mask = be32_to_cpu(prop[0]);
+		pdata->offset_value = be32_to_cpu(prop[1]);
 	}
 }
 
@@ -586,6 +591,16 @@ static int max6697_init_chip(struct max6697_data *data,
 						pdata->ideality_mask >> 1);
 		if (ret < 0)
 			return ret;
+		ret = i2c_smbus_write_byte_data(client,
+						MAX6581_REG_OFFSET,
+						pdata->offset_value);
+		if (ret < 0)
+			return ret;
+		ret = i2c_smbus_write_byte_data(client,
+						MAX6581_REG_OFFSET_SELECT,
+						pdata->offset_mask >> 1);
+		if (ret < 0)
+			return ret;
 	}
 done:
 	data->update_interval = factor * MAX6697_CONV_TIME;
diff --git a/include/linux/platform_data/max6697.h b/include/linux/platform_data/max6697.h
index 6fbb70005541..ff98adfe9d8d 100644
--- a/include/linux/platform_data/max6697.h
+++ b/include/linux/platform_data/max6697.h
@@ -28,6 +28,10 @@ struct max6697_platform_data {
 	u8 ideality_value;		/* transistor ideality as per
 					 * MAX6581 datasheet
 					 */
+	u8 offset_mask;			/* set bit to 0 to disable */
+	u8 offset_value;		/* temperature read offset as
+					 * MAX6581 datasheet
+					 */
 };
 
 #endif /* MAX6697_H */
-- 
2.27.0.212.ge8ba1cc988-goog

Powered by blists - more mailing lists