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: <20240704111624.1583460-3-akshay.gupta@amd.com>
Date: Thu, 4 Jul 2024 11:16:20 +0000
From: Akshay Gupta <akshay.gupta@....com>
To: <linux-hwmon@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<linux@...ck-us.net>, <gregkh@...uxfoundation.org>, <arnd@...db.de>
CC: <naveenkrishna.chatradhi@....com>, Akshay Gupta <akshay.gupta@....com>
Subject: [PATCH 2/6] misc: sbrmi: Add platform device add to create platform device

- AMD provides socket power information from out of band
  which can be read by sensors.
- platform driver will probe drivers/hwmon/sbrmi as a platform device
  and share the sbrmi device data.

Signed-off-by: Akshay Gupta <akshay.gupta@....com>
Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@....com>
---
 drivers/misc/amd-sb/sbrmi-i2c.c | 25 ++++++++++++++++++++++++-
 include/misc/amd-sb.h           |  2 ++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/amd-sb/sbrmi-i2c.c b/drivers/misc/amd-sb/sbrmi-i2c.c
index c4903d9e9f0f..b593bbdd78e0 100644
--- a/drivers/misc/amd-sb/sbrmi-i2c.c
+++ b/drivers/misc/amd-sb/sbrmi-i2c.c
@@ -72,7 +72,29 @@ static int sbrmi_i2c_probe(struct i2c_client *client)
 		return ret;
 
 	/* Cache maximum power limit */
-	return sbrmi_get_max_pwr_limit(data);
+	ret = sbrmi_get_max_pwr_limit(data);
+	if (ret < 0)
+		return ret;
+
+	dev_set_drvdata(dev, (void *)data);
+	data->pdev = platform_device_register_data(dev, "sbrmi-hwmon",
+						   PLATFORM_DEVID_NONE,
+						   data,
+						   sizeof(struct sbrmi_data));
+	if (IS_ERR(data->pdev)) {
+		pr_err("unable to register platform device for sbrmi-hwmon\n");
+		return PTR_ERR(data->pdev);
+	}
+	return ret;
+}
+
+static void sbrmi_i2c_remove(struct i2c_client *client)
+{
+	struct sbrmi_data *data = dev_get_drvdata(&client->dev);
+
+	if (!data)
+		return;
+	platform_device_unregister(data->pdev);
 }
 
 static const struct i2c_device_id sbrmi_id[] = {
@@ -95,6 +117,7 @@ static struct i2c_driver sbrmi_driver = {
 		.of_match_table = of_match_ptr(sbrmi_of_match),
 	},
 	.probe = sbrmi_i2c_probe,
+	.remove = sbrmi_i2c_remove,
 	.id_table = sbrmi_id,
 };
 
diff --git a/include/misc/amd-sb.h b/include/misc/amd-sb.h
index e1a012fcdff9..79b76dd6068a 100644
--- a/include/misc/amd-sb.h
+++ b/include/misc/amd-sb.h
@@ -8,6 +8,7 @@
 
 #include <linux/mutex.h>
 #include <linux/i2c.h>
+#include <linux/platform_device.h>
 /*
  * SB-RMI supports soft mailbox service request to MP1 (power management
  * firmware) through SBRMI inbound/outbound message registers.
@@ -24,6 +25,7 @@ enum sbrmi_msg_id {
 struct sbrmi_data {
 	struct i2c_client *client;
 	struct mutex lock;
+	struct platform_device *pdev;
 	u32 pwr_limit_max;
 };
 
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ