aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-03-09 03:16:47 -0500
committerWolfram Sang <wsa@the-dreams.de>2013-04-02 01:06:17 -0400
commit71546300c8684eb69286604c79624582c16f2f5b (patch)
tree3b8c56b7c5a4cda198604e32f066614e28b419fd /drivers/i2c
parentbf51a8c5e0b6133b929eb7d7456e99a605f8168c (diff)
i2c: Make return type of i2c_del_adapter() void
i2c_del_adapter() is usually called from a drivers remove callback. The Linux device driver model does not allow the remove callback to fail and all resources allocated in the probe callback need to be freed, as well as all resources which have been provided to the rest of the kernel(for example a I2C adapter) need to be revoked. So any function revoking such resources isn't allowed to fail either. i2c_del_adapter() adheres to this requirement and will never fail. But i2c_del_adapter()'s return type is int, which may cause driver authors to think that it can fail. This led to code constructs like: ret = i2c_del_adapter(...); BUG_ON(ret); Since i2c_del_adapter() always returns 0 the BUG_ON is never hit and essentially becomes dead code, which means it can be removed. Making the return type of i2c_del_adapter() void makes it explicit that the function will never fail and should prevent constructs like the above from re-appearing in the kernel code. All callers of i2c_del_adapter() have already been updated in a previous patch to ignore the return value, so the conversion of the return type from int to void can be done without causing any build failures. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Reviewed-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-core.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index e4fe4940fd82..e9ac0d84a01e 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1219,7 +1219,7 @@ static int __process_removed_adapter(struct device_driver *d, void *data)
1219 * This unregisters an I2C adapter which was previously registered 1219 * This unregisters an I2C adapter which was previously registered
1220 * by @i2c_add_adapter or @i2c_add_numbered_adapter. 1220 * by @i2c_add_adapter or @i2c_add_numbered_adapter.
1221 */ 1221 */
1222int i2c_del_adapter(struct i2c_adapter *adap) 1222void i2c_del_adapter(struct i2c_adapter *adap)
1223{ 1223{
1224 struct i2c_adapter *found; 1224 struct i2c_adapter *found;
1225 struct i2c_client *client, *next; 1225 struct i2c_client *client, *next;
@@ -1231,7 +1231,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
1231 if (found != adap) { 1231 if (found != adap) {
1232 pr_debug("i2c-core: attempting to delete unregistered " 1232 pr_debug("i2c-core: attempting to delete unregistered "
1233 "adapter [%s]\n", adap->name); 1233 "adapter [%s]\n", adap->name);
1234 return 0; 1234 return;
1235 } 1235 }
1236 1236
1237 /* Tell drivers about this removal */ 1237 /* Tell drivers about this removal */
@@ -1283,8 +1283,6 @@ int i2c_del_adapter(struct i2c_adapter *adap)
1283 /* Clear the device structure in case this adapter is ever going to be 1283 /* Clear the device structure in case this adapter is ever going to be
1284 added again */ 1284 added again */
1285 memset(&adap->dev, 0, sizeof(adap->dev)); 1285 memset(&adap->dev, 0, sizeof(adap->dev));
1286
1287 return 0;
1288} 1286}
1289EXPORT_SYMBOL(i2c_del_adapter); 1287EXPORT_SYMBOL(i2c_del_adapter);
1290 1288