/* When this returns zero, the specified adapter became available for clients using the bus number provided in adap->nr. Also, the table of I2C devices pre-declared using i2c_register_board_info() is scanned, and the appropriate driver model device nodes are created. Otherwise, a negative errno value is returned.  */
int i2c_add_numbered_adapter(struct i2c_adapter *adap)
/* When this returns zero, the specified adapter became available for clients using the bus number provided in adap->nr. Also, the table of I2C devices pre-declared using i2c_register_board_info() is scanned, and the appropriate driver model device nodes are created. Otherwise, a negative errno value is returned.  */
int i2c_add_numbered_adapter(struct i2c_adapter *adap)
{
	int	id;
	int	status;
	if (adap->nr & ~MAX_ID_MASK)
		return -EINVAL;
retry:
	if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0)
		return -ENOMEM;
	mutex_lock(&core_lock);
	status = idr_get_new_above(&i2c_adapter_idr, adap, adap->nr, &id);
	if (status == 0 && id != adap->nr) {
		status = -EBUSY;
		idr_remove(&i2c_adapter_idr, id);
	}
	mutex_unlock(&core_lock);
	if (status == -EAGAIN)
		goto retry;
	if (status == 0)
		status = i2c_register_adapter(adap);
	return status;
}