vmbus: make hv_get_ringbuffer_availbytes local
authorStephen Hemminger <stephen@networkplumber.org>
Fri, 1 Dec 2017 19:01:49 +0000 (11:01 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 3 Dec 2017 15:10:02 +0000 (10:10 -0500)
The last use of hv_get_ringbuffer_availbytes in drivers is now
gone. Only used by the debug info routine so make it static. Also, add
READ_ONCE() to avoid any possible issues with potentially volatile
index values.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/hv/ring_buffer.c
include/linux/hyperv.h

index 12eb8caa426328592ae2f023f7818e812a347529..50e071444a5c5c319b8c253d4e8ee8cb87e1145f 100644 (file)
@@ -140,6 +140,29 @@ static u32 hv_copyto_ringbuffer(
        return start_write_offset;
 }
 
+/*
+ *
+ * hv_get_ringbuffer_availbytes()
+ *
+ * Get number of bytes available to read and to write to
+ * for the specified ring buffer
+ */
+static void
+hv_get_ringbuffer_availbytes(const struct hv_ring_buffer_info *rbi,
+                            u32 *read, u32 *write)
+{
+       u32 read_loc, write_loc, dsize;
+
+       /* Capture the read/write indices before they changed */
+       read_loc = READ_ONCE(rbi->ring_buffer->read_index);
+       write_loc = READ_ONCE(rbi->ring_buffer->write_index);
+       dsize = rbi->ring_datasize;
+
+       *write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
+               read_loc - write_loc;
+       *read = dsize - *write;
+}
+
 /* Get various debug metrics for the specified ring buffer. */
 void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
                                 struct hv_ring_buffer_debug_info *debug_info)
index f3e97c5f94c96bbaf4ef338f9bad6145f552b1be..5f8bd0cebddfb5263e9389dd6830e32748d68073 100644 (file)
@@ -127,28 +127,6 @@ struct hv_ring_buffer_info {
        u32 priv_read_index;
 };
 
-/*
- *
- * hv_get_ringbuffer_availbytes()
- *
- * Get number of bytes available to read and to write to
- * for the specified ring buffer
- */
-static inline void
-hv_get_ringbuffer_availbytes(const struct hv_ring_buffer_info *rbi,
-                            u32 *read, u32 *write)
-{
-       u32 read_loc, write_loc, dsize;
-
-       /* Capture the read/write indices before they changed */
-       read_loc = rbi->ring_buffer->read_index;
-       write_loc = rbi->ring_buffer->write_index;
-       dsize = rbi->ring_datasize;
-
-       *write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
-               read_loc - write_loc;
-       *read = dsize - *write;
-}
 
 static inline u32 hv_get_bytes_to_read(const struct hv_ring_buffer_info *rbi)
 {