static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
							uint8_t mode)
{
	struct mgmt_mode cp;
	uint32_t setting = 0;

	memset(&cp, 0, sizeof(cp));
	cp.val = mode;

	switch (opcode) {
	case MGMT_OP_SET_POWERED:
		setting = MGMT_SETTING_POWERED;
		break;
	case MGMT_OP_SET_CONNECTABLE:
		setting = MGMT_SETTING_CONNECTABLE;
		break;
	case MGMT_OP_SET_FAST_CONNECTABLE:
		setting = MGMT_SETTING_FAST_CONNECTABLE;
		break;
	case MGMT_OP_SET_DISCOVERABLE:
		setting = MGMT_SETTING_DISCOVERABLE;
		break;
	case MGMT_OP_SET_BONDABLE:
		setting = MGMT_SETTING_BONDABLE;
		break;
	}

	adapter->pending_settings |= setting;

	DBG("sending set mode command for index %u", adapter->dev_id);

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

	btd_error(adapter->dev_id, "Failed to set mode for index %u",
							adapter->dev_id);

	return false;
}
static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
							uint8_t mode)
{
	struct mgmt_mode cp;
	uint32_t setting = 0;

	memset(&cp, 0, sizeof(cp));
	cp.val = mode;

	switch (opcode) {
	case MGMT_OP_SET_POWERED:
		setting = MGMT_SETTING_POWERED;
		break;
	case MGMT_OP_SET_CONNECTABLE:
		setting = MGMT_SETTING_CONNECTABLE;
		break;
	case MGMT_OP_SET_FAST_CONNECTABLE:
		setting = MGMT_SETTING_FAST_CONNECTABLE;
		break;
	case MGMT_OP_SET_DISCOVERABLE:
		setting = MGMT_SETTING_DISCOVERABLE;
		break;
	case MGMT_OP_SET_BONDABLE:
		setting = MGMT_SETTING_BONDABLE;
		break;
	}

	adapter->pending_settings |= setting;

	DBG("sending set mode command for index %u", adapter->dev_id);

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

	btd_error(adapter->dev_id, "Failed to set mode for index %u",
							adapter->dev_id);

	return false;
}