diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 7788e1730063..9b9d808578b9 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -696,8 +696,6 @@ int i2c_attach_client(struct i2c_client *client) | |||
696 | } | 696 | } |
697 | list_add_tail(&client->list,&adapter->clients); | 697 | list_add_tail(&client->list,&adapter->clients); |
698 | 698 | ||
699 | client->usage_count = 0; | ||
700 | |||
701 | client->dev.parent = &client->adapter->dev; | 699 | client->dev.parent = &client->adapter->dev; |
702 | client->dev.bus = &i2c_bus_type; | 700 | client->dev.bus = &i2c_bus_type; |
703 | 701 | ||
@@ -744,12 +742,6 @@ int i2c_detach_client(struct i2c_client *client) | |||
744 | struct i2c_adapter *adapter = client->adapter; | 742 | struct i2c_adapter *adapter = client->adapter; |
745 | int res = 0; | 743 | int res = 0; |
746 | 744 | ||
747 | if (client->usage_count > 0) { | ||
748 | dev_warn(&client->dev, "Client [%s] still busy, " | ||
749 | "can't detach\n", client->name); | ||
750 | return -EBUSY; | ||
751 | } | ||
752 | |||
753 | if (adapter->client_unregister) { | 745 | if (adapter->client_unregister) { |
754 | res = adapter->client_unregister(client); | 746 | res = adapter->client_unregister(client); |
755 | if (res) { | 747 | if (res) { |
@@ -772,50 +764,16 @@ int i2c_detach_client(struct i2c_client *client) | |||
772 | } | 764 | } |
773 | EXPORT_SYMBOL(i2c_detach_client); | 765 | EXPORT_SYMBOL(i2c_detach_client); |
774 | 766 | ||
775 | static int i2c_inc_use_client(struct i2c_client *client) | ||
776 | { | ||
777 | |||
778 | if (!try_module_get(client->driver->driver.owner)) | ||
779 | return -ENODEV; | ||
780 | if (!try_module_get(client->adapter->owner)) { | ||
781 | module_put(client->driver->driver.owner); | ||
782 | return -ENODEV; | ||
783 | } | ||
784 | |||
785 | return 0; | ||
786 | } | ||
787 | |||
788 | static void i2c_dec_use_client(struct i2c_client *client) | ||
789 | { | ||
790 | module_put(client->driver->driver.owner); | ||
791 | module_put(client->adapter->owner); | ||
792 | } | ||
793 | |||
794 | int i2c_use_client(struct i2c_client *client) | 767 | int i2c_use_client(struct i2c_client *client) |
795 | { | 768 | { |
796 | int ret; | 769 | get_device(&client->dev); |
797 | |||
798 | ret = i2c_inc_use_client(client); | ||
799 | if (ret) | ||
800 | return ret; | ||
801 | |||
802 | client->usage_count++; | ||
803 | |||
804 | return 0; | 770 | return 0; |
805 | } | 771 | } |
806 | EXPORT_SYMBOL(i2c_use_client); | 772 | EXPORT_SYMBOL(i2c_use_client); |
807 | 773 | ||
808 | int i2c_release_client(struct i2c_client *client) | 774 | int i2c_release_client(struct i2c_client *client) |
809 | { | 775 | { |
810 | if (!client->usage_count) { | 776 | put_device(&client->dev); |
811 | pr_debug("i2c-core: %s used one too many times\n", | ||
812 | __FUNCTION__); | ||
813 | return -EPERM; | ||
814 | } | ||
815 | |||
816 | client->usage_count--; | ||
817 | i2c_dec_use_client(client); | ||
818 | |||
819 | return 0; | 777 | return 0; |
820 | } | 778 | } |
821 | EXPORT_SYMBOL(i2c_release_client); | 779 | EXPORT_SYMBOL(i2c_release_client); |