[PATCH v2 2/4] iio: adc: ltc2309: Use i2c_get_match_data() helper

Carlos Jones Jr posted 4 patches 1 week, 5 days ago
[PATCH v2 2/4] iio: adc: ltc2309: Use i2c_get_match_data() helper
Posted by Carlos Jones Jr 1 week, 5 days ago
Convert the driver to use the i2c_get_match_data() helper function
for retrieving chip-specific information. This simplifies device
identification and aligns with modern kernel practices.

Update both of_device_id and i2c_device_id tables to include
chip_info data pointers. The device name is now sourced from
chip_info to ensure proper identification in sysfs.

No functional changes to existing LTC2309 behavior.

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
---
 drivers/iio/adc/ltc2309.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c
index 0644b1f02568..475ecc21ebe9 100644
--- a/drivers/iio/adc/ltc2309.c
+++ b/drivers/iio/adc/ltc2309.c
@@ -191,7 +191,7 @@ static int ltc2309_probe(struct i2c_client *client)
 	ltc2309 = iio_priv(indio_dev);
 	ltc2309->dev = &indio_dev->dev;
 	ltc2309->client = client;
-	chip_info = &ltc2309_chip_info;
+	chip_info = i2c_get_match_data(client);
 	ltc2309->read_delay_us = chip_info->read_delay_us;
 
 	indio_dev->name = chip_info->name;
@@ -213,13 +213,13 @@ static int ltc2309_probe(struct i2c_client *client)
 }
 
 static const struct of_device_id ltc2309_of_match[] = {
-	{ .compatible = "lltc,ltc2309" },
+	{ .compatible = "lltc,ltc2309", .data = &ltc2309_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ltc2309_of_match);
 
 static const struct i2c_device_id ltc2309_id[] = {
-	{ "ltc2309" },
+	{ "ltc2309", (kernel_ulong_t)&ltc2309_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, ltc2309_id);
-- 
2.43.0
Re: [PATCH v2 2/4] iio: adc: ltc2309: Use i2c_get_match_data() helper
Posted by Andy Shevchenko 1 week, 5 days ago
On Tue, Mar 24, 2026 at 03:13:29PM +0800, Carlos Jones Jr wrote:
> Convert the driver to use the i2c_get_match_data() helper function
> for retrieving chip-specific information. This simplifies device
> identification and aligns with modern kernel practices.
> 
> Update both of_device_id and i2c_device_id tables to include
> chip_info data pointers. The device name is now sourced from
> chip_info to ensure proper identification in sysfs.
> 
> No functional changes to existing LTC2309 behavior.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko