[ipxe-devel] [RFC PATCH 3/8] vmbus: drop vmbus_has_data

Roman Kagan rkagan at virtuozzo.com
Mon Jun 11 17:28:18 UTC 2018


The external callers of vmbus_has_data (netvsc) should be fine checking
the return code from vmbus_poll instead.

As this leaves only a single callsite for vmbus_has_data, opencode it
there and drop the function.

Signed-off-by: Roman Kagan <rkagan at virtuozzo.com>
---
 src/include/ipxe/vmbus.h     | 12 ------------
 src/drivers/net/netvsc.c     |  3 +--
 src/interface/hyperv/vmbus.c |  4 ++--
 3 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/src/include/ipxe/vmbus.h b/src/include/ipxe/vmbus.h
index dd8f35e7..69776616 100644
--- a/src/include/ipxe/vmbus.h
+++ b/src/include/ipxe/vmbus.h
@@ -576,18 +576,6 @@ static inline void * vmbus_get_drvdata ( struct vmbus_device *vmdev ) {
 		{ e0, e1, e2, e3, e4, e5 }				\
 	 } }
 
-/**
- * Check if data is present in ring buffer
- *
- * @v vmdev		VMBus device
- * @v has_data		Data is present
- */
-static inline __attribute__ (( always_inline )) int
-vmbus_has_data ( struct vmbus_device *vmdev ) {
-
-	return ( vmdev->in->prod != vmdev->in->cons );
-}
-
 /**
  * Register transfer page set
  *
diff --git a/src/drivers/net/netvsc.c b/src/drivers/net/netvsc.c
index eb880180..ae6473d2 100644
--- a/src/drivers/net/netvsc.c
+++ b/src/drivers/net/netvsc.c
@@ -450,8 +450,7 @@ static void netvsc_poll ( struct rndis_device *rndis ) {
 	struct vmbus_device *vmdev = netvsc->vmdev;
 
 	/* Poll VMBus device */
-	while ( vmbus_has_data ( vmdev ) )
-		vmbus_poll ( vmdev );
+	while ( vmbus_poll ( vmdev ) == 0 );
 }
 
 /**
diff --git a/src/interface/hyperv/vmbus.c b/src/interface/hyperv/vmbus.c
index 8a340959..4b6a9440 100644
--- a/src/interface/hyperv/vmbus.c
+++ b/src/interface/hyperv/vmbus.c
@@ -1010,8 +1010,8 @@ int vmbus_poll ( struct vmbus_device *vmdev ) {
 		return -EPIPE;
 
 	/* Return immediately if buffer is empty */
-	if ( ! vmbus_has_data ( vmdev ) )
-		return 0;
+	if ( vmdev->in->prod == vmdev->in->cons )
+		return -EAGAIN;
 	cons = le32_to_cpu ( vmdev->in->cons );
 	old_cons = cons;
 
-- 
2.17.1




More information about the ipxe-devel mailing list