@@ -21,7 +21,7 @@ static void destroy_842(struct zcomp_ctx *ctx)
kfree(ctx->context);
}
-static int create_842(struct zcomp_params *params, struct zcomp_ctx *ctx)
+static int create_842(struct zcomp *zcomp, struct zcomp_ctx *ctx)
{
ctx->context = kmalloc(SW842_MEM_COMPRESS, GFP_KERNEL);
if (!ctx->context)
@@ -46,8 +46,9 @@ static void deflate_destroy(struct zcomp_ctx *ctx)
kfree(zctx);
}
-static int deflate_create(struct zcomp_params *params, struct zcomp_ctx *ctx)
+static int deflate_create(struct zcomp *zcomp, struct zcomp_ctx *ctx)
{
+ struct zcomp_params *params = zcomp->params;
struct deflate_ctx *zctx;
size_t sz;
int ret;
@@ -37,8 +37,9 @@ static void lz4_destroy(struct zcomp_ctx *ctx)
kfree(zctx);
}
-static int lz4_create(struct zcomp_params *params, struct zcomp_ctx *ctx)
+static int lz4_create(struct zcomp *zcomp, struct zcomp_ctx *ctx)
{
+ struct zcomp_params *params = zcomp->params;
struct lz4_ctx *zctx;
zctx = kzalloc(sizeof(*zctx), GFP_KERNEL);
@@ -37,8 +37,9 @@ static void lz4hc_destroy(struct zcomp_ctx *ctx)
kfree(zctx);
}
-static int lz4hc_create(struct zcomp_params *params, struct zcomp_ctx *ctx)
+static int lz4hc_create(struct zcomp *zcomp, struct zcomp_ctx *ctx)
{
+ struct zcomp_params *params = zcomp->params;
struct lz4hc_ctx *zctx;
zctx = kzalloc(sizeof(*zctx), GFP_KERNEL);
@@ -15,7 +15,7 @@ static int lzo_setup_params(struct zcomp_params *params)
return 0;
}
-static int lzo_create(struct zcomp_params *params, struct zcomp_ctx *ctx)
+static int lzo_create(struct zcomp *params, struct zcomp_ctx *ctx)
{
ctx->context = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL);
if (!ctx->context)
@@ -15,7 +15,7 @@ static int lzorle_setup_params(struct zcomp_params *params)
return 0;
}
-static int lzorle_create(struct zcomp_params *params, struct zcomp_ctx *ctx)
+static int lzorle_create(struct zcomp *zcomp, struct zcomp_ctx *ctx)
{
ctx->context = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL);
if (!ctx->context)
@@ -125,8 +125,9 @@ static void zstd_destroy(struct zcomp_ctx *ctx)
kfree(zctx);
}
-static int zstd_create(struct zcomp_params *params, struct zcomp_ctx *ctx)
+static int zstd_create(struct zcomp *zcomp, struct zcomp_ctx *ctx)
{
+ struct zcomp_params *params = zcomp->params;
struct zstd_ctx *zctx;
zstd_parameters prm;
size_t sz;
@@ -54,7 +54,7 @@ static int zcomp_strm_init(struct zcomp *comp, struct zcomp_strm *zstrm)
{
int ret;
- ret = comp->ops->create_ctx(comp->params, &zstrm->ctx);
+ ret = comp->ops->create_ctx(comp, &zstrm->ctx);
if (ret)
return ret;
@@ -45,13 +45,15 @@ struct zcomp_req {
size_t dst_len;
};
+struct zcomp;
+
struct zcomp_ops {
int (*compress)(struct zcomp_params *params, struct zcomp_ctx *ctx,
struct zcomp_req *req);
int (*decompress)(struct zcomp_params *params, struct zcomp_ctx *ctx,
struct zcomp_req *req);
- int (*create_ctx)(struct zcomp_params *params, struct zcomp_ctx *ctx);
+ int (*create_ctx)(struct zcomp *zcomp, struct zcomp_ctx *ctx);
void (*destroy_ctx)(struct zcomp_ctx *ctx);
int (*setup_params)(struct zcomp_params *params);
This is a more general approach: for some backends, some of the data needed to create a context can be stored in zcomp structure. And we also can get zcomp_params structure from zcomp. Signed-off-by: Alexey Romanov <avromanov@salutedevices.com> --- drivers/block/zram/backend_842.c | 2 +- drivers/block/zram/backend_deflate.c | 3 ++- drivers/block/zram/backend_lz4.c | 3 ++- drivers/block/zram/backend_lz4hc.c | 3 ++- drivers/block/zram/backend_lzo.c | 2 +- drivers/block/zram/backend_lzorle.c | 2 +- drivers/block/zram/backend_zstd.c | 3 ++- drivers/block/zram/zcomp.c | 2 +- drivers/block/zram/zcomp.h | 4 +++- 9 files changed, 15 insertions(+), 9 deletions(-)