Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp485275lqb; Wed, 29 May 2024 01:19:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU7lLDbo9Un4R8thk2wcjR6AvXRgbN1I4+9KcDpdyxwZD6mQETQz43q/beJAVK59wNdt1wQEcdnRjhzck2otnYAW5hYB4ST3zf46zrMRw== X-Google-Smtp-Source: AGHT+IHBFZxq25kAjLjn6xEeqC/JZd4vtfqVweh1HsF0YQiEQjgbL+mNwMRO/CXMJKBv2CvoBIfn X-Received: by 2002:a05:620a:22ea:b0:792:bcc5:5c5 with SMTP id af79cd13be357-794ab08d976mr1578326585a.9.1716970779956; Wed, 29 May 2024 01:19:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716970779; cv=pass; d=google.com; s=arc-20160816; b=EY6Ok1A9uh82oJX90/QJEoTOJ93x+Lk7C14p2KKL92heATg5TIHtyil6cd8OqLbxTN XpX8Yhbz4tRz/O2dmKDv+B3y0PF76OfrWKHypi8JAaWBeVPOmZHqz6aXl7Sx5c3G5fDw GyGTHmz2+jcqYyBgksfmcg4xiMROwQ6S3eE7FY0eDZ9YPOY7N06oIr2nfqswKpaKrtAN 1beGqIa85y0Ti9dH+hQ5RTkQgVmIF/faHQxf9/3p/ALqgzo33q8WjcILLpV2NCYsugBR 7yvGeFkdMmIuE+xukD2cQ85hPOtW5Bwt8bOEdh+eJrSD4m1caut3BPCZLnt5beosfF7T 5rEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from; bh=UQ3Fs24Hlq2CIiavJc//tuqW25mKc1p6+OsIx6HvpOo=; fh=bHKnRTSk+4V3ecUJyVumQ+9TAmf/ec1d0hsxlUaNIg0=; b=iEUyzM/gpQrGh1BC2cruaaEG6aUYtJISXRqj0GoKXvMBNEGSpu3Ew8ynZga7eUOoBq 9rvyzm8FbYBvH5fhj4cicfh35OtZBFSpP6uQbrbekVMiiLdz0OE6jCZHhf8lNvH8hEK1 KVj1bDXcN50ybVJ8w9mT7IZeXMggIzpSq6VeolTwwn7wGck75DDDc3U4D2Ds064NpAkq JoJtfzbGcfz9bfLVySaHx8UIdNEH27lYlWPCKlpjOBP9HtDOomcbp5EoypDtWP/6skaB SryC8paZAXIJZvyRyHdrKE4UaVSQ4aKMax0pf2FfuwzDjHb3crMVSXzBCV1Jefajp5dY nlsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-193699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193699-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794abcad977si1305710685a.95.2024.05.29.01.19.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 01:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-193699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193699-linux.lists.archive=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id AA0191C25975 for ; Wed, 29 May 2024 08:18:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F3AB181BAD; Wed, 29 May 2024 08:09:07 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 81642181BA5 for ; Wed, 29 May 2024 08:09:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716970147; cv=none; b=RBVyfX8g2UV7RRda02BuajMUIenDMIgJTJWmqjqDKGQE63zqUMaq68xBH33VYu2p4eXx6rlTcx8nxOIDdCAgqz8Z97xAviNsM/UayAAZ9DliePK4yoLWsULlYqYdV/38jzW9456lrPhRHfILYhuFA1hm6XGolSht5CdmcIOMSo4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716970147; c=relaxed/simple; bh=96iFbUwojxwBoxA+H0JTEulerW3QRm1exN8DOQ8GsGs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=tYRQf8nlWXonTB6mEbL3wHE5a3QsWgKWPnPkCuuiDi396U5+8r4QIIAsED11RCVJhcP3cAQRHca+4vtrFIbe0dByYatDDiLU727BQ4j4URDmPS5WIzb867KHGnMZtGTu9IM2AaOU/QPGaLFZsM2kQUUPV0uu0XeH/+09cgGt6uM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sCEMW-0002i8-0F; Wed, 29 May 2024 10:08:44 +0200 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sCEMQ-003RAe-SQ; Wed, 29 May 2024 10:08:38 +0200 Received: from localhost ([::1] helo=dude05.red.stw.pengutronix.de) by dude05.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1sCEMQ-00EJoV-2e; Wed, 29 May 2024 10:08:38 +0200 From: Ahmad Fatoum Date: Wed, 29 May 2024 10:08:29 +0200 Subject: [PATCH v2] docs: crypto: async-tx-api: fix broken code example Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240529-async-dma-docs-v2-1-8faf87e72e6d@pengutronix.de> X-B4-Tracking: v=1; b=H4sIAHziVmYC/3XMQQ6CMBCF4auQWTtmpmKCrryHYVHaEWZhS1okE MLdrexd/i953wZZkkqGe7VBklmzxlDCnCpwgw29oPrSYMjUdDUXtHkNDv3boo8uI5F03NhaiB2 U05jkpcsBPtvSg+YppvXwZ/6tf6mZkbG7FZEaqoX5MUroP1OKQZezF2j3ff8Cf58CxLEAAAA= To: Dan Williams , Herbert Xu , "David S. Miller" , Jonathan Corbet , Andre Noll Cc: linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Ahmad Fatoum X-Mailer: b4 0.13-dev X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org The code example fails to compile: 1) addr_conv is defined twice, once as a VLA, which have been phased out 2) submit is not a pointer, but is still dereferenced with -> 3) The first call to async_xor() lacked the trailing semicolon Fix these issues and while at it, fix some code style nitpicks as well: 1) make the functions static as users are unlikely to export them 2) include the relevant header 3) Shorten the example a bit by removing a redundant variable definition Fixes: 04ce9ab385dc ("async_xor: permit callers to pass in a 'dma/page scribble' region") Signed-off-by: Ahmad Fatoum --- Changes in v2: - commit message: fix addr_conv typo (Andre) - commit message: note addition of missing semicolon (Andre) - add header include (Andre) - shorten code by removing redundant variable definition (Andre) - Link to v1: https://lore.kernel.org/r/20240523-async-dma-docs-v1-1-b900e0804e11@pengutronix.de --- Documentation/crypto/async-tx-api.rst | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Documentation/crypto/async-tx-api.rst b/Documentation/crypto/async-tx-api.rst index 27c146b54d71..f88a7809385e 100644 --- a/Documentation/crypto/async-tx-api.rst +++ b/Documentation/crypto/async-tx-api.rst @@ -150,38 +150,38 @@ of an operation. Perform a xor->copy->xor operation where each operation depends on the result from the previous operation:: - void callback(void *param) - { - struct completion *cmp = param; + #include - complete(cmp); + static void callback(void *param) + { + complete(param); } - void run_xor_copy_xor(struct page **xor_srcs, - int xor_src_cnt, - struct page *xor_dest, - size_t xor_len, - struct page *copy_src, - struct page *copy_dest, - size_t copy_len) + #define NDISKS 2 + + static void run_xor_copy_xor(struct page **xor_srcs, + struct page *xor_dest, + size_t xor_len, + struct page *copy_src, + struct page *copy_dest, + size_t copy_len) { struct dma_async_tx_descriptor *tx; - addr_conv_t addr_conv[xor_src_cnt]; struct async_submit_ctl submit; addr_conv_t addr_conv[NDISKS]; struct completion cmp; init_async_submit(&submit, ASYNC_TX_XOR_DROP_DST, NULL, NULL, NULL, addr_conv); - tx = async_xor(xor_dest, xor_srcs, 0, xor_src_cnt, xor_len, &submit) + tx = async_xor(xor_dest, xor_srcs, 0, NDISKS, xor_len, &submit); - submit->depend_tx = tx; + submit.depend_tx = tx; tx = async_memcpy(copy_dest, copy_src, 0, 0, copy_len, &submit); init_completion(&cmp); init_async_submit(&submit, ASYNC_TX_XOR_DROP_DST | ASYNC_TX_ACK, tx, callback, &cmp, addr_conv); - tx = async_xor(xor_dest, xor_srcs, 0, xor_src_cnt, xor_len, &submit); + tx = async_xor(xor_dest, xor_srcs, 0, NDISKS, xor_len, &submit); async_tx_issue_pending_all(); --- base-commit: a38297e3fb012ddfa7ce0321a7e5a8daeb1872b6 change-id: 20240523-async-dma-docs-00eb18a4e01c Best regards, -- Ahmad Fatoum