aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2008-01-27 12:14:51 -0500
committerJean Delvare <khali@hyperion.delvare>2008-01-27 12:14:51 -0500
commit86ec5ec872566dda74848e09904bb5380cab962e (patch)
treed487b08d5b333780deb6e0dbccb56f745d7bfceb
parent961f80f9c0c0f7c45d7818f9c9969dfaa9e4463d (diff)
i2c-remove-redundant-i2c_client-list.patch
This goes on top of the patch removing most i2c_adapter.clients usage, updating i2c_attach_client: - Don't call device_register() while holding clist_lock. This removes a self-deadlock when on the i2c_driver.probe() path, for drivers that need to attach new devices (e.g. dummies). - Remove a redundant address check. The driver model core does this as a consequence of guaranteeing unique names. - Move the "device registered" diagnostic so that it never lies; previously, on error paths it would falsely report success. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r--drivers/i2c/i2c-core.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index c8bbd672226b..824f12c798d6 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -709,13 +709,6 @@ int i2c_attach_client(struct i2c_client *client)
709 struct i2c_adapter *adapter = client->adapter; 709 struct i2c_adapter *adapter = client->adapter;
710 int res = 0; 710 int res = 0;
711 711
712 mutex_lock(&adapter->clist_lock);
713 if (i2c_check_addr(client->adapter, client->addr)) {
714 res = -EBUSY;
715 goto out_unlock;
716 }
717 list_add_tail(&client->list,&adapter->clients);
718
719 client->dev.parent = &client->adapter->dev; 712 client->dev.parent = &client->adapter->dev;
720 client->dev.bus = &i2c_bus_type; 713 client->dev.bus = &i2c_bus_type;
721 714
@@ -730,13 +723,17 @@ int i2c_attach_client(struct i2c_client *client)
730 723
731 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), 724 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
732 "%d-%04x", i2c_adapter_id(adapter), client->addr); 725 "%d-%04x", i2c_adapter_id(adapter), client->addr);
733 dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n",
734 client->name, client->dev.bus_id);
735 res = device_register(&client->dev); 726 res = device_register(&client->dev);
736 if (res) 727 if (res)
737 goto out_list; 728 goto out_err;
729
730 mutex_lock(&adapter->clist_lock);
731 list_add_tail(&client->list, &adapter->clients);
738 mutex_unlock(&adapter->clist_lock); 732 mutex_unlock(&adapter->clist_lock);
739 733
734 dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n",
735 client->name, client->dev.bus_id);
736
740 if (adapter->client_register) { 737 if (adapter->client_register) {
741 if (adapter->client_register(client)) { 738 if (adapter->client_register(client)) {
742 dev_dbg(&adapter->dev, "client_register " 739 dev_dbg(&adapter->dev, "client_register "
@@ -747,12 +744,9 @@ int i2c_attach_client(struct i2c_client *client)
747 744
748 return 0; 745 return 0;
749 746
750out_list: 747out_err:
751 list_del(&client->list);
752 dev_err(&adapter->dev, "Failed to attach i2c client %s at 0x%02x " 748 dev_err(&adapter->dev, "Failed to attach i2c client %s at 0x%02x "
753 "(%d)\n", client->name, client->addr, res); 749 "(%d)\n", client->name, client->addr, res);
754out_unlock:
755 mutex_unlock(&adapter->clist_lock);
756 return res; 750 return res;
757} 751}
758EXPORT_SYMBOL(i2c_attach_client); 752EXPORT_SYMBOL(i2c_attach_client);