Signed-off-by: Tom Duffy <[EMAIL PROTECTED]>

Index: linux-kernel-work/dat-provider/dapl_ring_buffer_util.c
===================================================================
--- linux-kernel-work/dat-provider/dapl_ring_buffer_util.c      (revision 2704)
+++ linux-kernel-work/dat-provider/dapl_ring_buffer_util.c      (working copy)
@@ -63,9 +63,8 @@ u32 dapl_rbuf_alloc(struct dapl_ring_buf
 
        /* Put size on a power of 2 boundary */
        rsize = 1;
-       while ((int) rsize < size) {
+       while ((int) rsize < size)
                rsize <<= 1;
-       }
 
        rbuf->base = kmalloc(rsize * sizeof *rbuf->base, GFP_ATOMIC);
        if (rbuf->base) {
@@ -100,42 +99,37 @@ u32 dapl_rbuf_alloc(struct dapl_ring_buf
  */
 u32 dapl_rbuf_realloc(struct dapl_ring_buffer *rbuf, int size)
 {
-    struct dapl_ring_buffer new_rbuf;
-    void *entry;
-    u32 dat_status = DAT_SUCCESS;
-
-    /* decreasing the size or retaining the old size is not allowed */
-    if (size <= rbuf->lim + 1)
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-       goto bail;
-    }
-
-    /*
-     * !This is NOT ATOMIC!
-     * Simple algorithm: Allocate a new ring buffer, take everything
-     * out of the old one and put it in the new one, and release the 
-     * old base buffer.
-     */
-    dat_status = dapl_rbuf_alloc (&new_rbuf, size);
-    if (dat_status != DAT_SUCCESS)
-    {
-       goto bail;
-    }
-
-    while ( (entry = dapl_rbuf_remove(rbuf)) != NULL)
-    {
-       /* We know entries will fit so ignore the return code */
-       (void)dapl_rbuf_add (&new_rbuf, entry);
-    }
+       struct dapl_ring_buffer new_rbuf;
+       void *entry;
+       u32 status = DAT_SUCCESS;
+
+       /* decreasing the size or retaining the old size is not allowed */
+       if (size <= rbuf->lim + 1) {
+               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+               goto bail;
+       }
+
+       /*
+        * !This is NOT ATOMIC!
+        * Simple algorithm: Allocate a new ring buffer, take everything
+        * out of the old one and put it in the new one, and release the 
+        * old base buffer.
+        */
+       status = dapl_rbuf_alloc(&new_rbuf, size);
+       if (status != DAT_SUCCESS)
+               goto bail;
+
+       while ((entry = dapl_rbuf_remove(rbuf)) != NULL)
+               /* We know entries will fit so ignore the return code */
+               (void)dapl_rbuf_add(&new_rbuf, entry);
 
-    /* release the old base buffer */
-    kfree(rbuf->base);
+       /* release the old base buffer */
+       kfree(rbuf->base);
 
-    *rbuf = new_rbuf;
+       *rbuf = new_rbuf;
  
- bail:
-    return dat_status;
+bail:
+       return status;
 }
 
 /*
@@ -155,9 +149,8 @@ u32 dapl_rbuf_realloc(struct dapl_ring_b
  */
 void dapl_rbuf_destroy(struct dapl_ring_buffer *rbuf)
 {
-       if ((NULL == rbuf) || (NULL == rbuf->base)) {
+       if ((NULL == rbuf) || (NULL == rbuf->base))
                return;
-       }
 
        kfree(rbuf->base);
        rbuf->base = NULL;
@@ -221,22 +214,18 @@ u32 dapl_rbuf_add(struct dapl_ring_buffe
  */
 void *dapl_rbuf_remove(struct dapl_ring_buffer *rbuf)
 {
-       int pos;
-       int val;
+       int pos, val;
 
-       while (atomic_read(&rbuf->head) !=
-              atomic_read(&rbuf->tail)) {
+       while (atomic_read(&rbuf->head) != atomic_read(&rbuf->tail)) {
                pos = atomic_read(&rbuf->tail);
                val = dapl_os_atomic_assign(&rbuf->tail, pos, pos + 1);
                if (val == pos) {
                        pos = (pos + 1) & rbuf->lim;    /* verify in range */
-
                        return rbuf->base[pos];
                }
        }
 
        return NULL;
-
 }
 
 /*
@@ -261,12 +250,10 @@ int dapl_rbuf_count(struct dapl_ring_buf
 
        head = atomic_read(&rbuf->head) & rbuf->lim;
        tail = atomic_read(&rbuf->tail) & rbuf->lim;
-       if (head > tail) {
+       if (head > tail)
                count = head - tail;
-       } else {
-               /* add 1 to lim as it is a mask, number of entries - 1 */
+       else /* add 1 to lim as it is a mask, number of entries - 1 */
                count = (rbuf->lim + 1 - tail + head) & rbuf->lim;
-       }
 
        return count;
 }
@@ -292,12 +279,11 @@ int dapl_rbuf_count(struct dapl_ring_buf
  */
 void dapl_rbuf_adjust(struct dapl_ring_buffer *rbuf, unsigned long offset)
 {
-    int        pos;
+       int pos;
 
-    pos = atomic_read(&rbuf->head);
-    while ( pos != atomic_read(&rbuf->tail) )
-    {
-       rbuf->base[pos] = rbuf->base[pos] + offset;
-       pos = (pos + 1) & rbuf->lim; /* verify in range */
-    }
+       pos = atomic_read(&rbuf->head);
+       while (pos != atomic_read(&rbuf->tail)) {
+               rbuf->base[pos] = rbuf->base[pos] + offset;
+               pos = (pos + 1) & rbuf->lim; /* verify in range */
+       }
 }

_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to