summaryrefslogtreecommitdiff
path: root/drivers/infiniband/hw/usnic
diff options
context:
space:
mode:
authorUpinder Malhi <umalhi@cisco.com>2014-01-10 02:48:45 +0400
committerRoland Dreier <roland@purestorage.com>2014-01-14 12:44:46 +0400
commitc5f855e08a97edc107c4a3b73809ed629c1dcac1 (patch)
treeead6f88f161884d02fc73070e6bee0b85b8042a2 /drivers/infiniband/hw/usnic
parent6a54d9f9a04ed35e6615a47974c1ef02ff3a62cb (diff)
downloadlinux-c5f855e08a97edc107c4a3b73809ed629c1dcac1.tar.xz
IB/usnic: Use for_each_sg instead of a for-loop
Use for_each_sg() instead of an explicit for-loop to iterate over scatter-gather list. Signed-off-by: Upinder Malhi <umalhi@cisco.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/hw/usnic')
-rw-r--r--drivers/infiniband/hw/usnic/usnic_uiom.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c
index c841a752dbd0..ae6934c0d05a 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom.c
+++ b/drivers/infiniband/hw/usnic/usnic_uiom.c
@@ -80,13 +80,14 @@ static void usnic_uiom_put_pages(struct list_head *chunk_list, int dirty)
{
struct usnic_uiom_chunk *chunk, *tmp;
struct page *page;
+ struct scatterlist *sg;
int i;
dma_addr_t pa;
list_for_each_entry_safe(chunk, tmp, chunk_list, list) {
- for (i = 0; i < chunk->nents; i++) {
- page = sg_page(&chunk->page_list[i]);
- pa = sg_phys(&chunk->page_list[i]);
+ for_each_sg(chunk->page_list, sg, chunk->nents, i) {
+ page = sg_page(sg);
+ pa = sg_phys(sg);
if (dirty)
set_page_dirty_lock(page);
put_page(page);
@@ -100,6 +101,7 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
int dmasync, struct list_head *chunk_list)
{
struct page **page_list;
+ struct scatterlist *sg;
struct usnic_uiom_chunk *chunk;
unsigned long locked;
unsigned long lock_limit;
@@ -165,11 +167,10 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
chunk->nents = min_t(int, ret, USNIC_UIOM_PAGE_CHUNK);
sg_init_table(chunk->page_list, chunk->nents);
- for (i = 0; i < chunk->nents; ++i) {
- sg_set_page(&chunk->page_list[i],
- page_list[i + off],
- PAGE_SIZE, 0);
- pa = sg_phys(&chunk->page_list[i]);
+ for_each_sg(chunk->page_list, sg, chunk->nents, i) {
+ sg_set_page(sg, page_list[i + off],
+ PAGE_SIZE, 0);
+ pa = sg_phys(sg);
usnic_dbg("va: 0x%lx pa: %pa\n",
cur_base + i*PAGE_SIZE, &pa);
}