In addition to module_get()/module_put() add get_device()/put_device()
calls into i2c_get_adapter()/i2c_put_adapter() exported
interfaces. This is done to lock I2C bus device, if it is in use by a
client.
Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
 
        mutex_lock(&core_lock);
        adapter = idr_find(&i2c_adapter_idr, nr);
-       if (adapter && !try_module_get(adapter->owner))
+       if (!adapter)
+               goto exit;
+
+       if (try_module_get(adapter->owner))
+               get_device(&adapter->dev);
+       else
                adapter = NULL;
 
+ exit:
        mutex_unlock(&core_lock);
        return adapter;
 }
 
 void i2c_put_adapter(struct i2c_adapter *adap)
 {
-       if (adap)
-               module_put(adap->owner);
+       if (!adap)
+               return;
+
+       put_device(&adap->dev);
+       module_put(adap->owner);
 }
 EXPORT_SYMBOL(i2c_put_adapter);