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: Tue, 18 Jun 2024 18:06:43 +0200
From: Farouk Bouabid <farouk.bouabid@...rry.de>
To: Jean Delvare <jdelvare@...e.com>, Guenter Roeck <linux@...ck-us.net>, 
 Andi Shyti <andi.shyti@...nel.org>, Rob Herring <robh@...nel.org>, 
 Krzysztof Kozlowski <krzk+dt@...nel.org>, 
 Conor Dooley <conor+dt@...nel.org>, Lee Jones <lee@...nel.org>, 
 Farouk Bouabid <farouk.bouabid@...rry.de>, 
 Quentin Schulz <quentin.schulz@...rry.de>, Peter Rosin <peda@...ntia.se>, 
 Heiko Stuebner <heiko@...ech.de>
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org, 
 linux-i2c@...r.kernel.org, devicetree@...r.kernel.org, 
 linux-arm-kernel@...ts.infradead.org, linux-rockchip@...ts.infradead.org
Subject: [PATCH v4 1/9] hwmon: (amc6821) add platform driver probe

Prepare for probing amc6821 in an I2C MFD device, by adding support to
probing amc6821 as a platform device.

Signed-off-by: Farouk Bouabid <farouk.bouabid@...rry.de>
---
 drivers/hwmon/amc6821.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
index 9b02b304c2f5..464991fd7fc9 100644
--- a/drivers/hwmon/amc6821.c
+++ b/drivers/hwmon/amc6821.c
@@ -18,6 +18,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/err.h>
 #include <linux/mutex.h>
+#include <linux/platform_device.h>
 
 /*
  * Addresses to scan.
@@ -900,9 +901,8 @@ static int amc6821_init_client(struct i2c_client *client)
 	return 0;
 }
 
-static int amc6821_probe(struct i2c_client *client)
+static int probe(struct device *dev, struct i2c_client *client)
 {
-	struct device *dev = &client->dev;
 	struct amc6821_data *data;
 	struct device *hwmon_dev;
 	int err;
@@ -927,6 +927,18 @@ static int amc6821_probe(struct i2c_client *client)
 	return PTR_ERR_OR_ZERO(hwmon_dev);
 }
 
+static int amc6821_probe(struct i2c_client *client)
+{
+	return probe(&client->dev, client);
+}
+
+static int amc6821_platform_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+
+	return probe(dev, to_i2c_client(dev->parent));
+}
+
 static const struct i2c_device_id amc6821_id[] = {
 	{ "amc6821", amc6821 },
 	{ }
@@ -958,6 +970,16 @@ static struct i2c_driver amc6821_driver = {
 
 module_i2c_driver(amc6821_driver);
 
+static struct platform_driver amc6821_platform_driver = {
+	.driver = {
+		.name	= "amc6821",
+		.of_match_table = of_match_ptr(amc6821_of_match),
+	},
+	.probe = amc6821_platform_probe,
+};
+
+module_platform_driver(amc6821_platform_driver);
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("T. Mertelj <tomaz.mertelj@...st.arnes.si>");
 MODULE_DESCRIPTION("Texas Instruments amc6821 hwmon driver");

-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ