Blob Blame History Raw
From 3481551f035725fdc46885425eac3ef9b58ae7b7 Mon Sep 17 00:00:00 2001
From: Camel Guo <camel.guo@axis.com>
Date: Tue, 3 May 2022 13:43:33 +0200
Subject: [PATCH] hwmon: (tmp401) Add OF device ID table
Git-commit: 3481551f035725fdc46885425eac3ef9b58ae7b7
Patch-mainline: v5.18-rc7
References: git-fixes

This driver doesn't have of_match_table. This makes the kernel module
tmp401.ko lack alias patterns (e.g: of:N*T*Cti,tmp411) to match DT node
of the supported devices hence this kernel module will not be
automatically loaded.

After adding of_match_table to this driver, the folllowing alias will be
added into tmp401.ko.
$ modinfo drivers/hwmon/tmp401.ko
Filename: drivers/hwmon/tmp401.ko
......
Author: Hans de Goede <hdegoede@redhat.com>
Alias: of:N*T*Cti,tmp435C*
Alias: of:N*T*Cti,tmp435
Alias: of:N*T*Cti,tmp432C*
Alias: of:N*T*Cti,tmp432
Alias: of:N*T*Cti,tmp431C*
Alias: of:N*T*Cti,tmp431
Alias: of:N*T*Cti,tmp411C*
Alias: of:N*T*Cti,tmp411
Alias: of:N*T*Cti,tmp401C*
Alias: of:N*T*Cti,tmp401
......

Fixes: af503716ac14 ("i2c: core: report OF style module alias for devices registered via OF")
Signed-off-by: Camel Guo <camel.guo@axis.com>
Link: https://lore.kernel.org/r/20220503114333.456476-1-camel.guo@axis.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/hwmon/tmp401.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
index b86d9df7105d..52c9e7d3f2ae 100644
--- a/drivers/hwmon/tmp401.c
+++ b/drivers/hwmon/tmp401.c
@@ -708,10 +708,21 @@ static int tmp401_probe(struct i2c_client *client)
 	return 0;
 }
 
+static const struct of_device_id __maybe_unused tmp4xx_of_match[] = {
+	{ .compatible = "ti,tmp401", },
+	{ .compatible = "ti,tmp411", },
+	{ .compatible = "ti,tmp431", },
+	{ .compatible = "ti,tmp432", },
+	{ .compatible = "ti,tmp435", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, tmp4xx_of_match);
+
 static struct i2c_driver tmp401_driver = {
 	.class		= I2C_CLASS_HWMON,
 	.driver = {
 		.name	= "tmp401",
+		.of_match_table = of_match_ptr(tmp4xx_of_match),
 	},
 	.probe_new	= tmp401_probe,
 	.id_table	= tmp401_id,
-- 
2.31.1