i2c_adapter.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>
---------------------------
---------------------------
-What: i2c_adapter.list
-When: July 2007
-Why: Superfluous, this list duplicates the one maintained by the driver
- core.
-Who: Jean Delvare <khali@linux-fr.org>,
- David Brownell <dbrownell@users.sourceforge.net>
-
----------------------------
-
What: ACPI procfs interface
When: July 2008
Why: ACPI sysfs conversion should be finished by January 2008.
What: ACPI procfs interface
When: July 2008
Why: ACPI sysfs conversion should be finished by January 2008.
#include <linux/mutex.h>
#include <linux/completion.h>
#include <asm/uaccess.h>
#include <linux/mutex.h>
#include <linux/completion.h>
#include <asm/uaccess.h>
+#include <asm/semaphore.h>
-static LIST_HEAD(adapters);
static LIST_HEAD(drivers);
static DEFINE_MUTEX(core_lists);
static DEFINE_IDR(i2c_adapter_idr);
static LIST_HEAD(drivers);
static DEFINE_MUTEX(core_lists);
static DEFINE_IDR(i2c_adapter_idr);
INIT_LIST_HEAD(&adap->clients);
mutex_lock(&core_lists);
INIT_LIST_HEAD(&adap->clients);
mutex_lock(&core_lists);
- list_add_tail(&adap->list, &adapters);
/* Add the adapter to the driver core.
* If the parent pointer is not set up,
/* Add the adapter to the driver core.
* If the parent pointer is not set up,
idr_remove(&i2c_adapter_idr, adap->nr);
goto out_unlock;
}
idr_remove(&i2c_adapter_idr, adap->nr);
goto out_unlock;
}
int i2c_del_adapter(struct i2c_adapter *adap)
{
struct list_head *item, *_n;
int i2c_del_adapter(struct i2c_adapter *adap)
{
struct list_head *item, *_n;
- struct i2c_adapter *adap_from_list;
struct i2c_driver *driver;
struct i2c_client *client;
int res = 0;
struct i2c_driver *driver;
struct i2c_client *client;
int res = 0;
mutex_lock(&core_lists);
/* First make sure that this adapter was ever added */
mutex_lock(&core_lists);
/* First make sure that this adapter was ever added */
- list_for_each_entry(adap_from_list, &adapters, list) {
- if (adap_from_list == adap)
- break;
- }
- if (adap_from_list != adap) {
+ if (idr_find(&i2c_adapter_idr, adap->nr) != adap) {
pr_debug("i2c-core: attempting to delete unregistered "
"adapter [%s]\n", adap->name);
res = -EINVAL;
pr_debug("i2c-core: attempting to delete unregistered "
"adapter [%s]\n", adap->name);
res = -EINVAL;
/* clean up the sysfs representation */
init_completion(&adap->dev_released);
device_unregister(&adap->dev);
/* clean up the sysfs representation */
init_completion(&adap->dev_released);
device_unregister(&adap->dev);
/* wait for sysfs to drop all references */
wait_for_completion(&adap->dev_released);
/* wait for sysfs to drop all references */
wait_for_completion(&adap->dev_released);
if (driver->attach_adapter) {
struct i2c_adapter *adapter;
if (driver->attach_adapter) {
struct i2c_adapter *adapter;
- list_for_each_entry(adapter, &adapters, list) {
+ down(&i2c_adapter_class.sem);
+ list_for_each_entry(adapter, &i2c_adapter_class.devices,
+ dev.node) {
driver->attach_adapter(adapter);
}
driver->attach_adapter(adapter);
}
+ up(&i2c_adapter_class.sem);
}
mutex_unlock(&core_lists);
}
mutex_unlock(&core_lists);
*/
void i2c_del_driver(struct i2c_driver *driver)
{
*/
void i2c_del_driver(struct i2c_driver *driver)
{
- struct list_head *item1, *item2, *_n;
+ struct list_head *item2, *_n;
struct i2c_client *client;
struct i2c_adapter *adap;
struct i2c_client *client;
struct i2c_adapter *adap;
* attached. If so, detach them to be able to kill the driver
* afterwards.
*/
* attached. If so, detach them to be able to kill the driver
* afterwards.
*/
- list_for_each(item1,&adapters) {
- adap = list_entry(item1, struct i2c_adapter, list);
+ down(&i2c_adapter_class.sem);
+ list_for_each_entry(adap, &i2c_adapter_class.devices, dev.node) {
if (driver->detach_adapter) {
if (driver->detach_adapter(adap)) {
dev_err(&adap->dev, "detach_adapter failed "
if (driver->detach_adapter) {
if (driver->detach_adapter(adap)) {
dev_err(&adap->dev, "detach_adapter failed "
+ up(&i2c_adapter_class.sem);
unregister:
driver_unregister(&driver->driver);
unregister:
driver_unregister(&driver->driver);
int nr;
struct list_head clients;
int nr;
struct list_head clients;
char name[48];
struct completion dev_released;
};
char name[48];
struct completion dev_released;
};