Skip to content

Commit 3f003fd

Browse files
Josua-SRgroeck
authored andcommitted
hwmon: (amc6821) add of_match table
Add of_match table for "ti,amc6821" compatible string. This fixes automatic driver loading by userspace when using device-tree, and if built as a module like major linux distributions do. While devices probe just fine with i2c_device_id table, userspace can't match the "ti,amc6821" compatible string from dt with the plain "amc6821" device id. As a result, the kernel module can not be loaded. Cc: stable@vger.kernel.org Signed-off-by: Josua Mayer <josua@solid-run.com> Link: https://lore.kernel.org/r/20240307-amc6821-of-match-v1-1-5f40464a3110@solid-run.com [groeck: Cleaned up patch description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 78cc80d commit 3f003fd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/hwmon/amc6821.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,10 +934,21 @@ static const struct i2c_device_id amc6821_id[] = {
934934

935935
MODULE_DEVICE_TABLE(i2c, amc6821_id);
936936

937+
static const struct of_device_id __maybe_unused amc6821_of_match[] = {
938+
{
939+
.compatible = "ti,amc6821",
940+
.data = (void *)amc6821,
941+
},
942+
{ }
943+
};
944+
945+
MODULE_DEVICE_TABLE(of, amc6821_of_match);
946+
937947
static struct i2c_driver amc6821_driver = {
938948
.class = I2C_CLASS_HWMON,
939949
.driver = {
940950
.name = "amc6821",
951+
.of_match_table = of_match_ptr(amc6821_of_match),
941952
},
942953
.probe = amc6821_probe,
943954
.id_table = amc6821_id,

0 commit comments

Comments
 (0)