Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77330
b: refs/heads/master
c: e48d331
h: refs/heads/master
v: v3
  • Loading branch information
Jean Delvare authored and Jean Delvare committed Jan 27, 2008
1 parent d1f58c6 commit 74db81d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bdc511f438f6ca40307e06edda00331e6ac0f813
refs/heads/master: e48d33193d94175f012c3ed606a1d1e574ed726a
24 changes: 20 additions & 4 deletions trunk/drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,17 +764,33 @@ int i2c_detach_client(struct i2c_client *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. The driver model does
* that automatically as part of driver binding, so that most drivers don't
* need to do this explicitly: they hold a reference until they're unbound
* from the device.
*
* 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);

Expand Down
22 changes: 4 additions & 18 deletions trunk/drivers/media/video/vino.c
Original file line number Diff line number Diff line change
Expand Up @@ -2589,11 +2589,7 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
/* 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;
Expand All @@ -2602,11 +2598,7 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
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);
Expand Down Expand Up @@ -2688,10 +2680,7 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
}

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;
}

Expand Down Expand Up @@ -2759,10 +2748,7 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
}

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;
}

Expand Down
7 changes: 2 additions & 5 deletions trunk/include/linux/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,8 @@ static inline int i2c_add_driver(struct i2c_driver *driver)
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 */
Expand Down

0 comments on commit 74db81d

Please sign in to comment.