/* When this returns zero, a new bus number was allocated and stored in adap->nr, and the specified adapter became available for clients. Otherwise, a negative errno value is returned.  */
int i2c_add_adapter(struct i2c_adapter *adapter)
/* When this returns zero, a new bus number was allocated and stored in adap->nr, and the specified adapter became available for clients. Otherwise, a negative errno value is returned.  */
int i2c_add_adapter(struct i2c_adapter *adapter)
{
	int	id, res = 0;
retry:
	if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0)
		return -ENOMEM;
	mutex_lock(&core_lock);
	res = idr_get_new_above(&i2c_adapter_idr, adapter,
				__i2c_first_dynamic_bus_num, &id);
	mutex_unlock(&core_lock);
	if (res < 0) {
		if (res == -EAGAIN)
			goto retry;
		return res;
	}
	adapter->nr = id;
	return i2c_register_adapter(adapter);
}