Hi Herbert, I'm resuming this as I would like to send an updated version of the patch that converts BTRFS to use the acomp APIs [1]. On Mon, May 20, 2024 at 07:04:48PM +0800, Herbert Xu wrote: > Add the acompress plubming for setparam. This is modelled after > setkey for ahash. > > Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> > --- > crypto/acompress.c | 70 ++++++++++++++++++++++++++--- > crypto/compress.h | 9 +++- > crypto/scompress.c | 9 +--- > include/crypto/acompress.h | 32 ++++++++++++- > include/crypto/internal/acompress.h | 3 ++ > 5 files changed, 106 insertions(+), 17 deletions(-) > > diff --git a/crypto/acompress.c b/crypto/acompress.c > index 6fdf0ff9f3c0..cf37243a2a3c 100644 > --- a/crypto/acompress.c > +++ b/crypto/acompress.c ... > +int crypto_acomp_setparam(struct crypto_acomp *tfm, const u8 *param, > + unsigned int len) Is the intent here to use strings to identify parameters? In such case, `len` should be called `value`. Or, is `param` a pointer to a structure? In case `param` is a string, this would work ok with parameters that just take a value, example of usage: tfm = crypto_alloc_acomp("deflate", 0, 0); crypto_acomp_setparam(tfm, COMP_ALG_COMPRESSION_LEVEL, 9); Logic in algorithm: #define COMP_ALG_COMPRESSION_LEVEL "compression-level" #define COMP_ALG_HISTORY_SIZE "history-size" enum { COMP_LEVEL, COMP_HISTORY_SIZE, }; static const char * const param_type[] = { [COMP_LEVEL] = COMP_ALG_COMPRESSION_LEVEL, [COMP_HISTORY_SIZE] = COMP_ALG_HISTORY_SIZE, }; static int deflate_setparam(struct crypto_acomp *tfm, const u8 *param, unsigned int val) { int ret; ret = sysfs_match_string(param_type, param); if (ret < 0) return ret; switch (ret) { case COMP_LEVEL: /* Set compression level */ break; case COMP_HISTORY_SIZE: /* Set history size*/ break; default: break; } return 0; } static struct acomp_alg acomp = { .compress = deflate_compress, .decompress = deflate_decompress, .setparam = deflate_setparam, Thanks, -- Giovanni [1] https://lore.kernel.org/all/20240426110941.5456-7-giovanni.cabiddu@xxxxxxxxx/