mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nvmem: m24lr: Remove use of i2c_match_id()
@ 2026-11-18 16:22 Andrew Davis
  2026-11-24 21:17 ` Srinivas Kandagatla
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Davis @ 2026-11-18 16:22 UTC (permalink / raw)
  To: Srinivas Kandagatla; +Cc: 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().

It also checks for device match data, which allows for OF and
ACPI based probing. That means we do not have to manually check
those first and can remove those checks.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/nvmem/m24lr.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/nvmem/m24lr.c b/drivers/nvmem/m24lr.c
index 04bec3a5b1380..769996f401282 100644
--- a/drivers/nvmem/m24lr.c
+++ b/drivers/nvmem/m24lr.c
@@ -468,23 +468,6 @@ static struct attribute *m24lr_ctl_dev_attrs[] = {
 	NULL,
 };
 
-static const struct m24lr_chip *m24lr_get_chip(struct device *dev)
-{
-	const struct m24lr_chip *ret;
-	const struct i2c_device_id *id;
-
-	id = i2c_match_id(m24lr_ids, to_i2c_client(dev));
-
-	if (dev->of_node && of_match_device(m24lr_of_match, dev))
-		ret = of_device_get_match_data(dev);
-	else if (id)
-		ret = (void *)id->driver_data;
-	else
-		ret = acpi_device_get_match_data(dev);
-
-	return ret;
-}
-
 static int m24lr_probe(struct i2c_client *client)
 {
 	struct regmap_config eeprom_regmap_conf = {0};
@@ -502,7 +485,7 @@ static int m24lr_probe(struct i2c_client *client)
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
 		return -EOPNOTSUPP;
 
-	chip = m24lr_get_chip(dev);
+	chip = i2c_get_match_data(client);
 	if (!chip)
 		return -ENODEV;
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] nvmem: m24lr: Remove use of i2c_match_id()
  2026-11-18 16:22 [PATCH] nvmem: m24lr: Remove use of i2c_match_id() Andrew Davis
@ 2026-11-24 21:17 ` Srinivas Kandagatla
  0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2026-11-24 21:17 UTC (permalink / raw)
  To: Andrew Davis; +Cc: linux-kernel


On Wed, 18 Nov 2026 10:22:51 -0600, Andrew Davis wrote:
> 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().
> 
> It also checks for device match data, which allows for OF and
> ACPI based probing. That means we do not have to manually check
> those first and can remove those checks.
> 
> [...]

Applied, thanks!

[1/1] nvmem: m24lr: Remove use of i2c_match_id()
      commit: f630f2a0930162cddcc6b7a88a9f7e2bfd89ae63

Best regards,
-- 
Srinivas Kandagatla <srini@kernel.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24 21:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 16:22 [PATCH] nvmem: m24lr: Remove use of i2c_match_id() Andrew Davis
2026-11-24 21:17 ` Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®