aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/i2c/i2c-core.c24
-rw-r--r--drivers/media/video/vino.c22
-rw-r--r--include/linux/i2c.h7
3 files changed, 26 insertions, 27 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 9b9d808578b9..f75344ac4663 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -764,17 +764,33 @@ int i2c_detach_client(struct i2c_client *client)
764} 764}
765EXPORT_SYMBOL(i2c_detach_client); 765EXPORT_SYMBOL(i2c_detach_client);
766 766
767int i2c_use_client(struct i2c_client *client) 767/**
768 * i2c_use_client - increments the reference count of the i2c client structure
769 * @client: the client being referenced
770 *
771 * Each live reference to a client should be refcounted. The driver model does
772 * that automatically as part of driver binding, so that most drivers don't
773 * need to do this explicitly: they hold a reference until they're unbound
774 * from the device.
775 *
776 * A pointer to the client with the incremented reference counter is returned.
777 */
778struct i2c_client *i2c_use_client(struct i2c_client *client)
768{ 779{
769 get_device(&client->dev); 780 get_device(&client->dev);
770 return 0; 781 return client;
771} 782}
772EXPORT_SYMBOL(i2c_use_client); 783EXPORT_SYMBOL(i2c_use_client);
773 784
774int i2c_release_client(struct i2c_client *client) 785/**
786 * i2c_release_client - release a use of the i2c client structure
787 * @client: the client being no longer referenced
788 *
789 * Must be called when a user of a client is finished with it.
790 */
791void i2c_release_client(struct i2c_client *client)
775{ 792{
776 put_device(&client->dev); 793 put_device(&client->dev);
777 return 0;
778} 794}
779EXPORT_SYMBOL(i2c_release_client); 795EXPORT_SYMBOL(i2c_release_client);
780 796
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 9a03dc82c6ca..5bb75294b5aa 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -2589,11 +2589,7 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
2589 /* First try D1 and then SAA7191 */ 2589 /* First try D1 and then SAA7191 */
2590 if (vino_drvdata->camera.driver 2590 if (vino_drvdata->camera.driver
2591 && (vino_drvdata->camera.owner == VINO_NO_CHANNEL)) { 2591 && (vino_drvdata->camera.owner == VINO_NO_CHANNEL)) {
2592 if (i2c_use_client(vino_drvdata->camera.driver)) { 2592 i2c_use_client(vino_drvdata->camera.driver);
2593 ret = -ENODEV;
2594 goto out;
2595 }
2596
2597 vino_drvdata->camera.owner = vcs->channel; 2593 vino_drvdata->camera.owner = vcs->channel;
2598 vcs->input = VINO_INPUT_D1; 2594 vcs->input = VINO_INPUT_D1;
2599 vcs->data_norm = VINO_DATA_NORM_D1; 2595 vcs->data_norm = VINO_DATA_NORM_D1;
@@ -2602,11 +2598,7 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
2602 int input, data_norm; 2598 int input, data_norm;
2603 int saa7191_input; 2599 int saa7191_input;
2604 2600
2605 if (i2c_use_client(vino_drvdata->decoder.driver)) { 2601 i2c_use_client(vino_drvdata->decoder.driver);
2606 ret = -ENODEV;
2607 goto out;
2608 }
2609
2610 input = VINO_INPUT_COMPOSITE; 2602 input = VINO_INPUT_COMPOSITE;
2611 2603
2612 saa7191_input = vino_get_saa7191_input(input); 2604 saa7191_input = vino_get_saa7191_input(input);
@@ -2688,10 +2680,7 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
2688 } 2680 }
2689 2681
2690 if (vino_drvdata->decoder.owner == VINO_NO_CHANNEL) { 2682 if (vino_drvdata->decoder.owner == VINO_NO_CHANNEL) {
2691 if (i2c_use_client(vino_drvdata->decoder.driver)) { 2683 i2c_use_client(vino_drvdata->decoder.driver);
2692 ret = -ENODEV;
2693 goto out;
2694 }
2695 vino_drvdata->decoder.owner = vcs->channel; 2684 vino_drvdata->decoder.owner = vcs->channel;
2696 } 2685 }
2697 2686
@@ -2759,10 +2748,7 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
2759 } 2748 }
2760 2749
2761 if (vino_drvdata->camera.owner == VINO_NO_CHANNEL) { 2750 if (vino_drvdata->camera.owner == VINO_NO_CHANNEL) {
2762 if (i2c_use_client(vino_drvdata->camera.driver)) { 2751 i2c_use_client(vino_drvdata->camera.driver);
2763 ret = -ENODEV;
2764 goto out;
2765 }
2766 vino_drvdata->camera.owner = vcs->channel; 2752 vino_drvdata->camera.owner = vcs->channel;
2767 } 2753 }
2768 2754
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index f7cd2f370c39..78a305bed8eb 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -386,11 +386,8 @@ static inline int i2c_add_driver(struct i2c_driver *driver)
386extern int i2c_attach_client(struct i2c_client *); 386extern int i2c_attach_client(struct i2c_client *);
387extern int i2c_detach_client(struct i2c_client *); 387extern int i2c_detach_client(struct i2c_client *);
388 388
389/* Should be used to make sure that client-struct is valid and that it 389extern struct i2c_client *i2c_use_client(struct i2c_client *client);
390 is okay to access the i2c-client. 390extern void i2c_release_client(struct i2c_client *client);
391 returns -ENODEV if client has gone in the meantime */
392extern int i2c_use_client(struct i2c_client *);
393extern int i2c_release_client(struct i2c_client *);
394 391
395/* call the i2c_client->command() of all attached clients with 392/* call the i2c_client->command() of all attached clients with
396 * the given arguments */ 393 * the given arguments */