diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/i2c-core.c | 22 |
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 | ||
750 | out_list: | 747 | out_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); |
754 | out_unlock: | ||
755 | mutex_unlock(&adapter->clist_lock); | ||
756 | return res; | 750 | return res; |
757 | } | 751 | } |
758 | EXPORT_SYMBOL(i2c_attach_client); | 752 | EXPORT_SYMBOL(i2c_attach_client); |