xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Bhupinder Thakur <bhupinder.thakur@linaro.org>
To: xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH 4/4 v3] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1
Date: Tue, 31 Oct 2017 12:25:08 +0530	[thread overview]
Message-ID: <1509432908-17449-4-git-send-email-bhupinder.thakur@linaro.org> (raw)
In-Reply-To: <1509432908-17449-1-git-send-email-bhupinder.thakur@linaro.org>

xenconsole will use a new macro XEN_INVALID_PFN instead of -1 for initializing ring-ref.
Since the type of ring_ref is changed to xen_pfn_t (which is an unsigned value) assigning -1
appeared to be confusing. For clarity, XEN_INVALID_PFN is introduced.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

This patch is as per the review of commit fa1f157
    libxl: Fix the bug introduced in commit "libxl: use correct type

 tools/console/daemon/io.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 1839973..aa291db 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -62,6 +62,8 @@
 /* Duration of each time period in ms */
 #define RATE_LIMIT_PERIOD 200
 
+#define XEN_INVALID_PFN (~(xen_pfn_t)0)
+
 extern int log_reload;
 extern int log_guest;
 extern int log_hv;
@@ -658,12 +660,12 @@ static void console_unmap_interface(struct console *con)
 {
 	if (con->interface == NULL)
 		return;
-	if (xgt_handle && con->ring_ref == -1)
+	if (xgt_handle && con->ring_ref == XEN_INVALID_PFN)
 		xengnttab_unmap(xgt_handle, con->interface, 1);
 	else
 		munmap(con->interface, XC_PAGE_SIZE);
 	con->interface = NULL;
-	con->ring_ref = -1;
+	con->ring_ref = XEN_INVALID_PFN;
 }
  
 static int console_create_ring(struct console *con)
@@ -698,7 +700,7 @@ static int console_create_ring(struct console *con)
 	free(type);
 
 	/* If using ring_ref and it has changed, remap */
-	if (ring_ref != con->ring_ref && con->ring_ref != -1)
+	if (ring_ref != con->ring_ref && con->ring_ref != XEN_INVALID_PFN)
 		console_unmap_interface(con);
 
 	if (!con->interface && xgt_handle && con->use_gnttab) {
@@ -706,7 +708,7 @@ static int console_create_ring(struct console *con)
 		con->interface = xengnttab_map_grant_ref(xgt_handle,
 			dom->domid, GNTTAB_RESERVED_CONSOLE,
 			PROT_READ|PROT_WRITE);
-		con->ring_ref = -1;
+		con->ring_ref = XEN_INVALID_PFN;
 	}
 	if (!con->interface) {
 		/* Fall back to xc_map_foreign_range */
@@ -812,7 +814,7 @@ static int console_init(struct console *con, struct domain *dom, void **data)
 	con->master_pollfd_idx = -1;
 	con->slave_fd = -1;
 	con->log_fd = -1;
-	con->ring_ref = -1;
+	con->ring_ref = XEN_INVALID_PFN;
 	con->local_port = -1;
 	con->remote_port = -1;
 	con->xce_pollfd_idx = -1;
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-10-31  6:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31  6:55 [PATCH 1/4 v3] libxl: Fix the bug introduced in commit "libxl: use correct type modifier for vuart_gfn" Bhupinder Thakur
2017-10-31  6:55 ` [PATCH 2/4 v3] libxl: Change the type of console_mfn to xen_pfn_t Bhupinder Thakur
2017-10-31 10:05   ` Wei Liu
2017-10-31  6:55 ` [PATCH 3/4 v3] xenconsole: Change the type of ring_ref to xen_pfn_t in console_create_ring Bhupinder Thakur
2017-10-31  6:55 ` Bhupinder Thakur [this message]
2017-10-31 10:06   ` [PATCH 4/4 v3] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1 Wei Liu
2017-10-31 10:07 ` [PATCH 1/4 v3 for-4.10] libxl: Fix the bug introduced in commit "libxl: use correct type modifier for vuart_gfn" Wei Liu
2017-11-13 15:56   ` Julien Grall
2017-11-14 10:05     ` Wei Liu
2017-11-14 11:42       ` Bhupinder Thakur
2017-11-14 13:56         ` Wei Liu
2018-01-24 12:34           ` Wei Liu

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=1509432908-17449-4-git-send-email-bhupinder.thakur@linaro.org \
    --to=bhupinder.thakur@linaro.org \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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).