[i2c] [PATCH 1/2] i2c: Use the driver model reference counting
David Brownell
david-b at pacbell.net
Wed Dec 5 20:31:41 CET 2007
On Wednesday 05 December 2007, Jean Delvare wrote:
> ...
> int i2c_use_client(struct i2c_client *client)
> {
> - int ret;
> -
> - ret = i2c_inc_use_client(client);
> - if (ret)
> - return ret;
> -
> - client->usage_count++;
> -
if (!client)
return -EINVAL;
> + get_device(&client->dev);
> return 0;
> }
> EXPORT_SYMBOL(i2c_use_client);
... or maybe just change the calling convention to return
null-or-client, matching the more widespread idiom.
> int i2c_release_client(struct i2c_client *client)
> {
> - if (!client->usage_count) {
> - pr_debug("i2c-core: %s used one too many times\n",
> - __FUNCTION__);
> - return -EPERM;
> - }
> -
> - client->usage_count--;
> - i2c_dec_use_client(client);
> -
> + put_device(&client->dev);
> return 0;
> }
> EXPORT_SYMBOL(i2c_release_client);
static inline int i2c_release_client(struct i2c_client *client)
{
put_device(&client->dev);
return 0;
}
... though it would be better to change the signature on this one
to void, since it can never fail.
More information about the i2c
mailing list