Re: [PATCH v3 4/5] zram: add per-backend caps and validate parameters early

From: Sergey Senozhatsky

Date: Wed Jul 29 2026 - 23:22:03 EST


On (26/07/30 10:52), Haoqin Huang wrote:
[..]
> +int zcomp_validate_params(const char *comp, s32 level, const char *dict_path)
> +{
> + const struct zcomp_ops *backend = lookup_backend_ops(comp);
> +
> + if (!backend)
> + return -EINVAL;
> +
> + if (dict_path && !(backend->caps & ZCOMP_CAP_DICT)) {
> + pr_err("zram: %s does not support dictionary\n", comp);
> + return -EOPNOTSUPP;
> + }
> +
> + if (level != ZCOMP_PARAM_NOT_SET) {
> + if (!(backend->caps & ZCOMP_CAP_LEVEL)) {
> + pr_err("zram: %s does not support level\n", comp);
> + return -EOPNOTSUPP;
> + }
> + /* level_max == -1 means validate in .setup_params() */
> + if (backend->level_max >= 0 &&
> + (level < backend->level_min || level > backend->level_max)) {
> + pr_err("zram: invalid level %d for %s\n", level, comp);
> + return -EINVAL;
> + }
> + }
> + return 0;
> +}

I was thinking that you'd move all params validation to backend's
.setup_params(), not just zstd, but for every backend. Sorry if
my message was not clear. Can we move all validation to backends?