Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp756879lqt; Tue, 19 Mar 2024 02:57:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVzk0c2UbP9B6LP7dCGkZ+GNOIGIsebFBliKasGxXrmss4J5av58EUlYxpBBfYpVu9lT0V5zC2sghc+bvHgRPe5LKiYkYptKPyf53fW6Q== X-Google-Smtp-Source: AGHT+IFSXWIhRLmJEKkjlUvSIdHS2Oy0SsPHvQKveMhSZhnL7xVexbBpFlboaTxtT8GeBnOk0M8H X-Received: by 2002:a05:6830:d7:b0:6e5:1aed:5e80 with SMTP id x23-20020a05683000d700b006e51aed5e80mr13019022oto.15.1710842225809; Tue, 19 Mar 2024 02:57:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710842225; cv=pass; d=google.com; s=arc-20160816; b=sDNXdWInZ9JYj43h6kSg3RHJkDOq4aTxCg40HC1bDCs24D+/QyMnI/ezEcRByvkQ+N qJ2t1ZRPf09cN9gj9GBBUdJwFAezRgpohCvUsRjD7P5YoiYi+viXpXybZmb9lxnofoEL CzLgnSnhkG3xG+QnX3QYH90sNu6FUKOC9+amdlr7Ob5L3SP2BjzDgpJcamm8eWPA1VOl tVYXkCdXnHOkpqpTLVUOoVjRmvVG0qsankyP49mAMdi3iUyB2DFKAPzjrOl4KsjW9cZ1 Iq/sa9uShYAqZSQOe3asF3YMIxo2dUmj8PkTJoKi/iLWrUPwM6p0IK2Vf62kY9hYVkPb 0oyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bZCFUqwHs82maVEanIvmVQZuddrjIMnilFX8JZU9BWw=; fh=1apLYfXS6+ZpCx7WOexgYA4nBDec/uaBA0QcIOIjpts=; b=zbUguq/c7f3nZ/+h3/L4kS4e2G2Ao4grJxpH2Ofpj7bVOazolsJwi0exCsxBHulSZG cEkY/rKBDwaAmLWQFPMyGBx+MmnMB6Yw3X0d0sNdjBBfVzk2djuS12R2Xbrm1KakWGSC IQnw27XhaU8m7z/DyrExGVHPliMLniScx9f5ZH4Ec/xZWKO21QfQBncOvisiHW8CvLNF DURX0lEZC5Z/Sy9zjciO9m7d2i6A00Fwg+mqYej3IES5VDrcMlbY5eZGxVyITTiK/yCU P/fk2XdG92sBnF5D0AUS8tf8mnKiHe6hC8KLMBy72KGXvA3jEds29Qh68YXTd3xp1dYu z/Lg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bSETVizk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-107339-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107339-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y22-20020a656c16000000b005dc9c8e7093si10282118pgu.756.2024.03.19.02.57.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 02:57:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107339-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bSETVizk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-107339-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107339-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D3C2BB21E55 for ; Tue, 19 Mar 2024 09:55:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05BDD7F7C6; Tue, 19 Mar 2024 09:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bSETVizk" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D28F7D098; Tue, 19 Mar 2024 09:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710842021; cv=none; b=auMPhynXmOCG75oOjffgLRsyNzK5cTVQgoaGaagbuzZaDu4K8vrf5SY+A0FBRwaclVahAFMgbSZs8yiJhoQaB+fmPeDRDP95Tnc1UAEXJLWjmV8468TqQZFHKde6AjQFf5RgjVJmria84Q9c0/tAn3wCOLBrbs3eU2BuxbDpqNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710842021; c=relaxed/simple; bh=cWZjeTgOZCFr/5XpumqncS6R514+WzkceRCXWiA0OoM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pcot3DBJzz8072PPaO7THXe7CIogKR3vwTwYZNWcSlDYwqHzPJgQhgsu4SKNOO0AiV8gkZh85Yh+rbJQ+3DZeS2Pl7CM0TW5RCyKV9kifY6Imzl7JjCPnablbk9lubPRBteuITZDnurcExftaF5p6+Or946itcA+U43kI8P2kks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bSETVizk; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BBD7C433F1; Tue, 19 Mar 2024 09:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710842020; bh=cWZjeTgOZCFr/5XpumqncS6R514+WzkceRCXWiA0OoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bSETVizk+rVn1apNUog2bK9+0yOGPGPp+0yHbPNtKZgCpp77UOAdFetdlOHghgbn7 hiUOE1zV99R6k99AnMUbuDewlOltkcDsZzsBnyEHDuI2CDxWbrAY/oVHtJEmN8MQP8 xIXdbdCiozlLuoYPkryEgiRFbrTFDByc1BjBUStGv6tvDyrIgtit2ovDycxxvlA703 mWY9/t+wEO9KuND3+Gl+ijUd+xHRy9nvpE+Qb3kTfm4IEzBzS+5NWiC0XCyLV72vmu vVfjgEh7pJYaT7pghL+tNx/OHkUdDiitx6ryqsJps/H+ixWzQtC9b1fGuBEYsA/Zh7 0htebaF2ld8vQ== From: "Jiri Slaby (SUSE)" To: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Stefani Seibold , Andrew Morton Subject: [RFT 06/15] kfifo: pass offset to setup_sgl_buf() instead of a pointer Date: Tue, 19 Mar 2024 10:53:06 +0100 Message-ID: <20240319095315.27624-8-jirislaby@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240319095315.27624-1-jirislaby@kernel.org> References: <20240319095315.27624-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit As a preparatory for dma addresses filling, we need the data offset instead of virtual pointer in setup_sgl_buf(). So pass the former instead the latter. And pointer to fifo is needed in setup_sgl_buf() now too. Signed-off-by: Jiri Slaby (SUSE) Cc: Stefani Seibold Cc: Andrew Morton --- lib/kfifo.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/kfifo.c b/lib/kfifo.c index 61e35550aea5..3a249ce4f281 100644 --- a/lib/kfifo.c +++ b/lib/kfifo.c @@ -305,9 +305,12 @@ int __kfifo_to_user(struct __kfifo *fifo, void __user *to, } EXPORT_SYMBOL(__kfifo_to_user); -static unsigned int setup_sgl_buf(struct scatterlist *sgl, void *buf, - int nents, unsigned int len) +static unsigned int setup_sgl_buf(struct __kfifo *fifo, struct scatterlist *sgl, + unsigned int data_offset, int nents, + unsigned int len) { + const void *buf = fifo->data + data_offset; + if (!nents || !len) return 0; @@ -332,8 +335,8 @@ static unsigned int setup_sgl(struct __kfifo *fifo, struct scatterlist *sgl, } len_to_end = min(len, size - off); - n = setup_sgl_buf(sgl, fifo->data + off, nents, len_to_end); - n += setup_sgl_buf(sgl + n, fifo->data, nents - n, len - len_to_end); + n = setup_sgl_buf(fifo, sgl, off, nents, len_to_end); + n += setup_sgl_buf(fifo, sgl + n, 0, nents - n, len - len_to_end); return n; } -- 2.44.0