* [PATCH v2 01/11] hwmon: (pmbus/bel-pfe) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 17:16 ` [PATCH v2 02/11] hwmon: (pmbus/ibm-cffps) " Andrew Davis
` (10 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has another benefit:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove that.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/bel-pfe.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/hwmon/pmbus/bel-pfe.c b/drivers/hwmon/pmbus/bel-pfe.c
index ddf9d9a2958c4..6499556f735b4 100644
--- a/drivers/hwmon/pmbus/bel-pfe.c
+++ b/drivers/hwmon/pmbus/bel-pfe.c
@@ -88,13 +88,10 @@ static struct pmbus_driver_info pfe_driver_info[] = {
},
};
-static const struct i2c_device_id pfe_device_id[];
-
static int pfe_pmbus_probe(struct i2c_client *client)
{
- int model;
+ int model = (uintptr_t)i2c_get_match_data(client);
- model = (int)i2c_match_id(pfe_device_id, client)->driver_data;
client->dev.platform_data = &pfe_plat_data;
/*
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 02/11] hwmon: (pmbus/ibm-cffps) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
2026-03-06 17:16 ` [PATCH v2 01/11] hwmon: (pmbus/bel-pfe) Remove use of i2c_match_id() Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 17:16 ` [PATCH v2 03/11] hwmon: (pmbus/isl68137) " Andrew Davis
` (9 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has another benefit:
* It also checks for device match data, which allows for OF based
probing. That means we do not have to manually check those first
and can remove that check.
As i2c_get_match_data() return NULL/0 on failure which also matches
the enum for "cffps1", switch around the enum order so cffps_unknown
is index 0 and existing behavior is preserved.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/ibm-cffps.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
index d05ef7a968a96..6c7256d997f46 100644
--- a/drivers/hwmon/pmbus/ibm-cffps.c
+++ b/drivers/hwmon/pmbus/ibm-cffps.c
@@ -58,7 +58,7 @@ enum {
CFFPS_DEBUGFS_NUM_ENTRIES
};
-enum versions { cffps1, cffps2, cffps_unknown };
+enum versions { cffps_unknown, cffps1, cffps2 };
struct ibm_cffps {
enum versions version;
@@ -482,19 +482,9 @@ MODULE_DEVICE_TABLE(i2c, ibm_cffps_id);
static int ibm_cffps_probe(struct i2c_client *client)
{
int i, rc;
- enum versions vs = cffps_unknown;
+ enum versions vs = (uintptr_t)i2c_get_match_data(client);
struct dentry *debugfs;
struct ibm_cffps *psu;
- const void *md = of_device_get_match_data(&client->dev);
- const struct i2c_device_id *id;
-
- if (md) {
- vs = (uintptr_t)md;
- } else {
- id = i2c_match_id(ibm_cffps_id, client);
- if (id)
- vs = (enum versions)id->driver_data;
- }
if (vs == cffps_unknown) {
u16 ccin_revision = 0;
@@ -534,7 +524,7 @@ static int ibm_cffps_probe(struct i2c_client *client)
}
/* Set the client name to include the version number. */
- snprintf(client->name, I2C_NAME_SIZE, "cffps%d", vs + 1);
+ snprintf(client->name, I2C_NAME_SIZE, "cffps%d", vs);
}
client->dev.platform_data = &ibm_cffps_pdata;
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 03/11] hwmon: (pmbus/isl68137) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
2026-03-06 17:16 ` [PATCH v2 01/11] hwmon: (pmbus/bel-pfe) Remove use of i2c_match_id() Andrew Davis
2026-03-06 17:16 ` [PATCH v2 02/11] hwmon: (pmbus/ibm-cffps) " Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 17:16 ` [PATCH v2 04/11] hwmon: (pmbus/max20730) " Andrew Davis
` (8 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has a couple other benefits:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove that.
* It also checks for device match data, which allows for OF and
ACPI based probing.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/isl68137.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/hwmon/pmbus/isl68137.c b/drivers/hwmon/pmbus/isl68137.c
index 97b61836f53a4..78cff97128541 100644
--- a/drivers/hwmon/pmbus/isl68137.c
+++ b/drivers/hwmon/pmbus/isl68137.c
@@ -90,8 +90,6 @@ struct isl68137_data {
#define to_isl68137_data(x) container_of(x, struct isl68137_data, info)
-static const struct i2c_device_id raa_dmpvr_id[];
-
static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client,
int page,
char *buf)
@@ -375,7 +373,7 @@ static int isl68137_probe(struct i2c_client *client)
memcpy(&data->info, &raa_dmpvr_info, sizeof(data->info));
info = &data->info;
- switch (i2c_match_id(raa_dmpvr_id, client)->driver_data) {
+ switch ((uintptr_t)i2c_get_match_data(client)) {
case raa_dmpvr1_2rail:
info->pages = 2;
info->R[PSC_VOLTAGE_IN] = 3;
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 04/11] hwmon: (pmbus/max20730) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
` (2 preceding siblings ...)
2026-03-06 17:16 ` [PATCH v2 03/11] hwmon: (pmbus/isl68137) " Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 17:16 ` [PATCH v2 05/11] hwmon: (pmbus/max34440) " Andrew Davis
` (7 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has another benefit:
* It also checks for device match data. That means we do not have
to manually check that first.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/max20730.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/hwmon/pmbus/max20730.c b/drivers/hwmon/pmbus/max20730.c
index 95869d198ecf0..fe03164788dfa 100644
--- a/drivers/hwmon/pmbus/max20730.c
+++ b/drivers/hwmon/pmbus/max20730.c
@@ -715,10 +715,7 @@ static int max20730_probe(struct i2c_client *client)
return -ENODEV;
}
- if (client->dev.of_node)
- chip_id = (uintptr_t)of_device_get_match_data(dev);
- else
- chip_id = i2c_match_id(max20730_id, client)->driver_data;
+ chip_id = (uintptr_t)i2c_get_match_data(client);
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 05/11] hwmon: (pmbus/max34440) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
` (3 preceding siblings ...)
2026-03-06 17:16 ` [PATCH v2 04/11] hwmon: (pmbus/max20730) " Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 17:16 ` [PATCH v2 06/11] hwmon: (pmbus) " Andrew Davis
` (6 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has another benefit:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove that.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/max34440.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
index 8ea4e68d4e9de..cc96bb22f8f5a 100644
--- a/drivers/hwmon/pmbus/max34440.c
+++ b/drivers/hwmon/pmbus/max34440.c
@@ -71,8 +71,6 @@ struct max34440_data {
#define to_max34440_data(x) container_of(x, struct max34440_data, info)
-static const struct i2c_device_id max34440_id[];
-
static int max34440_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{
@@ -628,7 +626,7 @@ static int max34440_probe(struct i2c_client *client)
GFP_KERNEL);
if (!data)
return -ENOMEM;
- data->id = i2c_match_id(max34440_id, client)->driver_data;
+ data->id = (uintptr_t)i2c_get_match_data(client);
data->info = max34440_info[data->id];
data->iout_oc_fault_limit = MAX34440_IOUT_OC_FAULT_LIMIT;
data->iout_oc_warn_limit = MAX34440_IOUT_OC_WARN_LIMIT;
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 06/11] hwmon: (pmbus) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
` (4 preceding siblings ...)
2026-03-06 17:16 ` [PATCH v2 05/11] hwmon: (pmbus/max34440) " Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 17:16 ` [PATCH v2 07/11] hwmon: (pmbus/q54sj108a2) " Andrew Davis
` (5 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has another benefit:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove that.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/pmbus.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
index 920cd5408141a..d1844c7a51eef 100644
--- a/drivers/hwmon/pmbus/pmbus.c
+++ b/drivers/hwmon/pmbus/pmbus.c
@@ -20,8 +20,6 @@ struct pmbus_device_info {
u32 flags;
};
-static const struct i2c_device_id pmbus_id[];
-
/*
* Find sensor groups and status registers on each page.
*/
@@ -174,7 +172,7 @@ static int pmbus_probe(struct i2c_client *client)
if (!info)
return -ENOMEM;
- device_info = (struct pmbus_device_info *)i2c_match_id(pmbus_id, client)->driver_data;
+ device_info = (struct pmbus_device_info *)i2c_get_match_data(client);
if (device_info->flags) {
pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data),
GFP_KERNEL);
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 07/11] hwmon: (pmbus/q54sj108a2) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
` (5 preceding siblings ...)
2026-03-06 17:16 ` [PATCH v2 06/11] hwmon: (pmbus) " Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 17:16 ` [PATCH v2 08/11] hwmon: (pmbus/tps53679) " Andrew Davis
` (4 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has another benefit:
* It also checks for device match data, which means we do not have
to manually check that first.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/q54sj108a2.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/hwmon/pmbus/q54sj108a2.c b/drivers/hwmon/pmbus/q54sj108a2.c
index fc030ca34480c..88c25290ffce1 100644
--- a/drivers/hwmon/pmbus/q54sj108a2.c
+++ b/drivers/hwmon/pmbus/q54sj108a2.c
@@ -291,10 +291,7 @@ static int q54sj108a2_probe(struct i2c_client *client)
I2C_FUNC_SMBUS_BLOCK_DATA))
return -ENODEV;
- if (client->dev.of_node)
- chip_id = (enum chips)(unsigned long)of_device_get_match_data(dev);
- else
- chip_id = i2c_match_id(q54sj108a2_id, client)->driver_data;
+ chip_id = (enum chips)(uintptr_t)i2c_get_match_data(client);
ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
if (ret < 0) {
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 08/11] hwmon: (pmbus/tps53679) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
` (6 preceding siblings ...)
2026-03-06 17:16 ` [PATCH v2 07/11] hwmon: (pmbus/q54sj108a2) " Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 17:16 ` [PATCH v2 09/11] hwmon: (pmbus/fsp-3y) " Andrew Davis
` (3 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has another benefit:
* It also checks for device match data, which means we do not have
to manually check that first.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/tps53679.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/hwmon/pmbus/tps53679.c b/drivers/hwmon/pmbus/tps53679.c
index ca2bfa25eb04c..df2726659a4ed 100644
--- a/drivers/hwmon/pmbus/tps53679.c
+++ b/drivers/hwmon/pmbus/tps53679.c
@@ -253,10 +253,7 @@ static int tps53679_probe(struct i2c_client *client)
struct pmbus_driver_info *info;
enum chips chip_id;
- if (dev->of_node)
- chip_id = (uintptr_t)of_device_get_match_data(dev);
- else
- chip_id = i2c_match_id(tps53679_id, client)->driver_data;
+ chip_id = (uintptr_t)i2c_get_match_data(client);
info = devm_kmemdup(dev, &tps53679_info, sizeof(*info), GFP_KERNEL);
if (!info)
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 09/11] hwmon: (pmbus/fsp-3y) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
` (7 preceding siblings ...)
2026-03-06 17:16 ` [PATCH v2 08/11] hwmon: (pmbus/tps53679) " Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 17:16 ` [PATCH v2 10/11] hwmon: (pmbus/ltc2978) " Andrew Davis
` (2 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This can be done instead with
i2c_client_get_device_id() which doesn't need the i2c_device_id
passed in so we do not need to have that forward declared, allowing
us to move the i2c_device_id table down to its more natural spot
with the other module info.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/fsp-3y.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/hwmon/pmbus/fsp-3y.c b/drivers/hwmon/pmbus/fsp-3y.c
index a4dc09e2ef75a..cad4d23300036 100644
--- a/drivers/hwmon/pmbus/fsp-3y.c
+++ b/drivers/hwmon/pmbus/fsp-3y.c
@@ -222,12 +222,6 @@ static int fsp3y_detect(struct i2c_client *client)
return -ENODEV;
}
-static const struct i2c_device_id fsp3y_id[] = {
- {"ym2151e", ym2151e},
- {"yh5151e", yh5151e},
- { }
-};
-
static int fsp3y_probe(struct i2c_client *client)
{
struct fsp3y_data *data;
@@ -242,7 +236,7 @@ static int fsp3y_probe(struct i2c_client *client)
if (data->chip < 0)
return data->chip;
- id = i2c_match_id(fsp3y_id, client);
+ id = i2c_client_get_device_id(client);
if (data->chip != id->driver_data)
dev_warn(&client->dev, "Device mismatch: Configured %s (%d), detected %d\n",
id->name, (int)id->driver_data, data->chip);
@@ -276,6 +270,11 @@ static int fsp3y_probe(struct i2c_client *client)
return pmbus_do_probe(client, &data->info);
}
+static const struct i2c_device_id fsp3y_id[] = {
+ {"ym2151e", ym2151e},
+ {"yh5151e", yh5151e},
+ { }
+};
MODULE_DEVICE_TABLE(i2c, fsp3y_id);
static struct i2c_driver fsp3y_driver = {
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 10/11] hwmon: (pmbus/ltc2978) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
` (8 preceding siblings ...)
2026-03-06 17:16 ` [PATCH v2 09/11] hwmon: (pmbus/fsp-3y) " Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 18:10 ` Guenter Roeck
2026-03-06 17:16 ` [PATCH v2 11/11] hwmon: (pmbus/max16601) " Andrew Davis
2026-03-06 18:13 ` [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Guenter Roeck
11 siblings, 1 reply; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This can instead be done with
i2c_client_get_device_id(). For this driver functionality should
not change. Switch over to remove the last couple users of the
i2c_match_id() function from kernel.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/ltc2978.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
index 8f5be520a15db..d69a5e675e80e 100644
--- a/drivers/hwmon/pmbus/ltc2978.c
+++ b/drivers/hwmon/pmbus/ltc2978.c
@@ -733,7 +733,7 @@ static int ltc2978_probe(struct i2c_client *client)
return chip_id;
data->id = chip_id;
- id = i2c_match_id(ltc2978_id, client);
+ id = i2c_client_get_device_id(client);
if (data->id != id->driver_data)
dev_warn(&client->dev,
"Device mismatch: Configured %s (%d), detected %d\n",
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v2 10/11] hwmon: (pmbus/ltc2978) Remove use of i2c_match_id()
2026-03-06 17:16 ` [PATCH v2 10/11] hwmon: (pmbus/ltc2978) " Andrew Davis
@ 2026-03-06 18:10 ` Guenter Roeck
2026-03-06 18:30 ` Andrew Davis
0 siblings, 1 reply; 15+ messages in thread
From: Guenter Roeck @ 2026-03-06 18:10 UTC (permalink / raw)
To: Andrew Davis
Cc: Chiang Brian, Erick Karanja, Grant Peltier, Jeff Lin,
Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno,
linux-hwmon, linux-kernel
On Fri, Mar 06, 2026 at 11:16:51AM -0600, Andrew Davis wrote:
> The function i2c_match_id() is used to fetch the matching ID from
> the i2c_device_id table. This can instead be done with
> i2c_client_get_device_id(). For this driver functionality should
> not change. Switch over to remove the last couple users of the
> i2c_match_id() function from kernel.
>
> Signed-off-by: Andrew Davis <afd@ti.com>
> ---
> drivers/hwmon/pmbus/ltc2978.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
> index 8f5be520a15db..d69a5e675e80e 100644
> --- a/drivers/hwmon/pmbus/ltc2978.c
> +++ b/drivers/hwmon/pmbus/ltc2978.c
> @@ -733,7 +733,7 @@ static int ltc2978_probe(struct i2c_client *client)
> return chip_id;
>
> data->id = chip_id;
> - id = i2c_match_id(ltc2978_id, client);
> + id = i2c_client_get_device_id(client);
AI feedback:
Is `id` guaranteed to be non-NULL here?
If the device is instantiated via ACPI `PRP0001` or using a fallback DT
compatible string where the first compatible string is not in the
`ltc2978_id` table, `i2c_client_get_device_id()` will return `NULL`.
This leads to a NULL pointer dereference when accessing `id->driver_data`.
While this vulnerability existed in the old code with `i2c_match_id()`,
adding a NULL check here might be a good idea while the code is being
refactored.
I never know if this is real. Any idea ?
Thanks,
Guenter
> if (data->id != id->driver_data)
> dev_warn(&client->dev,
> "Device mismatch: Configured %s (%d), detected %d\n",
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 10/11] hwmon: (pmbus/ltc2978) Remove use of i2c_match_id()
2026-03-06 18:10 ` Guenter Roeck
@ 2026-03-06 18:30 ` Andrew Davis
0 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 18:30 UTC (permalink / raw)
To: Guenter Roeck
Cc: Chiang Brian, Erick Karanja, Grant Peltier, Jeff Lin,
Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno,
linux-hwmon, linux-kernel
On 3/6/26 12:10 PM, Guenter Roeck wrote:
> On Fri, Mar 06, 2026 at 11:16:51AM -0600, Andrew Davis wrote:
>> The function i2c_match_id() is used to fetch the matching ID from
>> the i2c_device_id table. This can instead be done with
>> i2c_client_get_device_id(). For this driver functionality should
>> not change. Switch over to remove the last couple users of the
>> i2c_match_id() function from kernel.
>>
>> Signed-off-by: Andrew Davis <afd@ti.com>
>> ---
>> drivers/hwmon/pmbus/ltc2978.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
>> index 8f5be520a15db..d69a5e675e80e 100644
>> --- a/drivers/hwmon/pmbus/ltc2978.c
>> +++ b/drivers/hwmon/pmbus/ltc2978.c
>> @@ -733,7 +733,7 @@ static int ltc2978_probe(struct i2c_client *client)
>> return chip_id;
>>
>> data->id = chip_id;
>> - id = i2c_match_id(ltc2978_id, client);
>> + id = i2c_client_get_device_id(client);
>
> AI feedback:
>
> Is `id` guaranteed to be non-NULL here?
>
> If the device is instantiated via ACPI `PRP0001` or using a fallback DT
> compatible string where the first compatible string is not in the
> `ltc2978_id` table, `i2c_client_get_device_id()` will return `NULL`.
> This leads to a NULL pointer dereference when accessing `id->driver_data`.
>
> While this vulnerability existed in the old code with `i2c_match_id()`,
> adding a NULL check here might be a good idea while the code is being
> refactored.
>
> I never know if this is real. Any idea ?
>
The AI is right on both parts, the second being the important one that
this was preexisting. i2c_match_id() should never return NULL in
practice as we must have matched on something to have gotten probe()'d
in the first place. And for the same reason i2c_client_get_device_id()
shouldn't ever return NULL either. So no change here.
But I see how this would confuse an AI as both functions have a
"return NULL;" statement in them. This problem of returning the matched
ID in-band with returning 0 for errors (which could also be a valid ID)
is one of the motivating reasons for me removing i2c_match_id(). Even
though its replacement has the same issue, once we get everyone over
to the same single API then switching that one API over to something
safer becomes possible.
Andrew
> Thanks,
> Guenter
>
>> if (data->id != id->driver_data)
>> dev_warn(&client->dev,
>> "Device mismatch: Configured %s (%d), detected %d\n",
>> --
>> 2.39.2
>>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 11/11] hwmon: (pmbus/max16601) Remove use of i2c_match_id()
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
` (9 preceding siblings ...)
2026-03-06 17:16 ` [PATCH v2 10/11] hwmon: (pmbus/ltc2978) " Andrew Davis
@ 2026-03-06 17:16 ` Andrew Davis
2026-03-06 18:13 ` [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Guenter Roeck
11 siblings, 0 replies; 15+ messages in thread
From: Andrew Davis @ 2026-03-06 17:16 UTC (permalink / raw)
To: Guenter Roeck, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel, Andrew Davis
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This can instead be done with
i2c_client_get_device_id(). For this driver functionality should
not change. Switch over to remove the last couple users of the
i2c_match_id() function from kernel.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/hwmon/pmbus/max16601.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/pmbus/max16601.c b/drivers/hwmon/pmbus/max16601.c
index d696e506aafba..36dc13424d929 100644
--- a/drivers/hwmon/pmbus/max16601.c
+++ b/drivers/hwmon/pmbus/max16601.c
@@ -318,7 +318,7 @@ static int max16601_probe(struct i2c_client *client)
if (chip_id < 0)
return chip_id;
- id = i2c_match_id(max16601_id, client);
+ id = i2c_client_get_device_id(client);
if (chip_id != id->driver_data)
dev_warn(&client->dev,
"Device mismatch: Configured %s (%d), detected %d\n",
--
2.39.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS
2026-03-06 17:16 [PATCH v2 00/11] Remove use of i2c_match_id in PMBUS Andrew Davis
` (10 preceding siblings ...)
2026-03-06 17:16 ` [PATCH v2 11/11] hwmon: (pmbus/max16601) " Andrew Davis
@ 2026-03-06 18:13 ` Guenter Roeck
11 siblings, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2026-03-06 18:13 UTC (permalink / raw)
To: Andrew Davis, Chiang Brian, Erick Karanja, Grant Peltier,
Jeff Lin, Cherrence Sarip, Kim Seer Paller, Alexis Czezar Torreno
Cc: linux-hwmon, linux-kernel
On 3/6/26 09:16, Andrew Davis wrote:
> Hello all,
>
> Much like we already have done for HWMON top level drivers,
> we are removing the i2c_match_id() function from all hwmon/pmbus/
> drivers now. Using i2c_get_match_data() can simplify code and has
> some other benefits described in the patches.
>
> I don't have most of this hardware, so testing is very welcome :)
>
It looks safe to me, so I'll apply the series. There is a potential
pre-existing problem in the ltc2978 driver, but that is really unrelated
to this series, and it is better to fix that separately anyway.
Thanks,
Guenter
> Thanks,
> Andrew
>
> Changes for v2:
> - Moved enum value [2/11] to prevent 0 from matching valid device
> - Trimmed all commit messages to only patch relevant info
>
> Andrew Davis (11):
> hwmon: (pmbus/bel-pfe) Remove use of i2c_match_id()
> hwmon: (pmbus/ibm-cffps) Remove use of i2c_match_id()
> hwmon: (pmbus/isl68137) Remove use of i2c_match_id()
> hwmon: (pmbus/max20730) Remove use of i2c_match_id()
> hwmon: (pmbus/max34440) Remove use of i2c_match_id()
> hwmon: (pmbus) Remove use of i2c_match_id()
> hwmon: (pmbus/q54sj108a2) Remove use of i2c_match_id()
> hwmon: (pmbus/tps53679) Remove use of i2c_match_id()
> hwmon: (pmbus/fsp-3y) Remove use of i2c_match_id()
> hwmon: (pmbus/ltc2978) Remove use of i2c_match_id()
> hwmon: (pmbus/max16601) Remove use of i2c_match_id()
>
> drivers/hwmon/pmbus/bel-pfe.c | 5 +----
> drivers/hwmon/pmbus/fsp-3y.c | 13 ++++++-------
> drivers/hwmon/pmbus/ibm-cffps.c | 16 +++-------------
> drivers/hwmon/pmbus/isl68137.c | 4 +---
> drivers/hwmon/pmbus/ltc2978.c | 2 +-
> drivers/hwmon/pmbus/max16601.c | 2 +-
> drivers/hwmon/pmbus/max20730.c | 5 +----
> drivers/hwmon/pmbus/max34440.c | 4 +---
> drivers/hwmon/pmbus/pmbus.c | 4 +---
> drivers/hwmon/pmbus/q54sj108a2.c | 5 +----
> drivers/hwmon/pmbus/tps53679.c | 5 +----
> 11 files changed, 18 insertions(+), 47 deletions(-)
>
^ permalink raw reply [flat|nested] 15+ messages in thread