[PATCH v1 2/3] hwmon: (emc1403) Convert to use OF bindings

From: Svyatoslav Ryhel

Date: Wed Jun 03 2026 - 10:18:12 EST


From: Jonas Schwöbel <jonasschwoebel@xxxxxxxx>

Add OF match compatible table to be able to use this driver with Device
Trees.

Signed-off-by: Jonas Schwöbel <jonasschwoebel@xxxxxxxx>
Signed-off-by: Svyatoslav Ryhel <clamor95@xxxxxxxxx>
---
drivers/hwmon/emc1403.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
index 964a8cb278f1..ac84200be71a 100644
--- a/drivers/hwmon/emc1403.c
+++ b/drivers/hwmon/emc1403.c
@@ -16,6 +16,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
+#include <linux/mod_devicetable.h>
#include <linux/sysfs.h>
#include <linux/regmap.h>
#include <linux/util_macros.h>
@@ -659,14 +660,16 @@ static int emc1403_probe(struct i2c_client *client)
{
struct thermal_data *data;
struct device *hwmon_dev;
- const struct i2c_device_id *id = i2c_match_id(emc1403_idtable, client);

data = devm_kzalloc(&client->dev, sizeof(struct thermal_data),
GFP_KERNEL);
if (!data)
return -ENOMEM;

- data->chip = id->driver_data;
+ data->chip = (enum emc1403_chip)i2c_get_match_data(client);
+ if (!data->chip)
+ return dev_err_probe(&client->dev, -ENODEV, "Unknown device!\n");
+
data->regmap = devm_regmap_init_i2c(client, &emc1403_regmap_config);
if (IS_ERR(data->regmap))
return PTR_ERR(data->regmap);
@@ -682,10 +685,21 @@ static const unsigned short emc1403_address_list[] = {
0x18, 0x1c, 0x29, 0x3c, 0x4c, 0x4d, 0x5c, I2C_CLIENT_END
};

+static const struct of_device_id emc1403_of_match[] = {
+ { .compatible = "smsc,emc1402", .data = (void *)emc1402 },
+ { .compatible = "smsc,emc1403", .data = (void *)emc1403 },
+ { .compatible = "smsc,emc1404", .data = (void *)emc1404 },
+ { .compatible = "smsc,emc1428", .data = (void *)emc1428 },
+ { }
+
+};
+MODULE_DEVICE_TABLE(of, emc1403_of_match);
+
static struct i2c_driver sensor_emc1403 = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = "emc1403",
+ .of_match_table = emc1403_of_match,
},
.detect = emc1403_detect,
.probe = emc1403_probe,
--
2.53.0