提交 11364d61 编写于 作者: C Christophe JAILLET 提交者: Herbert Xu

crypto: hisilicon/zip - Use the bitmap API to allocate bitmaps

Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.
It is less verbose and it improves the semantic.

While at it, add an explicit include <linux/bitmap.h>.
Signed-off-by: NChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 45f5d017
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* Copyright (c) 2019 HiSilicon Limited. */ /* Copyright (c) 2019 HiSilicon Limited. */
#include <crypto/internal/acompress.h> #include <crypto/internal/acompress.h>
#include <linux/bitfield.h> #include <linux/bitfield.h>
#include <linux/bitmap.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include "zip.h" #include "zip.h"
...@@ -606,8 +607,7 @@ static int hisi_zip_create_req_q(struct hisi_zip_ctx *ctx) ...@@ -606,8 +607,7 @@ static int hisi_zip_create_req_q(struct hisi_zip_ctx *ctx)
req_q = &ctx->qp_ctx[i].req_q; req_q = &ctx->qp_ctx[i].req_q;
req_q->size = QM_Q_DEPTH; req_q->size = QM_Q_DEPTH;
req_q->req_bitmap = kcalloc(BITS_TO_LONGS(req_q->size), req_q->req_bitmap = bitmap_zalloc(req_q->size, GFP_KERNEL);
sizeof(long), GFP_KERNEL);
if (!req_q->req_bitmap) { if (!req_q->req_bitmap) {
ret = -ENOMEM; ret = -ENOMEM;
if (i == 0) if (i == 0)
...@@ -631,11 +631,11 @@ static int hisi_zip_create_req_q(struct hisi_zip_ctx *ctx) ...@@ -631,11 +631,11 @@ static int hisi_zip_create_req_q(struct hisi_zip_ctx *ctx)
return 0; return 0;
err_free_loop1: err_free_loop1:
kfree(ctx->qp_ctx[HZIP_QPC_DECOMP].req_q.req_bitmap); bitmap_free(ctx->qp_ctx[HZIP_QPC_DECOMP].req_q.req_bitmap);
err_free_loop0: err_free_loop0:
kfree(ctx->qp_ctx[HZIP_QPC_COMP].req_q.q); kfree(ctx->qp_ctx[HZIP_QPC_COMP].req_q.q);
err_free_bitmap: err_free_bitmap:
kfree(ctx->qp_ctx[HZIP_QPC_COMP].req_q.req_bitmap); bitmap_free(ctx->qp_ctx[HZIP_QPC_COMP].req_q.req_bitmap);
return ret; return ret;
} }
...@@ -645,7 +645,7 @@ static void hisi_zip_release_req_q(struct hisi_zip_ctx *ctx) ...@@ -645,7 +645,7 @@ static void hisi_zip_release_req_q(struct hisi_zip_ctx *ctx)
for (i = 0; i < HZIP_CTX_Q_NUM; i++) { for (i = 0; i < HZIP_CTX_Q_NUM; i++) {
kfree(ctx->qp_ctx[i].req_q.q); kfree(ctx->qp_ctx[i].req_q.q);
kfree(ctx->qp_ctx[i].req_q.req_bitmap); bitmap_free(ctx->qp_ctx[i].req_q.req_bitmap);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册