diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-12-06 11:06:19 -0500 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-06 11:06:19 -0500 |
commit | 6dfa5ca3c9a35cb395ab1f51e0e500106c85dff4 (patch) | |
tree | 3ea208e88338d40fd9e4d0ea51f55cafecd64ff0 /drivers/i2c/busses/i2c-powermac.c | |
parent | d7d838a6ebbab6e786148133b6cf9617144603b4 (diff) |
i2c-powermac: Include the i2c_adapter in struct pmac_i2c_bus
Include the i2c_adapter in struct pmac_i2c_bus. This avoids memory
fragmentation and allows for several code cleanups.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Michel Daenzer <michel@daenzer.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-powermac.c')
-rw-r--r-- | drivers/i2c/busses/i2c-powermac.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c index 5c22d9f0289b..b58fb7026597 100644 --- a/drivers/i2c/busses/i2c-powermac.c +++ b/drivers/i2c/busses/i2c-powermac.c | |||
@@ -204,19 +204,16 @@ static const struct i2c_algorithm i2c_powermac_algorithm = { | |||
204 | static int __devexit i2c_powermac_remove(struct platform_device *dev) | 204 | static int __devexit i2c_powermac_remove(struct platform_device *dev) |
205 | { | 205 | { |
206 | struct i2c_adapter *adapter = platform_get_drvdata(dev); | 206 | struct i2c_adapter *adapter = platform_get_drvdata(dev); |
207 | struct pmac_i2c_bus *bus = i2c_get_adapdata(adapter); | ||
208 | int rc; | 207 | int rc; |
209 | 208 | ||
210 | rc = i2c_del_adapter(adapter); | 209 | rc = i2c_del_adapter(adapter); |
211 | pmac_i2c_detach_adapter(bus, adapter); | ||
212 | i2c_set_adapdata(adapter, NULL); | ||
213 | /* We aren't that prepared to deal with this... */ | 210 | /* We aren't that prepared to deal with this... */ |
214 | if (rc) | 211 | if (rc) |
215 | printk(KERN_WARNING | 212 | printk(KERN_WARNING |
216 | "i2c-powermac.c: Failed to remove bus %s !\n", | 213 | "i2c-powermac.c: Failed to remove bus %s !\n", |
217 | adapter->name); | 214 | adapter->name); |
218 | platform_set_drvdata(dev, NULL); | 215 | platform_set_drvdata(dev, NULL); |
219 | kfree(adapter); | 216 | memset(adapter, 0, sizeof(*adapter)); |
220 | 217 | ||
221 | return 0; | 218 | return 0; |
222 | } | 219 | } |
@@ -261,23 +258,17 @@ static int __devinit i2c_powermac_probe(struct platform_device *dev) | |||
261 | snprintf(name, 32, "%s %d", basename, pmac_i2c_get_channel(bus)); | 258 | snprintf(name, 32, "%s %d", basename, pmac_i2c_get_channel(bus)); |
262 | of_node_put(parent); | 259 | of_node_put(parent); |
263 | 260 | ||
264 | adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); | 261 | adapter = pmac_i2c_get_adapter(bus); |
265 | if (adapter == NULL) { | ||
266 | printk(KERN_ERR "i2c-powermac: can't allocate inteface !\n"); | ||
267 | return -ENOMEM; | ||
268 | } | ||
269 | platform_set_drvdata(dev, adapter); | 262 | platform_set_drvdata(dev, adapter); |
270 | strcpy(adapter->name, name); | 263 | strcpy(adapter->name, name); |
271 | adapter->algo = &i2c_powermac_algorithm; | 264 | adapter->algo = &i2c_powermac_algorithm; |
272 | i2c_set_adapdata(adapter, bus); | 265 | i2c_set_adapdata(adapter, bus); |
273 | adapter->dev.parent = &dev->dev; | 266 | adapter->dev.parent = &dev->dev; |
274 | pmac_i2c_attach_adapter(bus, adapter); | ||
275 | rc = i2c_add_adapter(adapter); | 267 | rc = i2c_add_adapter(adapter); |
276 | if (rc) { | 268 | if (rc) { |
277 | printk(KERN_ERR "i2c-powermac: Adapter %s registration " | 269 | printk(KERN_ERR "i2c-powermac: Adapter %s registration " |
278 | "failed\n", name); | 270 | "failed\n", name); |
279 | i2c_set_adapdata(adapter, NULL); | 271 | memset(adapter, 0, sizeof(*adapter)); |
280 | pmac_i2c_detach_adapter(bus, adapter); | ||
281 | } | 272 | } |
282 | 273 | ||
283 | printk(KERN_INFO "PowerMac i2c bus %s registered\n", name); | 274 | printk(KERN_INFO "PowerMac i2c bus %s registered\n", name); |