diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-01-27 12:14:49 -0500 |
---|---|---|
committer | Jean Delvare <khali@hyperion.delvare> | 2008-01-27 12:14:49 -0500 |
commit | 026526f5afcd421dce110f53e4c4e2b9e78753c2 (patch) | |
tree | 1dbdb54db8382dc1c1cb63b06960158f884fd823 | |
parent | 87c6c22945e5d68eb96dd1e5cb26185253cd5b9d (diff) |
i2c: Drop redundant i2c_driver.list
i2c_driver.list is superfluous, this list duplicates the one
maintained by the driver core. Drop it.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
-rw-r--r-- | drivers/i2c/i2c-core.c | 58 | ||||
-rw-r--r-- | include/linux/i2c.h | 1 |
2 files changed, 35 insertions, 24 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 3495ab4035ec..29d2a1b4b464 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include "i2c-core.h" | 39 | #include "i2c-core.h" |
40 | 40 | ||
41 | 41 | ||
42 | static LIST_HEAD(drivers); | ||
43 | static DEFINE_MUTEX(core_lists); | 42 | static DEFINE_MUTEX(core_lists); |
44 | static DEFINE_IDR(i2c_adapter_idr); | 43 | static DEFINE_IDR(i2c_adapter_idr); |
45 | 44 | ||
@@ -320,11 +319,21 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter) | |||
320 | mutex_unlock(&__i2c_board_lock); | 319 | mutex_unlock(&__i2c_board_lock); |
321 | } | 320 | } |
322 | 321 | ||
322 | static int i2c_do_add_adapter(struct device_driver *d, void *data) | ||
323 | { | ||
324 | struct i2c_driver *driver = to_i2c_driver(d); | ||
325 | struct i2c_adapter *adap = data; | ||
326 | |||
327 | if (driver->attach_adapter) { | ||
328 | /* We ignore the return code; if it fails, too bad */ | ||
329 | driver->attach_adapter(adap); | ||
330 | } | ||
331 | return 0; | ||
332 | } | ||
333 | |||
323 | static int i2c_register_adapter(struct i2c_adapter *adap) | 334 | static int i2c_register_adapter(struct i2c_adapter *adap) |
324 | { | 335 | { |
325 | int res = 0; | 336 | int res = 0, dummy; |
326 | struct list_head *item; | ||
327 | struct i2c_driver *driver; | ||
328 | 337 | ||
329 | mutex_init(&adap->bus_lock); | 338 | mutex_init(&adap->bus_lock); |
330 | mutex_init(&adap->clist_lock); | 339 | mutex_init(&adap->clist_lock); |
@@ -355,12 +364,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap) | |||
355 | i2c_scan_static_board_info(adap); | 364 | i2c_scan_static_board_info(adap); |
356 | 365 | ||
357 | /* let legacy drivers scan this bus for matching devices */ | 366 | /* let legacy drivers scan this bus for matching devices */ |
358 | list_for_each(item,&drivers) { | 367 | dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap, |
359 | driver = list_entry(item, struct i2c_driver, list); | 368 | i2c_do_add_adapter); |
360 | if (driver->attach_adapter) | ||
361 | /* We ignore the return code; if it fails, too bad */ | ||
362 | driver->attach_adapter(adap); | ||
363 | } | ||
364 | 369 | ||
365 | out_unlock: | 370 | out_unlock: |
366 | mutex_unlock(&core_lists); | 371 | mutex_unlock(&core_lists); |
@@ -460,6 +465,21 @@ retry: | |||
460 | } | 465 | } |
461 | EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); | 466 | EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); |
462 | 467 | ||
468 | static int i2c_do_del_adapter(struct device_driver *d, void *data) | ||
469 | { | ||
470 | struct i2c_driver *driver = to_i2c_driver(d); | ||
471 | struct i2c_adapter *adapter = data; | ||
472 | int res; | ||
473 | |||
474 | if (!driver->detach_adapter) | ||
475 | return 0; | ||
476 | res = driver->detach_adapter(adapter); | ||
477 | if (res) | ||
478 | dev_err(&adapter->dev, "detach_adapter failed (%d) " | ||
479 | "for driver [%s]\n", res, driver->driver.name); | ||
480 | return res; | ||
481 | } | ||
482 | |||
463 | /** | 483 | /** |
464 | * i2c_del_adapter - unregister I2C adapter | 484 | * i2c_del_adapter - unregister I2C adapter |
465 | * @adap: the adapter being unregistered | 485 | * @adap: the adapter being unregistered |
@@ -471,7 +491,6 @@ EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); | |||
471 | int i2c_del_adapter(struct i2c_adapter *adap) | 491 | int i2c_del_adapter(struct i2c_adapter *adap) |
472 | { | 492 | { |
473 | struct list_head *item, *_n; | 493 | struct list_head *item, *_n; |
474 | struct i2c_driver *driver; | ||
475 | struct i2c_client *client; | 494 | struct i2c_client *client; |
476 | int res = 0; | 495 | int res = 0; |
477 | 496 | ||
@@ -485,16 +504,11 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
485 | goto out_unlock; | 504 | goto out_unlock; |
486 | } | 505 | } |
487 | 506 | ||
488 | list_for_each(item,&drivers) { | 507 | /* Tell drivers about this removal */ |
489 | driver = list_entry(item, struct i2c_driver, list); | 508 | res = bus_for_each_drv(&i2c_bus_type, NULL, adap, |
490 | if (driver->detach_adapter) | 509 | i2c_do_del_adapter); |
491 | if ((res = driver->detach_adapter(adap))) { | 510 | if (res) |
492 | dev_err(&adap->dev, "detach_adapter failed " | 511 | goto out_unlock; |
493 | "for driver [%s]\n", | ||
494 | driver->driver.name); | ||
495 | goto out_unlock; | ||
496 | } | ||
497 | } | ||
498 | 512 | ||
499 | /* detach any active clients. This must be done first, because | 513 | /* detach any active clients. This must be done first, because |
500 | * it can fail; in which case we give up. */ | 514 | * it can fail; in which case we give up. */ |
@@ -577,7 +591,6 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
577 | 591 | ||
578 | mutex_lock(&core_lists); | 592 | mutex_lock(&core_lists); |
579 | 593 | ||
580 | list_add_tail(&driver->list,&drivers); | ||
581 | pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); | 594 | pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); |
582 | 595 | ||
583 | /* legacy drivers scan i2c busses directly */ | 596 | /* legacy drivers scan i2c busses directly */ |
@@ -647,7 +660,6 @@ void i2c_del_driver(struct i2c_driver *driver) | |||
647 | 660 | ||
648 | unregister: | 661 | unregister: |
649 | driver_unregister(&driver->driver); | 662 | driver_unregister(&driver->driver); |
650 | list_del(&driver->list); | ||
651 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); | 663 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); |
652 | 664 | ||
653 | mutex_unlock(&core_lists); | 665 | mutex_unlock(&core_lists); |
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 5fa7e180501d..0fc59efd80e4 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -140,7 +140,6 @@ struct i2c_driver { | |||
140 | int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); | 140 | int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); |
141 | 141 | ||
142 | struct device_driver driver; | 142 | struct device_driver driver; |
143 | struct list_head list; | ||
144 | }; | 143 | }; |
145 | #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) | 144 | #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) |
146 | 145 | ||