Skip to contentSkip to conversation

mfd: max77620: publish I2C and OF module aliases

PATCH In review hpp.iscas 3 participants 4 messages Sep 5 – Sep 10 Multifunction devices (MFD)

lore
Share & tools
lore

hpp.iscas

author
#0 lore raw

PATCH 1/1 mfd: max77620: publish I2C and OF module aliases

MFD_MAX77620 became tristate without publishing any module alias for the I2C driver. Device Tree I2C clients emit OF modaliases, while legacy board-info clients use the existing I2C IDs, so both supported enumeration paths need module metadata.

Publish the I2C table and add an OF table for the three documented compatibles. Keep i2c_client_get_device_id() as the source of chip data and leave MFD child registration unchanged.

Fixes 0d084ee9ba87 ("mfd: max77620: Allow building as a module")
---
 drivers/mfd/max77620.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mfd/max77620.c +10 -0
index c4f89a9..6a624e6 100644
@@ -699,6 +699,15 @@ static const struct i2c_device_id max77620_id[] = {
 	{"max77663", MAX77663},
 	{},
 };
+MODULE_DEVICE_TABLE(i2c, max77620_id);
+
+static const struct of_device_id max77620_of_match[] = {
+	{ .compatible = "maxim,max77620" },
+	{ .compatible = "maxim,max20024" },
+	{ .compatible = "maxim,max77663" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, max77620_of_match);
 
 static DEFINE_SIMPLE_DEV_PM_OPS(max77620_pm_ops,
 				max77620_i2c_suspend, max77620_i2c_resume);
@@ -706,6 +715,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(max77620_pm_ops,
 static struct i2c_driver max77620_driver = {
 	.driver = {
 		.name = "max77620",
+		.of_match_table = max77620_of_match,
 		.pm = pm_sleep_ptr(&max77620_pm_ops),
 	},
 	.probe = max77620_probe,
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Adding an `of_match_table` without migrating device matching logic causes a NULL pointer…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Adding an of_match_table without migrating device matching logic causes a NULL pointer dereference when binding via OF fallback compatibles. --

commit d8b3d136289436a8115d93de5fbb49572114282f
Author: hpp.iscas <[email protected]>

mfd: max77620: publish I2C and OF module aliases

This commit publishes the I2C module alias and adds an OF match table to support device enumeration. The patch intentionally leaves the existing i2c_client_get_device_id() call as the source of chip data.

Quoted 6 lines
drivers/mfd/max77620.c +0 -0
index c4f89a9681f34..6a624e691fe83 100644
@@ -699,6 +699,15 @@ static const struct i2c_device_id max77620_id[] = {
 	{"max77663", MAX77663},

drivers/mfd/max77620.c static const struct i2c_device_id max77620_id[] = { · line 709

Quoted 10 lines
drivers/mfd/max77620.c +8 -0
 	{},
 };
+MODULE_DEVICE_TABLE(i2c, max77620_id);
+
+static const struct of_device_id max77620_of_match[] = {
+	{ .compatible = "maxim,max77620" },
+	{ .compatible = "maxim,max20024" },
+	{ .compatible = "maxim,max77663" },
+	{ }
+};

[Severity: High]
Does adding this OF match table without populating the .data fields and migrating the matching logic to i2c_get_match_data() introduce a NULL pointer dereference during probe?

If a device tree uses a fallback compatible string not present in the I2C ID table (e.g., compatible = "maxim,future-chip", "maxim,max77620";), the device will bind successfully due to this new OF match table. However, the I2C core sets client->name to the first string ("future-chip").

Because max77620_probe() still relies on i2c_client_get_device_id() to obtain chip data:

drivers/mfd/max77620.c:max77620_probe() {
    ...
    const struct i2c_device_id *id = i2c_client_get_device_id(client);
    ...
    chip->chip_id = (enum max77620_chip_id)id->driver_data;
    ...
}

Will i2c_client_get_device_id() return NULL since the fallback name isn't in the I2C table, leading to a kernel panic when dereferencing id->driver_data?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
Quoted 2 lines · On Sat, 05 Sep 2026, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Adding an of_match_table without migrating device matching logic causes a NULL pointer dereference when binding via OF fallback compatibles.

Please review, explain or fix the Sashiko review(s).

If this is a set, this request includes the other patches too.

Quoted 54 lines

--

commit d8b3d136289436a8115d93de5fbb49572114282f
Author: hpp.iscas <[email protected]>

mfd: max77620: publish I2C and OF module aliases

This commit publishes the I2C module alias and adds an OF match table to support device enumeration. The patch intentionally leaves the existing i2c_client_get_device_id() call as the source of chip data.

Quoted 6 lines
drivers/mfd/max77620.c +0 -0
index c4f89a9681f34..6a624e691fe83 100644
@@ -699,6 +699,15 @@ static const struct i2c_device_id max77620_id[] = {
 	{"max77663", MAX77663},

drivers/mfd/max77620.c static const struct i2c_device_id max77620_id[] = { · line 709

Quoted 10 lines
drivers/mfd/max77620.c +8 -0
 	{},
 };
+MODULE_DEVICE_TABLE(i2c, max77620_id);
+
+static const struct of_device_id max77620_of_match[] = {
+	{ .compatible = "maxim,max77620" },
+	{ .compatible = "maxim,max20024" },
+	{ .compatible = "maxim,max77663" },
+	{ }
+};

[Severity: High]
Does adding this OF match table without populating the .data fields and migrating the matching logic to i2c_get_match_data() introduce a NULL pointer dereference during probe?

If a device tree uses a fallback compatible string not present in the I2C ID table (e.g., compatible = "maxim,future-chip", "maxim,max77620";), the device will bind successfully due to this new OF match table. However, the I2C core sets client->name to the first string ("future-chip").

Because max77620_probe() still relies on i2c_client_get_device_id() to obtain chip data:

drivers/mfd/max77620.c:max77620_probe() {
    ...
    const struct i2c_device_id *id = i2c_client_get_device_id(client);
    ...
    chip->chip_id = (enum max77620_chip_id)id->driver_data;
    ...
}

Will i2c_client_get_device_id() return NULL since the fallback name isn't in the I2C table, leading to a kernel panic when dereferencing id->driver_data?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Signature · 1 line
Lee Jones
maintainer
#3 lore raw
In reply to hpp.iscas
Quoted 11 lines · hpp.iscas

MFD_MAX77620 became tristate without publishing any module alias for the I2C driver. Device Tree I2C clients emit OF modaliases, while legacy board-info clients use the existing I2C IDs, so both supported enumeration paths need module metadata.

Publish the I2C table and add an OF table for the three documented compatibles. Keep i2c_client_get_device_id() as the source of chip data and leave MFD child registration unchanged.

Fixes 0d084ee9ba87 ("mfd: max77620: Allow building as a module")

Real name please.

Quoted 33 lines
---
 drivers/mfd/max77620.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mfd/max77620.c +10 -0
index c4f89a9..6a624e6 100644
@@ -699,6 +699,15 @@ static const struct i2c_device_id max77620_id[] = {
 	{"max77663", MAX77663},
 	{},
 };
+MODULE_DEVICE_TABLE(i2c, max77620_id);
+
+static const struct of_device_id max77620_of_match[] = {
+	{ .compatible = "maxim,max77620" },
+	{ .compatible = "maxim,max20024" },
+	{ .compatible = "maxim,max77663" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, max77620_of_match);
 
 static DEFINE_SIMPLE_DEV_PM_OPS(max77620_pm_ops,
 				max77620_i2c_suspend, max77620_i2c_resume);
@@ -706,6 +715,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(max77620_pm_ops,
 static struct i2c_driver max77620_driver = {
 	.driver = {
 		.name = "max77620",
+		.of_match_table = max77620_of_match,
 		.pm = pm_sleep_ptr(&max77620_pm_ops),
 	},
 	.probe = max77620_probe,
Signature · 1 line
Lee Jones