diff options
-rw-r--r-- | drivers/i2c/i2c-core.c | 28 | ||||
-rw-r--r-- | include/linux/i2c.h | 4 |
2 files changed, 11 insertions, 21 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 95fb997b41e0..b1fd00d9a5c7 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -276,10 +276,6 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) | |||
276 | if (status) | 276 | if (status) |
277 | goto out_err; | 277 | goto out_err; |
278 | 278 | ||
279 | mutex_lock(&adap->clist_lock); | ||
280 | list_add_tail(&client->list, &adap->clients); | ||
281 | mutex_unlock(&adap->clist_lock); | ||
282 | |||
283 | dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n", | 279 | dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n", |
284 | client->name, dev_name(&client->dev)); | 280 | client->name, dev_name(&client->dev)); |
285 | 281 | ||
@@ -301,12 +297,6 @@ EXPORT_SYMBOL_GPL(i2c_new_device); | |||
301 | */ | 297 | */ |
302 | void i2c_unregister_device(struct i2c_client *client) | 298 | void i2c_unregister_device(struct i2c_client *client) |
303 | { | 299 | { |
304 | struct i2c_adapter *adapter = client->adapter; | ||
305 | |||
306 | mutex_lock(&adapter->clist_lock); | ||
307 | list_del(&client->list); | ||
308 | mutex_unlock(&adapter->clist_lock); | ||
309 | |||
310 | device_unregister(&client->dev); | 300 | device_unregister(&client->dev); |
311 | } | 301 | } |
312 | EXPORT_SYMBOL_GPL(i2c_unregister_device); | 302 | EXPORT_SYMBOL_GPL(i2c_unregister_device); |
@@ -432,8 +422,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap) | |||
432 | return -EAGAIN; | 422 | return -EAGAIN; |
433 | 423 | ||
434 | mutex_init(&adap->bus_lock); | 424 | mutex_init(&adap->bus_lock); |
435 | mutex_init(&adap->clist_lock); | ||
436 | INIT_LIST_HEAD(&adap->clients); | ||
437 | 425 | ||
438 | mutex_lock(&core_lock); | 426 | mutex_lock(&core_lock); |
439 | 427 | ||
@@ -583,6 +571,14 @@ static int i2c_do_del_adapter(struct device_driver *d, void *data) | |||
583 | return res; | 571 | return res; |
584 | } | 572 | } |
585 | 573 | ||
574 | static int __unregister_client(struct device *dev, void *dummy) | ||
575 | { | ||
576 | struct i2c_client *client = i2c_verify_client(dev); | ||
577 | if (client) | ||
578 | i2c_unregister_device(client); | ||
579 | return 0; | ||
580 | } | ||
581 | |||
586 | /** | 582 | /** |
587 | * i2c_del_adapter - unregister I2C adapter | 583 | * i2c_del_adapter - unregister I2C adapter |
588 | * @adap: the adapter being unregistered | 584 | * @adap: the adapter being unregistered |
@@ -593,7 +589,6 @@ static int i2c_do_del_adapter(struct device_driver *d, void *data) | |||
593 | */ | 589 | */ |
594 | int i2c_del_adapter(struct i2c_adapter *adap) | 590 | int i2c_del_adapter(struct i2c_adapter *adap) |
595 | { | 591 | { |
596 | struct i2c_client *client, *_n; | ||
597 | int res = 0; | 592 | int res = 0; |
598 | 593 | ||
599 | mutex_lock(&core_lock); | 594 | mutex_lock(&core_lock); |
@@ -612,10 +607,9 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
612 | if (res) | 607 | if (res) |
613 | goto out_unlock; | 608 | goto out_unlock; |
614 | 609 | ||
615 | /* Detach any active clients */ | 610 | /* Detach any active clients. This can't fail, thus we do not |
616 | list_for_each_entry_safe_reverse(client, _n, &adap->clients, list) { | 611 | checking the returned value. */ |
617 | i2c_unregister_device(client); | 612 | res = device_for_each_child(&adap->dev, NULL, __unregister_client); |
618 | } | ||
619 | 613 | ||
620 | /* clean up the sysfs representation */ | 614 | /* clean up the sysfs representation */ |
621 | init_completion(&adap->dev_released); | 615 | init_completion(&adap->dev_released); |
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 28b27282496f..5f8157610c64 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -178,7 +178,6 @@ struct i2c_driver { | |||
178 | * @driver: device's driver, hence pointer to access routines | 178 | * @driver: device's driver, hence pointer to access routines |
179 | * @dev: Driver model device node for the slave. | 179 | * @dev: Driver model device node for the slave. |
180 | * @irq: indicates the IRQ generated by this device (if any) | 180 | * @irq: indicates the IRQ generated by this device (if any) |
181 | * @list: list of active/busy clients (DEPRECATED) | ||
182 | * @detected: member of an i2c_driver.clients list | 181 | * @detected: member of an i2c_driver.clients list |
183 | * | 182 | * |
184 | * An i2c_client identifies a single device (i.e. chip) connected to an | 183 | * An i2c_client identifies a single device (i.e. chip) connected to an |
@@ -195,7 +194,6 @@ struct i2c_client { | |||
195 | struct i2c_driver *driver; /* and our access routines */ | 194 | struct i2c_driver *driver; /* and our access routines */ |
196 | struct device dev; /* the device structure */ | 195 | struct device dev; /* the device structure */ |
197 | int irq; /* irq issued by device */ | 196 | int irq; /* irq issued by device */ |
198 | struct list_head list; /* DEPRECATED */ | ||
199 | struct list_head detected; | 197 | struct list_head detected; |
200 | }; | 198 | }; |
201 | #define to_i2c_client(d) container_of(d, struct i2c_client, dev) | 199 | #define to_i2c_client(d) container_of(d, struct i2c_client, dev) |
@@ -339,14 +337,12 @@ struct i2c_adapter { | |||
339 | /* data fields that are valid for all devices */ | 337 | /* data fields that are valid for all devices */ |
340 | u8 level; /* nesting level for lockdep */ | 338 | u8 level; /* nesting level for lockdep */ |
341 | struct mutex bus_lock; | 339 | struct mutex bus_lock; |
342 | struct mutex clist_lock; | ||
343 | 340 | ||
344 | int timeout; /* in jiffies */ | 341 | int timeout; /* in jiffies */ |
345 | int retries; | 342 | int retries; |
346 | struct device dev; /* the adapter device */ | 343 | struct device dev; /* the adapter device */ |
347 | 344 | ||
348 | int nr; | 345 | int nr; |
349 | struct list_head clients; /* DEPRECATED */ | ||
350 | char name[48]; | 346 | char name[48]; |
351 | struct completion dev_released; | 347 | struct completion dev_released; |
352 | }; | 348 | }; |