Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cde7859b authored by Jean Delvare's avatar Jean Delvare Committed by Greg Kroah-Hartman
Browse files

[PATCH] i2c: Rework client usage count, 2 of 3



Make I2C_CLIENT_ALLOW_USE the default for all i2c clients. It doesn't
hurt if the usage count is actually never used for any given driver,
and allows for nice code simplifications in i2c-core.

Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent cb748fb2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -133,7 +133,6 @@ static struct i2c_driver max7310_i2c_driver = {

static struct i2c_client max7310_template = {
	name:   "akita-max7310",
	flags:  I2C_CLIENT_ALLOW_USE,
	driver: &max7310_i2c_driver,
};

+0 −1
Original line number Diff line number Diff line
@@ -155,7 +155,6 @@ static int rtc8564_attach(struct i2c_adapter *adap, int addr, int kind)

	strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE);
	i2c_set_clientdata(new_client, d);
	new_client->flags = I2C_CLIENT_ALLOW_USE;
	new_client->addr = addr;
	new_client->adapter = adap;
	new_client->driver = &rtc8564_driver;
+10 −18
Original line number Diff line number Diff line
@@ -419,7 +419,6 @@ int i2c_attach_client(struct i2c_client *client)
		}
	}

	if (client->flags & I2C_CLIENT_ALLOW_USE)
	client->usage_count = 0;

	client->dev.parent = &client->adapter->dev;
@@ -443,8 +442,7 @@ int i2c_detach_client(struct i2c_client *client)
	struct i2c_adapter *adapter = client->adapter;
	int res = 0;
	
	if ((client->flags & I2C_CLIENT_ALLOW_USE)
	 && (client->usage_count > 0)) {
	if (client->usage_count > 0) {
		dev_warn(&client->dev, "Client [%s] still busy, "
			 "can't detach\n", client->name);
		return -EBUSY;
@@ -499,12 +497,9 @@ int i2c_use_client(struct i2c_client *client)
	if (ret)
		return ret;

	if (client->flags & I2C_CLIENT_ALLOW_USE) {
	if (client->usage_count > 0)
		goto busy;
		else 
	client->usage_count++;
	}

	return 0;
 busy:
@@ -514,16 +509,13 @@ int i2c_use_client(struct i2c_client *client)

int i2c_release_client(struct i2c_client *client)
{
	if(client->flags & I2C_CLIENT_ALLOW_USE) {
		if(client->usage_count>0)
			client->usage_count--;
		else {
	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);
	
	return 0;
+0 −1
Original line number Diff line number Diff line
@@ -420,7 +420,6 @@ adv7170_detect_client (struct i2c_adapter *adapter,
	client->addr = address;
	client->adapter = adapter;
	client->driver = &i2c_driver_adv7170;
	client->flags = I2C_CLIENT_ALLOW_USE;
	if ((client->addr == I2C_ADV7170 >> 1) ||
	    (client->addr == (I2C_ADV7170 >> 1) + 1)) {
		dname = adv7170_name;
+0 −1
Original line number Diff line number Diff line
@@ -470,7 +470,6 @@ adv7175_detect_client (struct i2c_adapter *adapter,
	client->addr = address;
	client->adapter = adapter;
	client->driver = &i2c_driver_adv7175;
	client->flags = I2C_CLIENT_ALLOW_USE;
	if ((client->addr == I2C_ADV7175 >> 1) ||
	    (client->addr == (I2C_ADV7175 >> 1) + 1)) {
		dname = adv7175_name;
Loading