From patchwork Thu Jan 9 22:48:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Upinder Malhi (umalhi)" X-Patchwork-Id: 3463671 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6FD749F2E9 for ; Thu, 9 Jan 2014 22:48:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E8F920103 for ; Thu, 9 Jan 2014 22:48:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0F41200F3 for ; Thu, 9 Jan 2014 22:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756236AbaAIWss (ORCPT ); Thu, 9 Jan 2014 17:48:48 -0500 Received: from mtv-iport-1.cisco.com ([173.36.130.12]:33205 "EHLO mtv-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751751AbaAIWsr (ORCPT ); Thu, 9 Jan 2014 17:48:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2068; q=dns/txt; s=iport; t=1389307727; x=1390517327; h=from:to:cc:subject:date:message-id; bh=e8VYbiEoiHANbbNrLD6DKP0QWeNsutWO+QdjHRowP/s=; b=MztnztEyKSOTs0rkLpSPWlZBQFSwOxK+R9WiPpJ5J6R5ccYox0IBTFui ECv/Yg5vtOmZa8Ln9X+yg9LRs/D5boDoVoxBv4JPiL5VJD9djLyAuPSIy pyG1/GU8dTp+7Awo7p2vSX4nVo5yWtCZK/T4T0Lo0amxAGUbsFuMCEH5M s=; X-IronPort-AV: E=Sophos;i="4.95,634,1384300800"; d="scan'208";a="99229774" Received: from mtv-core-1.cisco.com ([171.68.58.6]) by mtv-iport-1.cisco.com with ESMTP; 09 Jan 2014 22:48:46 +0000 Received: from sjc-savbu-bld03.cisco.com (sjc-savbu-bld03.cisco.com [171.71.188.58]) by mtv-core-1.cisco.com (8.14.5/8.14.5) with ESMTP id s09MmkTd031000; Thu, 9 Jan 2014 22:48:46 GMT Received: by sjc-savbu-bld03.cisco.com (Postfix, from userid 246720) id 54FCB3F563; Thu, 9 Jan 2014 14:48:46 -0800 (PST) From: Upinder Malhi To: linux-rdma@vger.kernel.org, roland@kernel.org Cc: Upinder Malhi Subject: [PATCH for-next] IB/usnic: Use for_each_sg instead of a for-loop Date: Thu, 9 Jan 2014 14:48:45 -0800 Message-Id: <1389307725-11670-1-git-send-email-umalhi@cisco.com> X-Mailer: git-send-email 1.8.0-rc0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Depends on "[PATCH v1 for-next] IB/usnic: usNIC UDP Support" series. Use for_each_sg instead of a explicit for-loop to iterate over scatter-gather list. Signed-off-by: Upinder Malhi --- drivers/infiniband/hw/usnic/usnic_uiom.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) -- 1.8.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c index 200941f..51e5b97 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); }