[PATCH v11 6/7] i2c: xiic: use numbered adapter registration

Abdurrahman Hussain via B4 Relay posted 7 patches 2 weeks, 6 days ago
There is a newer version of this series
[PATCH v11 6/7] i2c: xiic: use numbered adapter registration
Posted by Abdurrahman Hussain via B4 Relay 2 weeks, 6 days ago
From: Abdurrahman Hussain <abdurrahman@nexthop.ai>

Switch from i2c_add_adapter() to i2c_add_numbered_adapter() to enable
platforms to specify fixed I2C bus numbers via the platform device ID.

This allows systems to maintain consistent bus numbering across reboots.
On platforms where the device ID is PLATFORM_DEVID_NONE (the default),
the adapter falls back to dynamic allocation, preserving backward
compatibility.

Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
 drivers/i2c/busses/i2c-xiic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 373c00a93034..2ad75325154c 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1450,6 +1450,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
 	/* hook up driver to tree */
 	platform_set_drvdata(pdev, i2c);
 	i2c->adap = xiic_adapter;
+	i2c->adap.nr = pdev->id;
 	i2c_set_adapdata(&i2c->adap, i2c);
 	i2c->adap.dev.parent = dev;
 	device_set_node(&i2c->adap.dev, dev_fwnode(dev));
@@ -1506,7 +1507,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, ret, "Cannot xiic_reinit\n");
 
 	/* add i2c adapter to i2c tree */
-	ret = i2c_add_adapter(&i2c->adap);
+	ret = i2c_add_numbered_adapter(&i2c->adap);
 	if (ret) {
 		xiic_deinit(i2c);
 		return ret;

-- 
2.52.0
Re: [PATCH v11 6/7] i2c: xiic: use numbered adapter registration
Posted by Andy Shevchenko 2 weeks, 6 days ago
On Fri, Feb 13, 2026 at 12:15:21AM +0000, Abdurrahman Hussain via B4 Relay wrote:

> Switch from i2c_add_adapter() to i2c_add_numbered_adapter() to enable
> platforms to specify fixed I2C bus numbers via the platform device ID.
> 
> This allows systems to maintain consistent bus numbering across reboots.
> On platforms where the device ID is PLATFORM_DEVID_NONE (the default),
> the adapter falls back to dynamic allocation, preserving backward
> compatibility.

Assuming that the statement in the last sentence is proven and tested,
code wise patch LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko