linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nadav Amit <namit@vmware.com>
To: Arnd Bergmann <arnd@arndb.de>, <gregkh@linuxfoundation.org>
Cc: Xavier Deguillard <xdeguillard@vmware.com>,
	<linux-kernel@vger.kernel.org>, Nadav Amit <namit@vmware.com>
Subject: [PATCH v3 13/20] vmw_balloon: general style cleanup
Date: Wed, 26 Sep 2018 12:13:29 -0700	[thread overview]
Message-ID: <20180926191336.101885-14-namit@vmware.com> (raw)
In-Reply-To: <20180926191336.101885-1-namit@vmware.com>

Change all the remaining return values to int to avoid mistakes. Reduce
indentation when possible.

Reviewed-by: Xavier Deguillard <xdeguillard@vmware.com>
Signed-off-by: Nadav Amit <namit@vmware.com>
---
 drivers/misc/vmw_balloon.c | 39 ++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index cb363db34b4a..99a831ea82c0 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -477,10 +477,9 @@ vmballoon_cmd(struct vmballoon *b, unsigned long cmd, unsigned long arg1,
  * Send "start" command to the host, communicating supported version
  * of the protocol.
  */
-static bool vmballoon_send_start(struct vmballoon *b, unsigned long req_caps)
+static int vmballoon_send_start(struct vmballoon *b, unsigned long req_caps)
 {
 	unsigned long status, capabilities;
-	bool success;
 
 	status = __vmballoon_cmd(b, VMW_BALLOON_CMD_START, req_caps, 0,
 				 &capabilities);
@@ -488,14 +487,12 @@ static bool vmballoon_send_start(struct vmballoon *b, unsigned long req_caps)
 	switch (status) {
 	case VMW_BALLOON_SUCCESS_WITH_CAPABILITIES:
 		b->capabilities = capabilities;
-		success = true;
 		break;
 	case VMW_BALLOON_SUCCESS:
 		b->capabilities = VMW_BALLOON_BASIC_CMDS;
-		success = true;
 		break;
 	default:
-		success = false;
+		return -EIO;
 	}
 
 	/*
@@ -509,26 +506,29 @@ static bool vmballoon_send_start(struct vmballoon *b, unsigned long req_caps)
 		b->max_page_size = VMW_BALLOON_2M_PAGE;
 
 
-	return success;
+	return 0;
 }
 
-/*
+/**
+ * vmballoon_send_guest_id - communicate guest type to the host.
+ *
+ * @b: pointer to the balloon.
+ *
  * Communicate guest type to the host so that it can adjust ballooning
  * algorithm to the one most appropriate for the guest. This command
  * is normally issued after sending "start" command and is part of
  * standard reset sequence.
+ *
+ * Return: zero on success or appropriate error code.
  */
-static bool vmballoon_send_guest_id(struct vmballoon *b)
+static int vmballoon_send_guest_id(struct vmballoon *b)
 {
 	unsigned long status;
 
 	status = vmballoon_cmd(b, VMW_BALLOON_CMD_GUEST_ID,
 			       VMW_BALLOON_GUEST_ID, 0);
 
-	if (status == VMW_BALLOON_SUCCESS)
-		return true;
-
-	return false;
+	return status == VMW_BALLOON_SUCCESS ? 0 : -EIO;
 }
 
 /**
@@ -1215,8 +1215,15 @@ static void vmballoon_vmci_cleanup(struct vmballoon *b)
 	}
 }
 
-/*
- * Initialize vmci doorbell, to get notified as soon as balloon changes
+/**
+ * vmballoon_vmci_init - Initialize vmci doorbell.
+ *
+ * @b: pointer to the balloon.
+ *
+ * Return: zero on success or when wakeup command not supported. Error-code
+ * otherwise.
+ *
+ * Initialize vmci doorbell, to get notified as soon as balloon changes.
  */
 static int vmballoon_vmci_init(struct vmballoon *b)
 {
@@ -1278,7 +1285,7 @@ static void vmballoon_reset(struct vmballoon *b)
 	/* free all pages, skipping monitor unlock */
 	vmballoon_pop(b);
 
-	if (!vmballoon_send_start(b, VMW_BALLOON_CAPABILITIES))
+	if (vmballoon_send_start(b, VMW_BALLOON_CAPABILITIES))
 		return;
 
 	if ((b->capabilities & VMW_BALLOON_BATCHED_CMDS) != 0) {
@@ -1302,7 +1309,7 @@ static void vmballoon_reset(struct vmballoon *b)
 	if (error)
 		pr_err("failed to initialize vmci doorbell\n");
 
-	if (!vmballoon_send_guest_id(b))
+	if (vmballoon_send_guest_id(b))
 		pr_err("failed to send guest ID to the host\n");
 
 	up_write(&b->conf_sem);
-- 
2.17.1


  parent reply	other threads:[~2018-09-26 19:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 19:13 [PATCH v3 00/20] vmw_balloon: compaction, shrinker, 64-bit, etc Nadav Amit
2018-09-26 19:13 ` [PATCH v3 01/20] vmw_balloon: handle commands in a single function Nadav Amit
2018-09-26 19:13 ` [PATCH v3 02/20] vmw_balloon: unify commands tracing and stats Nadav Amit
2018-09-26 19:13 ` [PATCH v3 03/20] vmw_balloon: merge send_lock and send_unlock path Nadav Amit
2018-09-26 19:13 ` [PATCH v3 04/20] vmw_balloon: simplifying batch access Nadav Amit
2018-09-26 19:13 ` [PATCH v3 05/20] vmw_balloon: remove sleeping allocations Nadav Amit
2018-09-26 19:13 ` [PATCH v3 06/20] vmw_balloon: change batch/single lock abstractions Nadav Amit
2018-09-26 19:13 ` [PATCH v3 07/20] vmw_balloon: treat all refused pages equally Nadav Amit
2018-09-26 19:13 ` [PATCH v3 08/20] vmw_balloon: rename VMW_BALLOON_2M_SHIFT to VMW_BALLOON_2M_ORDER Nadav Amit
2018-09-26 19:13 ` [PATCH v3 09/20] vmw_balloon: refactor change size from vmballoon_work Nadav Amit
2018-09-26 19:13 ` [PATCH v3 10/20] vmw_balloon: simplify vmballoon_send_get_target() Nadav Amit
2018-09-26 19:13 ` [PATCH v3 11/20] vmw_balloon: stats rework Nadav Amit
2018-09-26 19:13 ` [PATCH v3 12/20] vmw_balloon: rework the inflate and deflate loops Nadav Amit
2018-09-26 19:13 ` Nadav Amit [this message]
2018-09-26 19:13 ` [PATCH v3 14/20] vmw_balloon: add reset stat Nadav Amit
2018-09-26 19:13 ` [PATCH v3 15/20] mm/balloon_compaction: suppress allocation warnings Nadav Amit
2018-09-26 19:13 ` [PATCH v3 16/20] mm/balloon_compaction: list interfaces Nadav Amit
2018-09-28 19:48   ` Nadav Amit
2018-10-17  2:42     ` Nadav Amit
2018-09-26 19:13 ` [PATCH v3 17/20] vmw_balloon: compaction support Nadav Amit
2018-09-26 19:13 ` [PATCH v3 18/20] vmw_balloon: support 64-bit memory limit Nadav Amit
2018-09-26 19:13 ` [PATCH v3 19/20] vmw_balloon: memory shrinker Nadav Amit
2018-09-26 19:13 ` [PATCH v3 20/20] vmw_balloon: split refused pages Nadav Amit
2018-10-30 16:32 ` [PATCH v3 00/20] vmw_balloon: compaction, shrinker, 64-bit, etc Nadav Amit
2018-10-30 16:51   ` gregkh
2018-10-30 16:52     ` Nadav Amit
2018-10-30 17:05       ` gregkh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180926191336.101885-14-namit@vmware.com \
    --to=namit@vmware.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xdeguillard@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).