[PATCH] iio: adc: rtq6056: add i2c_device_id support

Kevin Tung posted 1 patch 1 month, 3 weeks ago
drivers/iio/adc/rtq6056.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
[PATCH] iio: adc: rtq6056: add i2c_device_id support
Posted by Kevin Tung 1 month, 3 weeks ago
Add i2c_device_id table to support legacy I2C instantiation.
Update probe to use i2c_get_match_data() so device data can be
retrieved consistently for both OF and legacy I2C instantiation.

Signed-off-by: Kevin Tung <kevin.tung.openbmc@gmail.com>
---
 drivers/iio/adc/rtq6056.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/rtq6056.c b/drivers/iio/adc/rtq6056.c
index 2bf3a09ac6b0416d1afea85de3d343ed503ac3b9..e2b1da13c0d31fa90cf9a7bfe494f331bcce2675 100644
--- a/drivers/iio/adc/rtq6056.c
+++ b/drivers/iio/adc/rtq6056.c
@@ -728,7 +728,7 @@ static int rtq6056_probe(struct i2c_client *i2c)
 	if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_WORD_DATA))
 		return -EOPNOTSUPP;
 
-	devdata = device_get_match_data(dev);
+	devdata = i2c_get_match_data(i2c);
 	if (!devdata)
 		return dev_err_probe(dev, -EINVAL, "Invalid dev data\n");
 
@@ -871,6 +871,13 @@ static const struct richtek_dev_data rtq6059_devdata = {
 	.set_average = rtq6059_adc_set_average,
 };
 
+static const struct i2c_device_id rtq6056_id[] = {
+	{ "rtq6056", (kernel_ulong_t)&rtq6056_devdata },
+	{ "rtq6059", (kernel_ulong_t)&rtq6059_devdata },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, rtq6056_id);
+
 static const struct of_device_id rtq6056_device_match[] = {
 	{ .compatible = "richtek,rtq6056", .data = &rtq6056_devdata },
 	{ .compatible = "richtek,rtq6059", .data = &rtq6059_devdata },
@@ -885,6 +892,7 @@ static struct i2c_driver rtq6056_driver = {
 		.pm = pm_ptr(&rtq6056_pm_ops),
 	},
 	.probe = rtq6056_probe,
+	.id_table = rtq6056_id,
 };
 module_i2c_driver(rtq6056_driver);
 

---
base-commit: c1f49dea2b8f335813d3b348fd39117fb8efb428
change-id: 20260420-rtq6056_support_sysfs_instantiation-c6ee66edbec7

Best regards,
-- 
Kevin Tung <kevin.tung.openbmc@gmail.com>
Re: [PATCH] iio: adc: rtq6056: add i2c_device_id support
Posted by Andy Shevchenko 1 month, 3 weeks ago
On Mon, Apr 20, 2026 at 08:52:52PM +0800, Kevin Tung wrote:
> Add i2c_device_id table to support legacy I2C instantiation.
> Update probe to use i2c_get_match_data() so device data can be
> retrieved consistently for both OF and legacy I2C instantiation.

Maybe someone finds this useful...
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH] iio: adc: rtq6056: add i2c_device_id support
Posted by Jonathan Cameron 1 month, 3 weeks ago
On Mon, 20 Apr 2026 20:12:49 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Mon, Apr 20, 2026 at 08:52:52PM +0800, Kevin Tung wrote:
> > Add i2c_device_id table to support legacy I2C instantiation.
> > Update probe to use i2c_get_match_data() so device data can be
> > retrieved consistently for both OF and legacy I2C instantiation.  
> 
> Maybe someone finds this useful...
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 
Applied.
Re: [PATCH] iio: adc: rtq6056: add i2c_device_id support
Posted by ChiYuan Huang 1 month, 3 weeks ago
On Tue, Apr 21, 2026 at 03:54:26PM +0100, Jonathan Cameron wrote:
> On Mon, 20 Apr 2026 20:12:49 +0300
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> 
> > On Mon, Apr 20, 2026 at 08:52:52PM +0800, Kevin Tung wrote:
> > > Add i2c_device_id table to support legacy I2C instantiation.
> > > Update probe to use i2c_get_match_data() so device data can be
> > > retrieved consistently for both OF and legacy I2C instantiation.  
> > 
> > Maybe someone finds this useful...
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> > 
> Applied.
Hi, Jonathan:

Since 89a1034cd841 ("iio: adc: rtq6056: Add support for the whole RTQ6056 family")
break the sysfs usage, should we Cc <"stable@vger.kernel.org"> to make
it backported?

BR,
ChiYuan.
Re: [PATCH] iio: adc: rtq6056: add i2c_device_id support
Posted by Andy Shevchenko 1 month, 3 weeks ago
On Wed, Apr 22, 2026 at 10:07:33AM +0800, ChiYuan Huang wrote:
> On Tue, Apr 21, 2026 at 03:54:26PM +0100, Jonathan Cameron wrote:
> > On Mon, 20 Apr 2026 20:12:49 +0300
> > Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > > On Mon, Apr 20, 2026 at 08:52:52PM +0800, Kevin Tung wrote:
> > > > Add i2c_device_id table to support legacy I2C instantiation.
> > > > Update probe to use i2c_get_match_data() so device data can be
> > > > retrieved consistently for both OF and legacy I2C instantiation.  
> > > 
> > > Maybe someone finds this useful...
> > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> > > 
> > Applied.

> Since 89a1034cd841 ("iio: adc: rtq6056: Add support for the whole RTQ6056 family")
> break the sysfs usage, should we Cc <"stable@vger.kernel.org"> to make
> it backported?

In that case you need to add Fixes tag as well.

Fixes: 89a1034cd841 ("iio: adc: rtq6056: Add support for the whole RTQ6056 family")
Cc: stable@vger.kernel.org

-- 
With Best Regards,
Andy Shevchenko