diff options
-rw-r--r-- | drivers/i2c/i2c-core.c | 46 | ||||
-rw-r--r-- | drivers/media/video/ks0127.c | 1 | ||||
-rw-r--r-- | include/linux/i2c.h | 3 |
3 files changed, 2 insertions, 48 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); |
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 | ||
770 | static int ks0127_found_proc(struct i2c_adapter *adapter, int addr, int kind) | 769 | static int ks0127_found_proc(struct i2c_adapter *adapter, int addr, int kind) |
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 37c14b08d61a..f7cd2f370c39 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -155,7 +155,6 @@ struct i2c_driver { | |||
155 | * generic enough to hide second-sourcing and compatible revisions. | 155 | * generic enough to hide second-sourcing and compatible revisions. |
156 | * @adapter: manages the bus segment hosting this I2C device | 156 | * @adapter: manages the bus segment hosting this I2C device |
157 | * @driver: device's driver, hence pointer to access routines | 157 | * @driver: device's driver, hence pointer to access routines |
158 | * @usage_count: counts current number of users of this client | ||
159 | * @dev: Driver model device node for the slave. | 158 | * @dev: Driver model device node for the slave. |
160 | * @irq: indicates the IRQ generated by this device (if any) | 159 | * @irq: indicates the IRQ generated by this device (if any) |
161 | * @driver_name: Identifies new-style driver used with this device; also | 160 | * @driver_name: Identifies new-style driver used with this device; also |
@@ -175,8 +174,6 @@ struct i2c_client { | |||
175 | char name[I2C_NAME_SIZE]; | 174 | char name[I2C_NAME_SIZE]; |
176 | struct i2c_adapter *adapter; /* the adapter we sit on */ | 175 | struct i2c_adapter *adapter; /* the adapter we sit on */ |
177 | struct i2c_driver *driver; /* and our access routines */ | 176 | struct i2c_driver *driver; /* and our access routines */ |
178 | int usage_count; /* How many accesses currently */ | ||
179 | /* to the client */ | ||
180 | struct device dev; /* the device structure */ | 177 | struct device dev; /* the device structure */ |
181 | int irq; /* irq issued by device (or -1) */ | 178 | int irq; /* irq issued by device (or -1) */ |
182 | char driver_name[KOBJ_NAME_LEN]; | 179 | char driver_name[KOBJ_NAME_LEN]; |