hv: coding style: refine hcall_initialize_trusty to one exit

Fix procedure has more than one exit point.

Tracked-On: #2120
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
Li, Fei1 2018-12-19 23:37:32 +08:00 committed by Eddie Dong
parent 1d1d24345f
commit 8a55f03823
1 changed files with 17 additions and 23 deletions

View File

@ -66,32 +66,26 @@ int32_t hcall_world_switch(struct acrn_vcpu *vcpu)
*/
int32_t hcall_initialize_trusty(struct acrn_vcpu *vcpu, uint64_t param)
{
int32_t ret = 0;
if (vcpu->vm->sworld_control.flag.supported == 0UL) {
dev_dbg(ACRN_DBG_TRUSTY_HYCALL,
"Secure World is not supported!\n");
return -EPERM;
pr_err("Secure World is not supported!\n");
ret = -EPERM;
} else if (vcpu->vm->sworld_control.flag.active != 0UL) {
pr_err("Trusty already initialized!\n");
ret = -EPERM;
} else if (vcpu->arch.cur_context != NORMAL_WORLD) {
pr_err("%s, must initialize Trusty from Normal World!\n", __func__);
ret = -EPERM;
} else {
if (!initialize_trusty(vcpu, param)) {
ret = -ENODEV;
} else {
vcpu->vm->sworld_control.flag.active = 1UL;
}
}
if (vcpu->vm->sworld_control.flag.active != 0UL) {
dev_dbg(ACRN_DBG_TRUSTY_HYCALL,
"Trusty already initialized!\n");
return -EPERM;
}
if (vcpu->arch.cur_context != NORMAL_WORLD) {
dev_dbg(ACRN_DBG_TRUSTY_HYCALL,
"%s, must initialize Trusty from Normal World!\n",
__func__);
return -EPERM;
}
if (!initialize_trusty(vcpu, param)) {
return -ENODEV;
}
vcpu->vm->sworld_control.flag.active = 1UL;
return 0;
return ret;
}
/**