diff mbox

[1/2] dataplane: move vring_more_avail() into vring.c

Message ID 1421687077-9025-2-git-send-email-stefanha@redhat.com
State New
Headers show

Commit Message

Stefan Hajnoczi Jan. 19, 2015, 5:04 p.m. UTC
vring_more_avail() was an inline function in vring.h.  No external
callers use it so it's not necessary to export it.

Furthermore, we'll need virtio-access.h for endian-aware memory accesses
but that only works in per-target object files (obj-y) and not
build-once object files (common-obj-y) like the virtio-blk and
virtio-scsi devices.

Move vring_more_avail() into vring.c so that virtio devices like
virtio-blk and virtio-scsi can continue to use vring.h without being
built once per target.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/virtio/dataplane/vring.c         | 6 ++++++
 include/hw/virtio/dataplane/vring.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

David Gibson Jan. 20, 2015, 11:56 p.m. UTC | #1
On Mon, Jan 19, 2015 at 05:04:36PM +0000, Stefan Hajnoczi wrote:
> vring_more_avail() was an inline function in vring.h.  No external
> callers use it so it's not necessary to export it.
> 
> Furthermore, we'll need virtio-access.h for endian-aware memory accesses
> but that only works in per-target object files (obj-y) and not
> build-once object files (common-obj-y) like the virtio-blk and
> virtio-scsi devices.
> 
> Move vring_more_avail() into vring.c so that virtio devices like
> virtio-blk and virtio-scsi can continue to use vring.h without being
> built once per target.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Looks sensible to me.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Tested-by: David Gibson <david@gibson.dropbear.id.au>
Greg Kurz Jan. 21, 2015, 1:25 p.m. UTC | #2
On Mon, 19 Jan 2015 17:04:36 +0000
Stefan Hajnoczi <stefanha@redhat.com> wrote:

> vring_more_avail() was an inline function in vring.h.  No external
> callers use it so it's not necessary to export it.
> 
> Furthermore, we'll need virtio-access.h for endian-aware memory accesses
> but that only works in per-target object files (obj-y) and not
> build-once object files (common-obj-y) like the virtio-blk and
> virtio-scsi devices.
> 
> Move vring_more_avail() into vring.c so that virtio devices like
> virtio-blk and virtio-scsi can continue to use vring.h without being
> built once per target.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---

Yes, this function should definitely be declared in more appropriate scope.
And BTW I remember Cornelia had the same concern in the virtio-1 serie. :)

Reviewed-by: Greg Kurz <gkurz@linux.vnet.ibm.com>

>  hw/virtio/dataplane/vring.c         | 6 ++++++
>  include/hw/virtio/dataplane/vring.h | 6 ------
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
> index 61f6d83..cb31d7f 100644
> --- a/hw/virtio/dataplane/vring.c
> +++ b/hw/virtio/dataplane/vring.c
> @@ -21,6 +21,12 @@
>  #include "hw/virtio/dataplane/vring.h"
>  #include "qemu/error-report.h"
> 
> +/* Are there more descriptors available? */
> +static inline bool vring_more_avail(Vring *vring)
> +{
> +    return vring->vr.avail->idx != vring->last_avail_idx;
> +}
> +
>  /* vring_map can be coupled with vring_unmap or (if you still have the
>   * value returned in *mr) memory_region_unref.
>   */
> diff --git a/include/hw/virtio/dataplane/vring.h b/include/hw/virtio/dataplane/vring.h
> index d3e086a..1e871e6 100644
> --- a/include/hw/virtio/dataplane/vring.h
> +++ b/include/hw/virtio/dataplane/vring.h
> @@ -36,12 +36,6 @@ static inline unsigned int vring_get_num(Vring *vring)
>      return vring->vr.num;
>  }
> 
> -/* Are there more descriptors available? */
> -static inline bool vring_more_avail(Vring *vring)
> -{
> -    return vring->vr.avail->idx != vring->last_avail_idx;
> -}
> -
>  /* Fail future vring_pop() and vring_push() calls until reset */
>  static inline void vring_set_broken(Vring *vring)
>  {
diff mbox

Patch

diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
index 61f6d83..cb31d7f 100644
--- a/hw/virtio/dataplane/vring.c
+++ b/hw/virtio/dataplane/vring.c
@@ -21,6 +21,12 @@ 
 #include "hw/virtio/dataplane/vring.h"
 #include "qemu/error-report.h"
 
+/* Are there more descriptors available? */
+static inline bool vring_more_avail(Vring *vring)
+{
+    return vring->vr.avail->idx != vring->last_avail_idx;
+}
+
 /* vring_map can be coupled with vring_unmap or (if you still have the
  * value returned in *mr) memory_region_unref.
  */
diff --git a/include/hw/virtio/dataplane/vring.h b/include/hw/virtio/dataplane/vring.h
index d3e086a..1e871e6 100644
--- a/include/hw/virtio/dataplane/vring.h
+++ b/include/hw/virtio/dataplane/vring.h
@@ -36,12 +36,6 @@  static inline unsigned int vring_get_num(Vring *vring)
     return vring->vr.num;
 }
 
-/* Are there more descriptors available? */
-static inline bool vring_more_avail(Vring *vring)
-{
-    return vring->vr.avail->idx != vring->last_avail_idx;
-}
-
 /* Fail future vring_pop() and vring_push() calls until reset */
 static inline void vring_set_broken(Vring *vring)
 {