From 44454baa7ca7bb57c47a5564ed2528ba211fe8db Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Tue, 27 Mar 2012 11:10:28 +0200 Subject: [PATCH] i2c: Dynamically assign adapter id if it wasn't explictly specified Commit 488bf314b ("i2c: Allow i2c_add_numbered_adapter() to assign a bus id") reworked i2c_add_numbered_adapter() to call i2c_add_adapter() if requested bus was -1. This allows to simplify driver's initialization procedure by using just one function for static and dynamic adapter id registration. This patch updates few more drivers (missed out in original patch) to use this functionality. Signed-off-by: Karol Lewandowski Signed-off-by: Kyungmin Park Signed-off-by: Wolfram Sang --- drivers/i2c/busses/i2c-gpio.c | 7 +------ drivers/i2c/busses/i2c-pca-platform.c | 2 +- drivers/i2c/busses/i2c-versatile.c | 9 ++------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index c0330a41db03..e62d2d938628 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -190,12 +190,7 @@ static int __devinit i2c_gpio_probe(struct platform_device *pdev) adap->dev.parent = &pdev->dev; adap->dev.of_node = pdev->dev.of_node; - /* - * If "dev->id" is negative we consider it as zero. - * The reason to do so is to avoid sysfs names that only make - * sense when there are multiple adapters. - */ - adap->nr = (pdev->id != -1) ? pdev->id : 0; + adap->nr = pdev->id; ret = i2c_bit_add_numbered_bus(adap); if (ret) goto err_add_bus; diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c index 2adbf1a8fdea..675878f49f76 100644 --- a/drivers/i2c/busses/i2c-pca-platform.c +++ b/drivers/i2c/busses/i2c-pca-platform.c @@ -171,7 +171,7 @@ static int __devinit i2c_pca_pf_probe(struct platform_device *pdev) i2c->io_size = resource_size(res); i2c->irq = irq; - i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0; + i2c->adap.nr = pdev->id; i2c->adap.owner = THIS_MODULE; snprintf(i2c->adap.name, sizeof(i2c->adap.name), "PCA9564/PCA9665 at 0x%08lx", diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c index f585aead50cc..eec20db6246f 100644 --- a/drivers/i2c/busses/i2c-versatile.c +++ b/drivers/i2c/busses/i2c-versatile.c @@ -104,13 +104,8 @@ static int i2c_versatile_probe(struct platform_device *dev) i2c->algo = i2c_versatile_algo; i2c->algo.data = i2c; - if (dev->id >= 0) { - /* static bus numbering */ - i2c->adap.nr = dev->id; - ret = i2c_bit_add_numbered_bus(&i2c->adap); - } else - /* dynamic bus numbering */ - ret = i2c_bit_add_bus(&i2c->adap); + i2c->adap.nr = dev->id; + ret = i2c_bit_add_numbered_bus(&i2c->adap); if (ret >= 0) { platform_set_drvdata(dev, i2c); of_i2c_register_devices(&i2c->adap); -- 2.34.1