[PATCH v4 1/9] hwmon: (amc6821) add platform driver probe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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@xxxxxxxxxxxxxx>");
 MODULE_DESCRIPTION("Texas Instruments amc6821 hwmon driver");

-- 
2.34.1





[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux