Skip to content
  • Lars-Peter Clausen's avatar
    i2c: Make return type of i2c_del_adapter() void · 71546300
    Lars-Peter Clausen authored
    
    
    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: default avatarLars-Peter Clausen <lars@metafoo.de>
    Reviewed-by: default avatarJean Delvare <khali@linux-fr.org>
    Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
    71546300