aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/i2c-core.c46
-rw-r--r--drivers/media/video/ks0127.c1
2 files changed, 2 insertions, 45 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}
773EXPORT_SYMBOL(i2c_detach_client); 765EXPORT_SYMBOL(i2c_detach_client);
774 766
775static 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
788static 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
794int i2c_use_client(struct i2c_client *client) 767int 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}
806EXPORT_SYMBOL(i2c_use_client); 772EXPORT_SYMBOL(i2c_use_client);
807 773
808int i2c_release_client(struct i2c_client *client) 774int 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}
821EXPORT_SYMBOL(i2c_release_client); 779EXPORT_SYMBOL(i2c_release_client);
diff --git a/drivers/media/video/ks0127.c b/drivers/media/video/ks0127.c
index b6cd21e6dab9..4895540be195 100644
--- a/drivers/media/video/ks0127.c
+++ b/drivers/media/video/ks0127.c
@@ -764,7 +764,6 @@ static struct i2c_client ks0127_client_tmpl =
764 .addr = 0, 764 .addr = 0,
765 .adapter = NULL, 765 .adapter = NULL,
766 .driver = &i2c_driver_ks0127, 766 .driver = &i2c_driver_ks0127,
767 .usage_count = 0
768}; 767};
769 768
770static int ks0127_found_proc(struct i2c_adapter *adapter, int addr, int kind) 769static int ks0127_found_proc(struct i2c_adapter *adapter, int addr, int kind)