[openib-general] [PATCH][SDP][3/22] Whitespace cleanup in sdp_buff.c

Tom Duffy Tom.Duffy at Sun.COM
Fri Feb 18 16:44:53 PST 2005


Signed-off-by: Tom Duffy <tduffy at sun.com>

Index: linux-2.6.10-openib/drivers/infiniband/ulp/sdp/sdp_buff.c
===================================================================
--- linux-2.6.10-openib/drivers/infiniband/ulp/sdp/sdp_buff.c	(revision 1836)
+++ linux-2.6.10-openib/drivers/infiniband/ulp/sdp/sdp_buff.c	(working copy)
@@ -42,41 +42,29 @@ static struct sdpc_buff_root *main_pool 
 /*
  * _sdp_buff_q_get - Get a buffer from a specific pool
  */
-static __inline__ struct sdpc_buff *_sdp_buff_q_get
-(
-	struct sdpc_buff_q *pool,
-	int fifo,
-	int (*test_func)(struct sdpc_buff *buff,
-			 void *arg),
-	void *usr_arg
-)
+static __inline__ struct sdpc_buff *_sdp_buff_q_get(struct sdpc_buff_q *pool,
+						    int fifo,
+						    int (*test_func)
+							(struct sdpc_buff *buff,
+							 void *arg),
+						    void *usr_arg)
 {
 	struct sdpc_buff *buff;
 
 	SDP_CHECK_NULL(pool, NULL);
 
-	if (NULL == pool->head) {
-
+	if (NULL == pool->head)
 		return NULL;
-	}
-
-	if (fifo) {
 
+	if (fifo)
 		buff = pool->head;
-	}
-	else {
-
+	else
 		buff = pool->head->prev;
-	}
 
 	if (NULL == test_func || 0 == test_func(buff, usr_arg)) {
-
-		if (buff->next == buff && buff->prev == buff) {
-
+		if (buff->next == buff && buff->prev == buff)
 			pool->head = NULL;
-		}
 		else {
-
 			buff->next->prev = buff->prev;
 			buff->prev->next = buff->next;
 
@@ -89,10 +77,8 @@ static __inline__ struct sdpc_buff *_sdp
 		buff->prev = NULL;
 		buff->pool = NULL;
 	}
-	else {
-
+	else
 		buff = NULL;
-	}
 
 	return buff;
 } /* _sdp_buff_q_get */
@@ -108,28 +94,22 @@ static __inline__ int _sdp_buff_q_put(st
 	SDP_CHECK_NULL(pool, -EINVAL);
 	SDP_CHECK_NULL(buff, -EINVAL);
 
-	if (NULL != buff->pool) {
-
+	if (NULL != buff->pool)
 		return -EINVAL;
-	}
 
 	if (NULL == pool->head) {
-
 		buff->next = buff;
 		buff->prev = buff;
 		pool->head = buff;
-	}
-	else {
-
+	} else {
 		buff->next = pool->head;
 		buff->prev = pool->head->prev;
 
 		buff->next->prev = buff;
 		buff->prev->next = buff;
 
-		if (fifo) {
+		if (fifo)
 			pool->head = buff;
-		}
 	}
 
 	pool->size++;
@@ -146,14 +126,10 @@ static __inline__ struct sdpc_buff *_sdp
 {
 	SDP_CHECK_NULL(pool, NULL);
 
-	if (NULL == pool->head || fifo) {
-
+	if (NULL == pool->head || fifo)
 		return pool->head;
-	}
-	else {
-
+	else
 		return pool->head->prev;
-	}
 } /* _sdp_buff_q_look */
 
 /*
@@ -171,26 +147,19 @@ static __inline__ int _sdp_buff_q_remove
 	SDP_CHECK_NULL(buff->prev, -EINVAL);
 	SDP_CHECK_NULL(buff->pool, -EINVAL);
 
-	if (pool != buff->pool) {
-
+	if (pool != buff->pool)
 		return -EINVAL;
-	}
-
-	if (buff->next == buff && buff->prev == buff) {
 
+	if (buff->next == buff && buff->prev == buff)
 		pool->head = NULL;
-	}
 	else {
-
 		next = buff->next;
 		prev = buff->prev;
 		next->prev = prev;
 		prev->next = next;
 
-		if (pool->head == buff) {
-
+		if (pool->head == buff)
 			pool->head = next;
-		}
 	}
 
 	pool->size--;
@@ -217,10 +186,8 @@ int sdp_buff_q_init(struct sdpc_buff_q *
 	pool->size = 0;
 
 	for (counter = 0; counter < size; counter++) {
-
 		result = sdp_buff_q_put(pool, sdp_buff_pool_get());
 		if (0 > result) {
-
 			result = -ENOMEM;
 			goto error;
 		}
@@ -329,28 +296,23 @@ struct sdpc_buff *sdp_buff_q_fetch(struc
 	/*
 	 * check to see if there is anything to traverse.
 	 */
-	if (NULL != pool->head) {
+	if (NULL != pool->head)
 		/*
 		 * lock to prevent corruption of table
 		 */
 		for (counter = 0, buff = pool->head;
 		     counter < pool->size; counter++, buff = buff->next) {
-
 			result = test(buff, usr_arg);
 			if (0 < result) {
-
 				result = _sdp_buff_q_remove(pool, buff);
 				SDP_EXPECT(!(0 > result));
 
 				return buff;
 			}
 
-			if (0 > result) {
-
+			if (0 > result)
 				break;
-			}
 		}
-	}
 
 	return NULL;
 } /* sdp_buff_q_fetch_head */
@@ -372,7 +334,7 @@ int sdp_buff_q_trav_head(struct sdpc_buf
 	/*
 	 * check to see if there is anything to traverse.
 	 */
-	if (NULL != pool->head) {
+	if (NULL != pool->head)
 		/*
 		 * lock to prevent corruption of table
 		 */
@@ -380,12 +342,9 @@ int sdp_buff_q_trav_head(struct sdpc_buf
 		     counter < pool->size; counter++, buff = buff->next) {
 
 			result = trav_func(buff, usr_arg);
-			if (0 > result) {
-
+			if (0 > result)
 				break;
-			}
 		}
-	}
 
 	return result;
 } /* sdp_buff_q_trav_head */
@@ -442,20 +401,14 @@ int sdp_buff_q_clear_unmap(struct sdpc_b
 	SDP_CHECK_NULL(pool, -EINVAL);
 
 	while (NULL != (buff = _sdp_buff_q_get(pool, 0, NULL, NULL))) {
-
-		if (dev) {
-			dma_unmap_single(dev, 
-					 buff->real,
-					 buff->tail - buff->data,
-					 direction);
-		}
+		if (dev)
+			dma_unmap_single(dev, buff->real,
+					 buff->tail - buff->data, direction);
 
 		result = sdp_buff_pool_put(buff);
-		if (0 > result) {
-
+		if (0 > result)
 			sdp_dbg_err("Error <%d> returning buffer to main",
 				    result);
-		}
 	}
 	
 	return 0;
@@ -477,12 +430,9 @@ static int _sdp_buff_pool_release(struct
 	 * Release count buffers.
 	 */
 	while (count--) {
-		
 		buff = sdp_buff_q_get(&m_pool->pool);
-		if (NULL == buff) {
-			
+		if (NULL == buff)
 			break;
-		}
 		/*
 		 * decrement global buffer count, free buffer page, and free
 		 * buffer descriptor.
@@ -520,10 +470,8 @@ static __inline__ int _sdp_buff_pool_rel
 
 		return _sdp_buff_pool_release(m_pool, count);
 	}
-	else {
-		
+	else
 		return 0;
-	}
 } /* _sdp_buff_pool_release_check */
 
 /*
@@ -549,7 +497,6 @@ static int _sdp_buff_pool_alloc(struct s
 		 */
 		buff = kmem_cache_alloc(m_pool->buff_cache, GFP_ATOMIC);
 		if (NULL == buff) {
-
 			sdp_warn("Failed to allocate buffer. <%d:%d>",
 				 total, m_pool->buff_cur);
 			break;
@@ -557,7 +504,6 @@ static int _sdp_buff_pool_alloc(struct s
 
 		buff->head = (void *)__get_free_page(GFP_ATOMIC);
 		if (NULL == buff->head) {
-
 			sdp_warn("Failed to allocate buffer page. <%d:%d>",
 				 total, m_pool->buff_cur);
 
@@ -577,7 +523,6 @@ static int _sdp_buff_pool_alloc(struct s
 
 		result = sdp_buff_q_put(&m_pool->pool, buff);
 		if (0 > result) {
-
 			sdp_warn("Failed to queue buffer. <%d>", result);
 			
 			free_page((unsigned long)buff->head);
@@ -589,7 +534,6 @@ static int _sdp_buff_pool_alloc(struct s
 	}
 
 	if (NULL == main_pool->pool.head) {
-
 		sdp_warn("Failed to allocate any buffers. <%d:%d:%d>",
 			 total, m_pool->buff_cur, m_pool->alloc_inc);
 
@@ -610,7 +554,6 @@ int sdp_buff_pool_init(int buff_min, 
 	int result;
 
 	if (NULL != main_pool) {
-
 		sdp_warn("Main pool already initialized!");
 		return -EEXIST;
 	}
@@ -629,7 +572,6 @@ int sdp_buff_pool_init(int buff_min, 
 	 */
 	main_pool = kmalloc(sizeof(struct sdpc_buff_root), GFP_KERNEL);
 	if (NULL == main_pool) {
-
 		sdp_warn("Main pool initialization failed.");
 		result = -ENOMEM;
 		goto done;
@@ -653,7 +595,6 @@ int sdp_buff_pool_init(int buff_min, 
 						  0, SLAB_HWCACHE_ALIGN,
 						  NULL, NULL);
 	if (NULL == main_pool->pool_cache) {
-
 		sdp_warn("Failed to allocate pool cache.");
 		result = -ENOMEM;
 		goto error_pool;
@@ -664,17 +605,15 @@ int sdp_buff_pool_init(int buff_min, 
 						  0, SLAB_HWCACHE_ALIGN,
 						  NULL, NULL);
 	if (NULL == main_pool->buff_cache) {
-
 		sdp_warn("Failed to allocate buffer cache.");
 		result = -ENOMEM;
 		goto error_buff;
-	} /* if */
+	}
 	/*
 	 * allocate the minimum number of buffers.
 	 */
 	result = _sdp_buff_pool_alloc(main_pool);
 	if (0 > result) {
-
 		sdp_warn("Error <%d> allocating buffers. <%d>",
 			 result, buff_min);
 		goto error_alloc;
@@ -703,7 +642,6 @@ done:
 void sdp_buff_pool_destroy(void)
 {
 	if (NULL == main_pool) {
-
 		sdp_warn("Main pool dosn't exist.");
 		return;
 	}
@@ -714,11 +652,9 @@ void sdp_buff_pool_destroy(void)
 	/*
 	 * Sanity check that the current number of buffers was released.
 	 */
-	if (main_pool->buff_cur) {
-		
+	if (main_pool->buff_cur)
 		sdp_warn("Leaking buffers during cleanup. <%d>", 
 			 main_pool->buff_cur);
-	}
 	/*
 	 * free pool cache
 	 */
@@ -753,10 +689,8 @@ struct sdpc_buff *sdp_buff_pool_get(void
 	spin_lock_irqsave(&main_pool->lock, flags);
 
 	if (NULL == main_pool->pool.head) {
-
 		result = _sdp_buff_pool_alloc(main_pool);
 		if (0 > result) {
-
 			sdp_warn("Error <%d> allocating buffers.", result);
 			spin_unlock_irqrestore(&main_pool->lock, flags);
 			return NULL;
@@ -765,12 +699,9 @@ struct sdpc_buff *sdp_buff_pool_get(void
 
 	buff = main_pool->pool.head;
 
-	if (buff->next == buff) {
-
+	if (buff->next == buff)
 		main_pool->pool.head = NULL;
-	}
 	else {
-
 		buff->next->prev = buff->prev;
 		buff->prev->next = buff->next;
 
@@ -806,15 +737,11 @@ int sdp_buff_pool_put(struct sdpc_buff *
 
 	SDP_CHECK_NULL(main_pool, -EINVAL);
 
-	if (NULL == buff || NULL != buff->pool) {
-
+	if (NULL == buff || NULL != buff->pool)
 		return -EINVAL;
-	}
-
-	if (NULL != buff->next || NULL != buff->prev) {
 
+	if (NULL != buff->next || NULL != buff->prev)
 		return -ETOOMANYREFS;
-	}
 	/*
 	 * reset pointers
 	 */
@@ -825,13 +752,10 @@ int sdp_buff_pool_put(struct sdpc_buff *
 	spin_lock_irqsave(&main_pool->lock, flags);
 
 	if (NULL == main_pool->pool.head) {
-
 		buff->next = buff;
 		buff->prev = buff;
 		main_pool->pool.head = buff;
-	}
-	else {
-
+	} else {
 		buff->next = main_pool->pool.head;
 		buff->prev = main_pool->pool.head->prev;
 
@@ -861,12 +785,9 @@ int sdp_buff_pool_chain_link(struct sdpc
 	buff->pool = &main_pool->pool;
 
 	if (NULL == head) {
-
 		buff->next = buff;
 		buff->prev = buff;
-	}
-	else {
-
+	} else {
 		buff->next = head;
 		buff->prev = head->prev;
 
@@ -893,19 +814,14 @@ int sdp_buff_pool_chain_put(struct sdpc_
 	 */
 	SDP_CHECK_NULL(main_pool, -EINVAL);
 
-	if (NULL == buff || !(0 < count)) {
-
+	if (NULL == buff || !(0 < count))
 		return -EINVAL;
-	}
 
 	spin_lock_irqsave(&main_pool->lock, flags);
 
-	if (NULL == main_pool->pool.head) {
-
+	if (NULL == main_pool->pool.head)
 		main_pool->pool.head = buff;
-	}
 	else {
-
 		prev = buff->prev;
 		next = main_pool->pool.head->next;
 
@@ -932,14 +848,10 @@ int sdp_buff_pool_buff_size(void)
 {
 	int result;
 
-	if (NULL == main_pool) {
-
+	if (NULL == main_pool)
 		result = -1;
-	}
-	else {
-
+	else
 		result = main_pool->buff_size;
-	}
 
 	return result;
 } /* sdp_buff_pool_buff_size */
@@ -966,7 +878,6 @@ int sdp_proc_dump_buff_pool(char *buffer
 	spin_lock_irqsave(&main_pool->lock, flags);
 
 	if (0 == start_index) {
-
 		offset += sprintf((buffer + offset), 
 				  "  buffer size:         %8d\n",
 				  main_pool->buff_size);




More information about the general mailing list