diff options
author | Karol Lewandowski <k.lewandowsk@samsung.com> | 2012-03-27 05:10:28 -0400 |
---|---|---|
committer | Wolfram Sang <w.sang@pengutronix.de> | 2012-05-12 08:28:11 -0400 |
commit | 44454baa7ca7bb57c47a5564ed2528ba211fe8db (patch) | |
tree | 590ed2e391c6fdaac6b4add9c36f502371796ede | |
parent | bc414b7b9bbccbdeac80757c03a966578d04a9a2 (diff) |
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 <k.lewandowsk@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
-rw-r--r-- | drivers/i2c/busses/i2c-gpio.c | 7 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-pca-platform.c | 2 | ||||
-rw-r--r-- | 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) | |||
190 | adap->dev.parent = &pdev->dev; | 190 | adap->dev.parent = &pdev->dev; |
191 | adap->dev.of_node = pdev->dev.of_node; | 191 | adap->dev.of_node = pdev->dev.of_node; |
192 | 192 | ||
193 | /* | 193 | adap->nr = pdev->id; |
194 | * If "dev->id" is negative we consider it as zero. | ||
195 | * The reason to do so is to avoid sysfs names that only make | ||
196 | * sense when there are multiple adapters. | ||
197 | */ | ||
198 | adap->nr = (pdev->id != -1) ? pdev->id : 0; | ||
199 | ret = i2c_bit_add_numbered_bus(adap); | 194 | ret = i2c_bit_add_numbered_bus(adap); |
200 | if (ret) | 195 | if (ret) |
201 | goto err_add_bus; | 196 | 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) | |||
171 | i2c->io_size = resource_size(res); | 171 | i2c->io_size = resource_size(res); |
172 | i2c->irq = irq; | 172 | i2c->irq = irq; |
173 | 173 | ||
174 | i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0; | 174 | i2c->adap.nr = pdev->id; |
175 | i2c->adap.owner = THIS_MODULE; | 175 | i2c->adap.owner = THIS_MODULE; |
176 | snprintf(i2c->adap.name, sizeof(i2c->adap.name), | 176 | snprintf(i2c->adap.name, sizeof(i2c->adap.name), |
177 | "PCA9564/PCA9665 at 0x%08lx", | 177 | "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) | |||
104 | i2c->algo = i2c_versatile_algo; | 104 | i2c->algo = i2c_versatile_algo; |
105 | i2c->algo.data = i2c; | 105 | i2c->algo.data = i2c; |
106 | 106 | ||
107 | if (dev->id >= 0) { | 107 | i2c->adap.nr = dev->id; |
108 | /* static bus numbering */ | 108 | ret = i2c_bit_add_numbered_bus(&i2c->adap); |
109 | i2c->adap.nr = dev->id; | ||
110 | ret = i2c_bit_add_numbered_bus(&i2c->adap); | ||
111 | } else | ||
112 | /* dynamic bus numbering */ | ||
113 | ret = i2c_bit_add_bus(&i2c->adap); | ||
114 | if (ret >= 0) { | 109 | if (ret >= 0) { |
115 | platform_set_drvdata(dev, i2c); | 110 | platform_set_drvdata(dev, i2c); |
116 | of_i2c_register_devices(&i2c->adap); | 111 | of_i2c_register_devices(&i2c->adap); |