hv: coding style: refine hcall_initialize_trusty to one exit
Fix procedure has more than one exit point.
@@ -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)
{
- if (vcpu->vm->sworld_control.flag.supported == 0UL) {
- dev_dbg(ACRN_DBG_TRUSTY_HYCALL,
- "Secure World is not supported!\n");
- return -EPERM;
- }
-
- 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;
- }
+ int32_t ret = 0;
+ if (vcpu->vm->sworld_control.flag.supported == 0UL) {
+ 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)) {
- return -ENODEV;
- }
-
+ ret = -ENODEV;
+ } else {
vcpu->vm->sworld_control.flag.active = 1UL;
+ }
+ }
- return 0;
+ return ret;
}
/**
