linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] docs: crypto: async-tx-api: fix broken code example
@ 2024-05-29  8:08 Ahmad Fatoum
  2024-06-03 18:58 ` Andre Noll
  2024-06-12 21:41 ` Jonathan Corbet
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-05-29  8:08 UTC (permalink / raw)
  To: Dan Williams, Herbert Xu, David S. Miller, Jonathan Corbet,
	Andre Noll
  Cc: linux-crypto, linux-doc, linux-kernel, kernel, Ahmad Fatoum

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 <a.fatoum@pengutronix.de>
---
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 <linux/async_tx.h>
 
-	    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 <a.fatoum@pengutronix.de>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] docs: crypto: async-tx-api: fix broken code example
  2024-05-29  8:08 [PATCH v2] docs: crypto: async-tx-api: fix broken code example Ahmad Fatoum
@ 2024-06-03 18:58 ` Andre Noll
  2024-06-12 21:41 ` Jonathan Corbet
  1 sibling, 0 replies; 3+ messages in thread
From: Andre Noll @ 2024-06-03 18:58 UTC (permalink / raw)
  To: Ahmad Fatoum
  Cc: Dan Williams, Herbert Xu, David S. Miller, Jonathan Corbet,
	Andre Noll, linux-crypto, linux-doc, linux-kernel, kernel

On Wed, May 29, 10:08, Ahmad Fatoum wrote
> 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 <a.fatoum@pengutronix.de>
> ---
> 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

Looks good to me now. Feel free to add

	Reviewed-by: Andre Noll <maan@tuebingen.mpg.de>

Best
Andre
-- 
Max Planck Institute for Biology
Tel: (+49) 7071 601 829
Max-Planck-Ring 5, 72076 Tübingen, Germany
http://people.tuebingen.mpg.de/maan/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] docs: crypto: async-tx-api: fix broken code example
  2024-05-29  8:08 [PATCH v2] docs: crypto: async-tx-api: fix broken code example Ahmad Fatoum
  2024-06-03 18:58 ` Andre Noll
@ 2024-06-12 21:41 ` Jonathan Corbet
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Corbet @ 2024-06-12 21:41 UTC (permalink / raw)
  To: Ahmad Fatoum, Dan Williams, Herbert Xu, David S. Miller,
	Andre Noll
  Cc: linux-crypto, linux-doc, linux-kernel, kernel, Ahmad Fatoum

Ahmad Fatoum <a.fatoum@pengutronix.de> writes:

> 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 <a.fatoum@pengutronix.de>

It looks like nobody has picked this up, so I've applied it.

Thanks,

jon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-12 21:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29  8:08 [PATCH v2] docs: crypto: async-tx-api: fix broken code example Ahmad Fatoum
2024-06-03 18:58 ` Andre Noll
2024-06-12 21:41 ` Jonathan Corbet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).