Re: [PATCH v3 04/19] crypto: scatterwalk - add new functions for copying data

From: Herbert Xu
Date: Sun Mar 02 2025 - 01:41:12 EST


Eric Biggers <ebiggers@xxxxxxxxxx> wrote:
>
> +void memcpy_from_sglist(void *buf, struct scatterlist *sg,
> + unsigned int start, unsigned int nbytes)
> {
> struct scatter_walk walk;
> - struct scatterlist tmp[2];
>
> - if (!nbytes)
> + if (unlikely(nbytes == 0)) /* in case sg == NULL */
> return;
>
> - sg = scatterwalk_ffwd(tmp, sg, start);
> + scatterwalk_start_at_pos(&walk, sg, start);
> + memcpy_from_scatterwalk(buf, &walk, nbytes);
> +}
> +EXPORT_SYMBOL_GPL(memcpy_from_sglist);
> +
> +void memcpy_to_sglist(struct scatterlist *sg, unsigned int start,
> + const void *buf, unsigned int nbytes)

These functions duplicate sg_copy_buffer. Of course scatterwalk
in general duplicates SG miter which came later IIRC.

What's your plan for eliminating this duplication?

Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt