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: <20240529205204.81208-4-linux@roeck-us.net>
Date: Wed, 29 May 2024 13:52:04 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: linux-hwmon@...r.kernel.org
Cc: Hristo Venev <hristo@...ev.name>,
	René Rebe <rene@...ctcode.de>,
	Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Radu Sabau <radu.sabau@...log.com>,
	Guenter Roeck <linux@...ck-us.net>
Subject: [RFT PATCH 3/3] hwmon: (spd5118) Add PEC support

Add support for configuring PEC (Packet Error Checking).

Signed-off-by: Guenter Roeck <linux@...ck-us.net>
---
This patch depends on the patch series at
https://patchwork.kernel.org/project/linux-hwmon/list/?series=857097

 drivers/hwmon/spd5118.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c
index 440503d09d13..eb21bf3dffd7 100644
--- a/drivers/hwmon/spd5118.c
+++ b/drivers/hwmon/spd5118.c
@@ -33,6 +33,7 @@ static const unsigned short normal_i2c[] = {
 #define SPD5118_REG_VENDOR		0x03	/* MR3:MR4 */
 #define SPD5118_REG_CAPABILITY		0x05	/* MR5 */
 #define SPD5118_REG_I2C_LEGACY_MODE	0x0B	/* MR11 */
+#define SPD5118_REG_DEV_CONFIG		0x12	/* MR18 */
 #define SPD5118_REG_TEMP_CLR		0x13	/* MR19 */
 #define SPD5118_REG_ERROR_CLR		0x14	/* MR20 */
 #define SPD5118_REG_TEMP_CONFIG		0x1A	/* MR26 */
@@ -50,6 +51,8 @@ static const unsigned short normal_i2c[] = {
 
 #define SPD5118_CAP_TS_SUPPORT		BIT(1)	/* temperature sensor support */
 
+#define SPD5118_PEC_ENABLE		BIT(7)	/* PEC enable */
+
 #define SPD5118_TS_DISABLE		BIT(0)	/* temperature sensor disable */
 
 /* Temperature unit in millicelsius */
@@ -217,6 +220,18 @@ static int spd5118_write_enable(struct regmap *regmap, u32 attr, long val)
 				  val ? 0 : SPD5118_TS_DISABLE);
 }
 
+static int spd5118_chip_write(struct regmap *regmap, u32 attr, long val)
+{
+	switch (attr) {
+	case hwmon_chip_pec:
+		return regmap_update_bits(regmap, SPD5118_REG_DEV_CONFIG,
+					  SPD5118_PEC_ENABLE,
+					  val ? SPD5118_PEC_ENABLE : 0);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
 static int spd5118_temp_write(struct regmap *regmap, u32 attr, long val)
 {
 	switch (attr) {
@@ -238,6 +253,8 @@ static int spd5118_write(struct device *dev, enum hwmon_sensor_types type,
 	struct regmap *regmap = dev_get_drvdata(dev);
 
 	switch (type) {
+	case hwmon_chip:
+		return spd5118_chip_write(regmap, attr, val);
 	case hwmon_temp:
 		return spd5118_temp_write(regmap, attr, val);
 	default:
@@ -338,7 +355,7 @@ static int spd5118_detect(struct i2c_client *client, struct i2c_board_info *info
 
 static const struct hwmon_channel_info *spd5118_info[] = {
 	HWMON_CHANNEL_INFO(chip,
-			   HWMON_C_REGISTER_TZ),
+			   HWMON_C_REGISTER_TZ | HWMON_C_PEC),
 	HWMON_CHANNEL_INFO(temp,
 			   HWMON_T_INPUT |
 			   HWMON_T_LCRIT | HWMON_T_LCRIT_ALARM |
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ