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

Herbert Xu
2025-03-02T06:40:59Z

Eric Biggers <ebiggers@kernel.org> 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@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt