aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-dev.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2006-12-10 15:21:33 -0500
committerJean Delvare <khali@arrakis.delvare>2006-12-10 15:21:33 -0500
commit07125ab2c2641e976bbaf3b89a735ad5a99e25d3 (patch)
tree21c463002783fdae90e6b54673de7582710d02a1 /drivers/i2c/i2c-dev.c
parent3bacb36db01c7541ffea21d4ff39219e8b211a5c (diff)
i2c: Refactor a kfree in i2c-dev
Refactor kfree(i2c_dev) into return_i2c_dev(). This saves some code and makes more sense, as the memory is allocated in get_free_i2c_dev(). Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/i2c-dev.c')
-rw-r--r--drivers/i2c/i2c-dev.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 909428af2b7e..ac5bd2a7ca99 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -90,6 +90,7 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev)
90 spin_lock(&i2c_dev_list_lock); 90 spin_lock(&i2c_dev_list_lock);
91 list_del(&i2c_dev->list); 91 list_del(&i2c_dev->list);
92 spin_unlock(&i2c_dev_list_lock); 92 spin_unlock(&i2c_dev_list_lock);
93 kfree(i2c_dev);
93} 94}
94 95
95static ssize_t show_adapter_name(struct device *dev, 96static ssize_t show_adapter_name(struct device *dev,
@@ -431,7 +432,6 @@ error_destroy:
431 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); 432 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
432error: 433error:
433 return_i2c_dev(i2c_dev); 434 return_i2c_dev(i2c_dev);
434 kfree(i2c_dev);
435 return res; 435 return res;
436} 436}
437 437
@@ -446,7 +446,6 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
446 device_remove_file(i2c_dev->dev, &dev_attr_name); 446 device_remove_file(i2c_dev->dev, &dev_attr_name);
447 return_i2c_dev(i2c_dev); 447 return_i2c_dev(i2c_dev);
448 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); 448 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
449 kfree(i2c_dev);
450 449
451 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); 450 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
452 return 0; 451 return 0;