aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorDwight Engen <dwight.engen@oracle.com>2014-12-11 12:26:15 -0500
committerDavid S. Miller <davem@davemloft.net>2014-12-11 21:52:45 -0500
commitfe47c3c2623d6914655f507a317a6b881bc7c6a4 (patch)
treeb9e30d272af800b1de1f59c7ebe661bc9ac7eb67 /arch/sparc
parent31f4888f51afb038f7f8e7e4b3f0a80587c92c9b (diff)
vio: create routines for inc,dec vio dring indexes
Both sunvdc and sunvnet implemented distinct functionality for incrementing and decrementing dring indexes. Create common functions for use by both from the sunvnet versions, which were chosen since they will still work correctly in case a non power of two ring size is used. Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/include/asm/vio.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/sparc/include/asm/vio.h b/arch/sparc/include/asm/vio.h
index fb124feb363b..8174f6cdbbbb 100644
--- a/arch/sparc/include/asm/vio.h
+++ b/arch/sparc/include/asm/vio.h
@@ -300,6 +300,21 @@ static inline u32 vio_dring_avail(struct vio_dring_state *dr,
300 ((dr->prod - dr->cons) & (ring_size - 1)) - 1); 300 ((dr->prod - dr->cons) & (ring_size - 1)) - 1);
301} 301}
302 302
303static inline u32 vio_dring_next(struct vio_dring_state *dr, u32 index)
304{
305 if (++index == dr->num_entries)
306 index = 0;
307 return index;
308}
309
310static inline u32 vio_dring_prev(struct vio_dring_state *dr, u32 index)
311{
312 if (index == 0)
313 return dr->num_entries - 1;
314 else
315 return index - 1;
316}
317
303#define VIO_MAX_TYPE_LEN 32 318#define VIO_MAX_TYPE_LEN 32
304#define VIO_MAX_COMPAT_LEN 64 319#define VIO_MAX_COMPAT_LEN 64
305 320