From patchwork Wed Jul 24 03:54:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhou Wang X-Patchwork-Id: 169591 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9708953ilk; Tue, 23 Jul 2019 20:57:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPCcMoYHKkAM7yUVsKwoFh/jnnIwlvShZetpUdzWySS2FMqOZoP0KdVmam/d/1QHlnZM3s X-Received: by 2002:aa7:8705:: with SMTP id b5mr9550764pfo.27.1563940670756; Tue, 23 Jul 2019 20:57:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563940670; cv=none; d=google.com; s=arc-20160816; b=ll95iWJVT41TlWf12dTOt0WXFNyp8RhRi8nA7elVGrADYDMB7NKgbcqvubgtAkWEHi lnIvRaBJZME8n+Kx2dyYY6DdBI5TpJAdfXqSkrJ8M/7NyWy8q8adjXMRc4Fky5Q1Y8Zk p/DPMarDS8f6NW+xX83i63yKgKt6uimYHxa2xNM2GlyLejl8hAB6JSsuWbdqPaWNBsA6 sVHy9kVBAEbqOe0vvOqhAzrQ4b1NXi6pXdiK3HHkGWe/pQilGgkhfwa1aUcBwAv6qLX4 2SVoCDZ75ygK/THGQv54y3xaDwndzVVXJpH971DdIdyjFXICZCiRjfOZNjoRGMyO8dyg JO7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=2dg8T0+GPML+1BICuT4M6Q8/TeE7ra3Jpcgm1/JRZ+w=; b=AUkENsvFZ/McIuM0IRRrF12I+55W5qNRNFA1qxd5rOu3c4El7I3qzW0N5WNLZyBbkw UfWwN16gbxBbdQkDRzpe2ohZghmbEHjfrk9h1xMHQbq128KKbzGbo8tnjFLTKDFZBRVO MIwggfeHTfuovHu1ihZyZZuEyefw+wDzc62wa0zzcX+lw4vsvOA066Tah5CPY7cu5coS bB9vu3SwmoU3aLxntTcxuHZZWj7EGYWxxHNfyXT22qZtQW1eiPDHb9dJP7lfAwstiPnm BFLaPh43dcPW/eWmY2f+bKICkhajD93pQU4Y1MJbY0nSLMZ3UOcPROx1UMR1dMXqEkev hJjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si12962106pgl.448.2019.07.23.20.57.50; Tue, 23 Jul 2019 20:57:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbfGXD5r (ORCPT + 29 others); Tue, 23 Jul 2019 23:57:47 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2745 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725855AbfGXD5r (ORCPT ); Tue, 23 Jul 2019 23:57:47 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id CEE496E40C58B4D5EB37; Wed, 24 Jul 2019 11:57:45 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 24 Jul 2019 11:57:39 +0800 From: Zhou Wang To: , CC: , , Zhou Wang Subject: [PATCH resend v2] lib: scatterlist: Fix to support no mapped sg Date: Wed, 24 Jul 2019 11:54:23 +0800 Message-ID: <1563940463-95597-1-git-send-email-wangzhou1@hisilicon.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In function sg_split, the second sg_calculate_split will return -EINVAL when in_mapped_nents is 0. Indeed there is no need to do second sg_calculate_split and sg_split_mapped when in_mapped_nents is 0, as in_mapped_nents indicates no mapped entry in original sgl. Signed-off-by: Zhou Wang Acked-by: Robert Jarzmik --- v2: Just add Acked-by from Robert. lib/sg_split.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.8.1 diff --git a/lib/sg_split.c b/lib/sg_split.c index 9982c63..60a0bab 100644 --- a/lib/sg_split.c +++ b/lib/sg_split.c @@ -176,11 +176,13 @@ int sg_split(struct scatterlist *in, const int in_mapped_nents, * The order of these 3 calls is important and should be kept. */ sg_split_phys(splitters, nb_splits); - ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip, - split_sizes, splitters, true); - if (ret < 0) - goto err; - sg_split_mapped(splitters, nb_splits); + if (in_mapped_nents) { + ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip, + split_sizes, splitters, true); + if (ret < 0) + goto err; + sg_split_mapped(splitters, nb_splits); + } for (i = 0; i < nb_splits; i++) { out[i] = splitters[i].out_sg;