]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i2c: xiic: use numbered adapter registration
authorAbdurrahman Hussain <abdurrahman@nexthop.ai>
Mon, 23 Feb 2026 15:59:21 +0000 (15:59 +0000)
committerAndi Shyti <andi.shyti@kernel.org>
Wed, 1 Apr 2026 23:27:56 +0000 (01:27 +0200)
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>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260223-i2c-xiic-v12-6-b6c9ce4e4f3c@nexthop.ai
drivers/i2c/busses/i2c-xiic.c

index 80e183b6e4f174ca8baf5bbdf1b4ae536961c56c..6eb0c6a2618a9d2eb9fd1b2ddf7e4f812adb81e1 100644 (file)
@@ -1451,6 +1451,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 = &pdev->dev;
        device_set_node(&i2c->adap.dev, fwnode);
@@ -1507,7 +1508,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;