public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next v2] KVM: SVM: Remove the unneeded result variable
@ 2022-08-22  1:37 cgel.zte
  2022-08-22 16:00 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-08-22  1:37 UTC (permalink / raw)
  To: seanjc
  Cc: pbonzini, tglx, mingo, bp, dave.hansen, x86, hpa, kvm,
	linux-kernel, ye xingchen

From: ye xingchen <ye.xingchen@zte.com.cn>

Return the value from sev_guest_activate(&activate, error) and
sev_issue_cmd_external_user(f.file, id, data, error) directly
instead of storing it in another redundant variable.And also change
the position of handle and asid to simplify the code.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
v1 -> v2
Suggested-by: SeanChristopherson <seanjc@google.com>

Change the position of handle and asid.
Change the explain about this patch.
Dropping the comment about asid + handle.
 arch/x86/kvm/svm/sev.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 28064060413a..4448f2e512b9 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -276,31 +276,24 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
 
 static int sev_bind_asid(struct kvm *kvm, unsigned int handle, int *error)
 {
-	struct sev_data_activate activate;
-	int asid = sev_get_asid(kvm);
-	int ret;
-
-	/* activate ASID on the given handle */
-	activate.handle = handle;
-	activate.asid   = asid;
-	ret = sev_guest_activate(&activate, error);
+	struct sev_data_activate activate = {
+		.handle = handle,
+		.asid = sev_get_asid(kvm),
+	};
 
-	return ret;
+	return sev_guest_activate(&activate, error);
 }
 
 static int __sev_issue_cmd(int fd, int id, void *data, int *error)
 {
 	struct fd f;
-	int ret;
 
 	f = fdget(fd);
 	if (!f.file)
 		return -EBADF;
 
-	ret = sev_issue_cmd_external_user(f.file, id, data, error);
-
 	fdput(f);
-	return ret;
+	return sev_issue_cmd_external_user(f.file, id, data, error);
 }
 
 static int sev_issue_cmd(struct kvm *kvm, int id, void *data, int *error)
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-22 16:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-22  1:37 [PATCH linux-next v2] KVM: SVM: Remove the unneeded result variable cgel.zte
2022-08-22 16:00 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox