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]
Date:   Wed,  6 Jul 2022 12:40:22 +0200
From:   "Kallas, Pawel" <pawel.kallas@...el.com>
To:     linux@...ck-us.net, jdelvare@...e.com, corbet@....net,
        linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-doc@...r.kernel.org
Cc:     iwona.winiarska@...el.com, pawel.kallas@...el.com
Subject: [PATCH 1/3] hwmon: (pmbus) add support for QUERY command

QUERY command is used for checking if given command is supported by
the device and what data format it uses. It is needed to check if
READ_EIN and READ_EOUT commands are supported.

Signed-off-by: Kallas, Pawel <pawel.kallas@...el.com>
---
 Documentation/hwmon/pmbus-core.rst |  7 +++++++
 drivers/hwmon/pmbus/pmbus.h        | 14 ++++++++++++++
 drivers/hwmon/pmbus/pmbus_core.c   | 21 +++++++++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/Documentation/hwmon/pmbus-core.rst b/Documentation/hwmon/pmbus-core.rst
index e7e0c9ef10bec..6ba0a9d86f1f6 100644
--- a/Documentation/hwmon/pmbus-core.rst
+++ b/Documentation/hwmon/pmbus-core.rst
@@ -268,6 +268,13 @@ otherwise.
 This function calls the device specific write_byte function if defined to
 obtain the chip status. Therefore, it must _not_ be called from that function.
 
+::
+
+  int pmbus_query_register(struct i2c_client *client, int reg);
+
+Send pmbus QUERY command for specific register. Returns QUERY command
+response or negative value on fail.
+
 ::
 
   int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info);
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index 75aa97b1ecc05..971554f40dba6 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -364,6 +364,19 @@ enum pmbus_fan_mode { percent = 0, rpm };
 #define PB_CML_FAULT_INVALID_DATA	BIT(6)
 #define PB_CML_FAULT_INVALID_COMMAND	BIT(7)
 
+/*
+ * QUERY
+ */
+#define PB_QUERY_COMMAND_MODE_MASK	0x1C
+
+#define PB_QUERY_COMMAND_MODE_LINEAR	0x00
+#define PB_QUERY_COMMAND_MODE_DIRECT	0x0C
+#define PB_QUERY_COMMAND_MODE_VID	0x14
+
+#define PB_QUERY_COMMAND_SUPPORTED_FOR_READ	BIT(5)
+#define PB_QUERY_COMMAND_SUPPORTED_FOR_WRITE	BIT(6)
+#define PB_QUERY_COMMAND_SUPPORTED	BIT(7)
+
 enum pmbus_sensor_classes {
 	PSC_VOLTAGE_IN = 0,
 	PSC_VOLTAGE_OUT,
@@ -492,6 +505,7 @@ int pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg,
 void pmbus_clear_faults(struct i2c_client *client);
 bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg);
 bool pmbus_check_word_register(struct i2c_client *client, int page, int reg);
+int pmbus_query_register(struct i2c_client *client, int reg);
 int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info);
 const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client
 						      *client);
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index d462f732f3b40..4bcb70ab9b598 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -648,6 +648,27 @@ static int pmbus_get_status(struct i2c_client *client, int page, int reg)
 	return status;
 }
 
+int pmbus_query_register(struct i2c_client *client, int reg)
+{
+	int rv;
+	union i2c_smbus_data data;
+
+	data.block[0] = 1;
+	data.block[1] = reg;
+
+	rv = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
+			    I2C_SMBUS_WRITE, PMBUS_QUERY,
+			    I2C_SMBUS_BLOCK_PROC_CALL, &data);
+	if (rv < 0)
+		return rv;
+
+	if (data.block[0] != 1)
+		return -EIO;
+
+	return data.block[1];
+}
+EXPORT_SYMBOL_NS_GPL(pmbus_query_register, PMBUS);
+
 static void pmbus_update_sensor_data(struct i2c_client *client, struct pmbus_sensor *sensor)
 {
 	if (sensor->data < 0 || sensor->update)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ