int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
{
	struct mgmt_cp_set_io_capability cp;

	if (!btd_opts.pairable) {
		if (io_cap == IO_CAPABILITY_INVALID) {
			if (adapter->current_settings & MGMT_SETTING_BONDABLE)
				set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x00);

			return 0;
		}

		if (!(adapter->current_settings & MGMT_SETTING_BONDABLE))
			set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01);
	} else if (io_cap == IO_CAPABILITY_INVALID)
		io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;

	memset(&cp, 0, sizeof(cp));
	cp.io_capability = io_cap;

	if (mgmt_send(adapter->mgmt, MGMT_OP_SET_IO_CAPABILITY,
				adapter->dev_id, sizeof(cp), &cp,
				NULL, NULL, NULL) > 0)
		return 0;

	return -EIO;
}
int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
{
	struct mgmt_cp_set_io_capability cp;

	if (!btd_opts.pairable) {
		if (io_cap == IO_CAPABILITY_INVALID) {
			if (adapter->current_settings & MGMT_SETTING_BONDABLE)
				set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x00);

			return 0;
		}

		if (!(adapter->current_settings & MGMT_SETTING_BONDABLE))
			set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01);
	} else if (io_cap == IO_CAPABILITY_INVALID)
		io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;

	memset(&cp, 0, sizeof(cp));
	cp.io_capability = io_cap;

	if (mgmt_send(adapter->mgmt, MGMT_OP_SET_IO_CAPABILITY,
				adapter->dev_id, sizeof(cp), &cp,
				NULL, NULL, NULL) > 0)
		return 0;

	return -EIO;
}