[i2c] [PATCH 2/2] i2c: Change prototypes of refcounting functions

Jean Delvare khali at linux-fr.org
Wed Dec 5 14:30:59 CET 2007


Use more standard prototypes for i2c_use_client() and
i2c_release_client(). The former now returns a pointer to the client,
and the latter no longer returns anything. This matches what all other
subsystems do.

Signed-off-by: Jean Delvare <khali at linux-fr.org>
Cc: David Brownell <david-b at pacbell.net>
---
 drivers/i2c/i2c-core.c     |   21 +++++++++++++++++----
 drivers/media/video/vino.c |   22 ++++------------------
 include/linux/i2c.h        |    7 ++-----
 3 files changed, 23 insertions(+), 27 deletions(-)

--- linux-2.6.24-rc4.orig/drivers/media/video/vino.c	2007-12-05 12:03:01.000000000 +0100
+++ linux-2.6.24-rc4/drivers/media/video/vino.c	2007-12-05 12:03:40.000000000 +0100
@@ -2589,11 +2589,7 @@ static int vino_acquire_input(struct vin
 	/* First try D1 and then SAA7191 */
 	if (vino_drvdata->camera.driver
 	    && (vino_drvdata->camera.owner == VINO_NO_CHANNEL)) {
-		if (i2c_use_client(vino_drvdata->camera.driver)) {
-			ret = -ENODEV;
-			goto out;
-		}
-
+		i2c_use_client(vino_drvdata->camera.driver);
 		vino_drvdata->camera.owner = vcs->channel;
 		vcs->input = VINO_INPUT_D1;
 		vcs->data_norm = VINO_DATA_NORM_D1;
@@ -2602,11 +2598,7 @@ static int vino_acquire_input(struct vin
 		int input, data_norm;
 		int saa7191_input;
 
-		if (i2c_use_client(vino_drvdata->decoder.driver)) {
-			ret = -ENODEV;
-			goto out;
-		}
-
+		i2c_use_client(vino_drvdata->decoder.driver);
 		input = VINO_INPUT_COMPOSITE;
 
 		saa7191_input = vino_get_saa7191_input(input);
@@ -2688,10 +2680,7 @@ static int vino_set_input(struct vino_ch
 		}
 
 		if (vino_drvdata->decoder.owner == VINO_NO_CHANNEL) {
-			if (i2c_use_client(vino_drvdata->decoder.driver)) {
-				ret = -ENODEV;
-				goto out;
-			}
+			i2c_use_client(vino_drvdata->decoder.driver);
 			vino_drvdata->decoder.owner = vcs->channel;
 		}
 
@@ -2759,10 +2748,7 @@ static int vino_set_input(struct vino_ch
 		}
 
 		if (vino_drvdata->camera.owner == VINO_NO_CHANNEL) {
-			if (i2c_use_client(vino_drvdata->camera.driver)) {
-				ret = -ENODEV;
-				goto out;
-			}
+			i2c_use_client(vino_drvdata->camera.driver);
 			vino_drvdata->camera.owner = vcs->channel;
 		}
 
--- linux-2.6.24-rc4.orig/drivers/i2c/i2c-core.c	2007-12-05 12:03:01.000000000 +0100
+++ linux-2.6.24-rc4/drivers/i2c/i2c-core.c	2007-12-05 12:04:56.000000000 +0100
@@ -764,17 +764,30 @@ int i2c_detach_client(struct i2c_client 
 }
 EXPORT_SYMBOL(i2c_detach_client);
 
-int i2c_use_client(struct i2c_client *client)
+/**
+ * i2c_use_client - increments the reference count of the i2c client structure
+ * @client: the client being referenced
+ *
+ * Each live reference to a client should be refcounted.
+ *
+ * A pointer to the client with the incremented reference counter is returned.
+ */
+struct i2c_client *i2c_use_client(struct i2c_client *client)
 {
 	get_device(&client->dev);
-	return 0;
+	return client;
 }
 EXPORT_SYMBOL(i2c_use_client);
 
-int i2c_release_client(struct i2c_client *client)
+/**
+ * i2c_release_client - release a use of the i2c client structure
+ * @client: the client being no longer referenced
+ *
+ * Must be called when a user of a client is finished with it.
+ */
+void i2c_release_client(struct i2c_client *client)
 {
 	put_device(&client->dev);
-	return 0;
 }
 EXPORT_SYMBOL(i2c_release_client);
 
--- linux-2.6.24-rc4.orig/include/linux/i2c.h	2007-12-05 12:03:01.000000000 +0100
+++ linux-2.6.24-rc4/include/linux/i2c.h	2007-12-05 12:05:34.000000000 +0100
@@ -386,11 +386,8 @@ static inline int i2c_add_driver(struct 
 extern int i2c_attach_client(struct i2c_client *);
 extern int i2c_detach_client(struct i2c_client *);
 
-/* Should be used to make sure that client-struct is valid and that it
-   is okay to access the i2c-client.
-   returns -ENODEV if client has gone in the meantime */
-extern int i2c_use_client(struct i2c_client *);
-extern int i2c_release_client(struct i2c_client *);
+extern struct i2c_client *i2c_use_client(struct i2c_client *client);
+extern void i2c_release_client(struct i2c_client *client);
 
 /* call the i2c_client->command() of all attached clients with
  * the given arguments */


-- 
Jean Delvare



More information about the i2c mailing list