[openib-general] [PATCH][SDP][8/22] Whitespace cleanup in sdp_iocb.c
Tom Duffy
Tom.Duffy at Sun.COM
Fri Feb 18 16:45:44 PST 2005
Signed-off-by: Tom Duffy <tduffy at sun.com>
Index: linux-2.6.10-openib/drivers/infiniband/ulp/sdp/sdp_iocb.c
===================================================================
--- linux-2.6.10-openib/drivers/infiniband/ulp/sdp/sdp_iocb.c (revision 1836)
+++ linux-2.6.10-openib/drivers/infiniband/ulp/sdp/sdp_iocb.c (working copy)
@@ -52,14 +52,11 @@ static int _sdp_iocb_unlock(struct sdpc_
struct vm_area_struct *vma;
vma = find_vma(iocb->mm, (iocb->addr & PAGE_MASK));
- if (NULL == vma) {
-
+ if (NULL == vma)
sdp_warn("No VMA for IOCB <%lx:%Zu> unlock",
iocb->addr, iocb->size);
- }
while (vma) {
-
sdp_dbg_data(NULL,
"unmark <%lx> <%p> <%08lx:%08lx> <%08lx> <%ld>",
iocb->addr, vma, vma->vm_start, vma->vm_end,
@@ -88,14 +85,10 @@ static int _sdp_iocb_unlock(struct sdpc_
/*
* continue if the buffer continues onto the next vma
*/
- if ((iocb->addr + iocb->size) > vma->vm_end) {
-
+ if ((iocb->addr + iocb->size) > vma->vm_end)
vma = vma->vm_next;
- }
- else {
-
+ else
vma = NULL;
- }
}
return 0;
@@ -112,10 +105,8 @@ int sdp_iocb_unlock(struct sdpc_iocb *io
/*
* check if IOCB is locked.
*/
- if (0 == (SDP_IOCB_F_LOCKED & iocb->flags)) {
-
+ if (0 == (SDP_IOCB_F_LOCKED & iocb->flags))
return 0;
- } /* if */
/*
* spin lock since this could be from interrupt context.
*/
@@ -155,29 +146,21 @@ static int _sdp_iocb_page_save(struct sd
pte_t *ptep;
pte_t pte;
- if (!(0 < iocb->page_count) ||
- !(0 < iocb->size) ||
- 0 == iocb->addr) {
-
+ if (!(0 < iocb->page_count) || !(0 < iocb->size) || 0 == iocb->addr)
return -EINVAL;
- }
/*
* create array to hold page value which are later needed to register
* the buffer with the HCA
*/
iocb->addr_array = kmalloc((sizeof(u64) * iocb->page_count),
GFP_KERNEL);
- if (NULL == iocb->addr_array) {
-
+ if (NULL == iocb->addr_array)
goto err_addr;
- }
iocb->page_array = kmalloc((sizeof(struct page *) * iocb->page_count),
GFP_KERNEL);
- if (NULL == iocb->page_array) {
-
+ if (NULL == iocb->page_array)
goto err_page;
- }
/*
* iocb->addr - buffer start address
* iocb->size - buffer length
@@ -197,33 +180,27 @@ static int _sdp_iocb_page_save(struct sd
for (counter = 0;
0 < size;
counter++, addr += PAGE_SIZE, size -= PAGE_SIZE) {
-
pgd = pgd_offset_gate(iocb->mm, addr);
- if (!pgd || pgd_none(*pgd)) {
+ if (!pgd || pgd_none(*pgd))
break;
- }
pmd = pmd_offset(pgd, addr);
- if (!pmd || pmd_none(*pmd)) {
+ if (!pmd || pmd_none(*pmd))
break;
- }
ptep = pte_offset_map(pmd, addr);
- if (!ptep) {
+ if (!ptep)
break;
- }
pte = *ptep;
pte_unmap(ptep);
- if (!pte_present(pte)) {
+ if (!pte_present(pte))
break;
- }
pfn = pte_pfn(pte);
- if (!pfn_valid(pfn)) {
+ if (!pfn_valid(pfn))
break;
- }
page = pfn_to_page(pfn);
@@ -234,7 +211,6 @@ static int _sdp_iocb_page_save(struct sd
spin_unlock(&iocb->mm->page_table_lock);
if (size > 0) {
-
result = -EFAULT;
goto err_find;
}
@@ -290,15 +266,12 @@ int sdp_iocb_lock(struct sdpc_iocb *iocb
*/
down_write(&iocb->mm->mmap_sem);
- if (!((iocb->page_count + current->mm->locked_vm) > limit)) {
-
+ if (!((iocb->page_count + current->mm->locked_vm) > limit))
result = (*_mlock_ptr)(addr, size, 1);
- }
/*
* process result
*/
if (result) {
-
sdp_dbg_err("VMA lock <%lx:%Zu> error <%d> <%d:%lu:%lu>",
iocb->addr, iocb->size, result,
iocb->page_count, iocb->mm->locked_vm, limit);
@@ -309,28 +282,22 @@ int sdp_iocb_lock(struct sdpc_iocb *iocb
* them do not copy, reference counting, and saving them.
*/
vma = find_vma(iocb->mm, addr);
- if (NULL == vma) {
+ if (NULL == vma)
/*
* sanity check.
*/
sdp_warn("No VMA for IOCB! <%lx:%Zu> lock",
iocb->addr, iocb->size);
- }
while (vma) {
-
spin_lock(&iocb->mm->page_table_lock);
- if (0 == (VM_LOCKED & vma->vm_flags)) {
-
+ if (0 == (VM_LOCKED & vma->vm_flags))
sdp_warn("Unlocked vma! <%08lx>", vma->vm_flags);
- }
-
- if (PAGE_SIZE < (unsigned long)vma->vm_private_data) {
+ if (PAGE_SIZE < (unsigned long)vma->vm_private_data)
sdp_dbg_err("VMA: private daya in use! <%08lx>",
(unsigned long)vma->vm_private_data);
- }
vma->vm_flags |= VM_DONTCOPY;
vma->vm_private_data++;
@@ -342,19 +309,14 @@ int sdp_iocb_lock(struct sdpc_iocb *iocb
iocb->addr, vma, vma->vm_start, vma->vm_end,
vma->vm_flags, (long)vma->vm_private_data);
- if ((addr + size) > vma->vm_end) {
-
+ if ((addr + size) > vma->vm_end)
vma = vma->vm_next;
- }
- else {
-
+ else
vma = NULL;
- }
}
result = _sdp_iocb_page_save(iocb);
if (result) {
-
sdp_dbg_err("Error <%d> saving pages for IOCB <%lx:%Zu>",
result, iocb->addr, iocb->size);
goto err_save;
@@ -408,36 +370,26 @@ static int _sdp_mem_lock_init(void)
kallsyms = filp_open("/proc/kallsyms", O_RDONLY, 0);
if (NULL == kallsyms) {
-
sdp_warn("Failed to open /proc/kallsyms");
goto done;
}
seq = (struct seq_file *)kallsyms->private_data;
if (NULL == seq) {
-
sdp_warn("Failed to fetch sequential file.");
goto err_close;
}
for (iter = seq->op->start(seq, &pos);
iter != NULL;
- iter = seq->op->next(seq, iter, &pos)) {
-
- if (0 == strcmp(iter->name, "do_mlock")) {
-
+ iter = seq->op->next(seq, iter, &pos))
+ if (0 == strcmp(iter->name, "do_mlock"))
_mlock_ptr = (do_mlock_ptr_t)iter->value;
- }
- }
-
- if (NULL == _mlock_ptr) {
+ if (NULL == _mlock_ptr)
sdp_warn("Failed to find lock pointer.");
- }
- else {
-
+ else
ret = 0;
- }
err_close:
filp_close(kallsyms, NULL);
@@ -475,10 +427,8 @@ int sdp_iocb_register(struct sdpc_iocb *
/*
* register only once.
*/
- if (SDP_IOCB_F_REG & iocb->flags) {
-
+ if (SDP_IOCB_F_REG & iocb->flags)
return 0;
- }
/*
* prime io address with physical address of first byte?
*/
@@ -491,18 +441,14 @@ int sdp_iocb_register(struct sdpc_iocb *
iocb->page_count,
&iocb->io_addr);
if (IS_ERR(iocb->mem)) {
-
result = (int)PTR_ERR(iocb->mem);
- if (-EAGAIN != result) {
-
+ if (-EAGAIN != result)
sdp_dbg_err("Error <%d> fmr_pool_map_phys <%d:%d:%d>",
result,
iocb->len,
iocb->page_count,
iocb->page_offset);
- }
-
goto error;
}
@@ -531,17 +477,13 @@ int sdp_iocb_release(struct sdpc_iocb *i
SDP_CHECK_NULL(iocb, -EINVAL);
- if (0 == (SDP_IOCB_F_REG & iocb->flags)) {
-
+ if (0 == (SDP_IOCB_F_REG & iocb->flags))
return 0;
- }
result = ib_fmr_pool_unmap(iocb->mem);
- if (0 > result) {
-
+ if (0 > result)
sdp_dbg_err("Error <%d> releasing IOCB <%d> memory <%ld>",
result, iocb->key, iocb->addr);
- }
iocb->flags &= ~(SDP_IOCB_F_REG);
@@ -560,20 +502,16 @@ static void _sdp_iocb_complete(void *arg
* release memory
*/
result = sdp_iocb_release(iocb);
- if (0 > result) {
-
+ if (0 > result)
sdp_dbg_err("Error <%d> releasing IOCB <%d> memory <%ld>",
result, iocb->key, iocb->addr);
- }
/*
* unlock now, after aio_complete the mm reference will be released.
*/
result = sdp_iocb_unlock(iocb);
- if (0 > result) {
-
+ if (0 > result)
sdp_dbg_err("Error <%d> unlocking IOCB <%d memory <%ld>>",
result, iocb->key, iocb->addr);
- }
/*
* callback to complete IOCB
*/
@@ -591,11 +529,9 @@ static void _sdp_iocb_complete(void *arg
* delete IOCB
*/
result = sdp_iocb_destroy(iocb);
- if (0 > result) {
-
+ if (0 > result)
sdp_dbg_err("Error <%d> deleting IOCB <%d> of status <%Zu>",
result, iocb->key, iocb->status);
- }
return;
} /* _sdp_iocb_complete */
@@ -610,17 +546,10 @@ int sdp_iocb_complete(struct sdpc_iocb *
iocb->status = status;
if (in_atomic() || irqs_disabled()) {
-
- INIT_WORK(&iocb->completion,
- _sdp_iocb_complete,
- (void *)iocb);
-
+ INIT_WORK(&iocb->completion, _sdp_iocb_complete, (void *)iocb);
schedule_work(&iocb->completion);
- }
- else {
-
+ } else
_sdp_iocb_complete(iocb);
- }
return 0;
} /* sdp_iocb_complete */
@@ -646,21 +575,16 @@ int sdp_iocb_q_remove(struct sdpc_iocb *
table = iocb->table;
- if (iocb->next == iocb && iocb->prev == iocb) {
-
+ if (iocb->next == iocb && iocb->prev == iocb)
table->head = NULL;
- }
else {
-
next = iocb->next;
prev = iocb->prev;
next->prev = prev;
prev->next = next;
- if (table->head == iocb) {
-
+ if (table->head == iocb)
table->head = next;
- }
}
table->size--;
@@ -682,15 +606,10 @@ struct sdpc_iocb *sdp_iocb_q_lookup(stru
SDP_CHECK_NULL(table, NULL);
- for (counter = 0, iocb = table->head;
- counter < table->size;
- counter++, iocb = iocb->next) {
-
- if (iocb->key == key) {
-
+ for (counter = 0, iocb = table->head; counter < table->size;
+ counter++, iocb = iocb->next)
+ if (iocb->key == key)
return iocb;
- }
- }
return NULL;
} /* sdp_iocb_q_lookup */
@@ -704,7 +623,6 @@ struct sdpc_iocb *sdp_iocb_create(void)
iocb = kmem_cache_alloc(__sdp_iocb_cache, SLAB_KERNEL);
if (NULL != iocb) {
-
memset(iocb, 0, sizeof(struct sdpc_iocb));
/*
* non-zero initialization
@@ -722,16 +640,11 @@ struct sdpc_iocb *sdp_iocb_create(void)
*/
int sdp_iocb_destroy(struct sdpc_iocb *iocb)
{
- if (NULL == iocb) {
-
+ if (NULL == iocb)
return -EINVAL;
- }
-
- if (NULL != iocb->next ||
- NULL != iocb->prev) {
+ if (NULL != iocb->next || NULL != iocb->prev)
return -EACCES;
- }
/*
* release iocb registered memory
*/
@@ -743,15 +656,11 @@ int sdp_iocb_destroy(struct sdpc_iocb *i
/*
* array dealloc
*/
- if (NULL != iocb->page_array) {
-
+ if (NULL != iocb->page_array)
kfree(iocb->page_array);
- }
- if (NULL != iocb->addr_array) {
-
+ if (NULL != iocb->addr_array)
kfree(iocb->addr_array);
- }
/*
* clear IOCB to check for usage after free...
*/
@@ -787,26 +696,17 @@ static struct sdpc_iocb *_sdp_iocb_q_get
SDP_CHECK_NULL(table, NULL);
- if (NULL == table->head) {
-
+ if (NULL == table->head)
return NULL;
- }
-
- if (head) {
+ if (head)
iocb = table->head;
- }
- else {
-
+ else
iocb = table->head->prev;
- }
-
- if (iocb->next == iocb && iocb->prev == iocb) {
+ if (iocb->next == iocb && iocb->prev == iocb)
table->head = NULL;
- }
else {
-
next = iocb->next;
prev = iocb->prev;
next->prev = prev;
@@ -838,13 +738,10 @@ static int _sdp_iocb_q_put(struct sdpc_i
SDP_CHECK_NULL(iocb, -EINVAL);
if (NULL == table->head) {
-
iocb->next = iocb;
iocb->prev = iocb;
table->head = iocb;
- }
- else {
-
+ } else {
next = table->head;
prev = next->prev;
@@ -853,9 +750,8 @@ static int _sdp_iocb_q_put(struct sdpc_i
iocb->next = next;
next->prev = iocb;
- if (head) {
+ if (head)
table->head = iocb;
- }
}
table->size++;
@@ -917,11 +813,9 @@ int sdp_iocb_q_cancel(struct sdpc_iocb_q
*/
for (counter = 0, iocb = table->head, total = table->size;
counter < total; counter++) {
-
next = iocb->next;
if (0 < (mask & iocb->flags) || SDP_IOCB_F_ALL == mask) {
-
sdp_dbg_err("IOCB <%d> cancel <%Zu> flag <%04x> "
"size <%Zu:%d:%d>",
iocb->key, comp, iocb->flags, iocb->size,
@@ -966,7 +860,6 @@ int sdp_iocb_q_clear(struct sdpc_iocb_q
* drain the table of any objects
*/
while (NULL != (iocb = sdp_iocb_q_get_head(table))) {
-
result = sdp_iocb_destroy(iocb);
SDP_EXPECT(!(0 > result));
}
@@ -991,7 +884,6 @@ int sdp_main_iocb_init(void)
*/
result = _sdp_mem_lock_init();
if (0 > result) {
-
sdp_warn("Error <%d> initializing memory locking.", result);
return result;
} /* if */
@@ -999,7 +891,6 @@ int sdp_main_iocb_init(void)
* initialize the caches only once.
*/
if (NULL != __sdp_iocb_cache) {
-
sdp_warn("IOCB caches already initialized.");
return -EINVAL;
}
@@ -1009,7 +900,6 @@ int sdp_main_iocb_init(void)
0, SLAB_HWCACHE_ALIGN, NULL,
NULL);
if (NULL == __sdp_iocb_cache) {
-
result = -ENOMEM;
goto error_iocb_c;
}
More information about the general
mailing list