Message ID | 49a1b5bf6e8f7c2ad06a0e2dbc35e00169d4ebe2.1657383385.git.christophe.jaillet@wanadoo.fr (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Herbert Xu |
Headers | show |
Series | crypto: hisilicon/zip: Use the bitmap API to allocate bitmaps | expand |
On Sat, Jul 09, 2022 at 06:16:46PM +0200, Christophe JAILLET wrote: > Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. > > It is less verbose and it improves the semantic. > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > drivers/crypto/hisilicon/zip/zip_crypto.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c > index 67869513e48c..7bf53877e508 100644 > --- a/drivers/crypto/hisilicon/zip/zip_crypto.c > +++ b/drivers/crypto/hisilicon/zip/zip_crypto.c > @@ -606,8 +606,7 @@ static int hisi_zip_create_req_q(struct hisi_zip_ctx *ctx) > req_q = &ctx->qp_ctx[i].req_q; > req_q->size = QM_Q_DEPTH; > > - req_q->req_bitmap = kcalloc(BITS_TO_LONGS(req_q->size), > - sizeof(long), GFP_KERNEL); > + req_q->req_bitmap = bitmap_zalloc(req_q->size, GFP_KERNEL); > if (!req_q->req_bitmap) { > ret = -ENOMEM; > if (i == 0) You should add an include for linux/bitmap.h instead of relying on implicit inclusion through some random header file. The same goes for all your other patches too. Thanks,
Le 15/07/2022 à 10:33, Herbert Xu a écrit : > On Sat, Jul 09, 2022 at 06:16:46PM +0200, Christophe JAILLET wrote: >> Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. >> >> It is less verbose and it improves the semantic. >> >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> >> --- >> drivers/crypto/hisilicon/zip/zip_crypto.c | 9 ++++----- >> 1 file changed, 4 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c >> index 67869513e48c..7bf53877e508 100644 >> --- a/drivers/crypto/hisilicon/zip/zip_crypto.c >> +++ b/drivers/crypto/hisilicon/zip/zip_crypto.c >> @@ -606,8 +606,7 @@ static int hisi_zip_create_req_q(struct hisi_zip_ctx *ctx) >> req_q = &ctx->qp_ctx[i].req_q; >> req_q->size = QM_Q_DEPTH; >> >> - req_q->req_bitmap = kcalloc(BITS_TO_LONGS(req_q->size), >> - sizeof(long), GFP_KERNEL); >> + req_q->req_bitmap = bitmap_zalloc(req_q->size, GFP_KERNEL); >> if (!req_q->req_bitmap) { >> ret = -ENOMEM; >> if (i == 0) > > You should add an include for linux/bitmap.h instead of relying > on implicit inclusion through some random header file. Hi, most of the patches are accepted as-is, so I will not resend all of them. I'll only add the #include if a v2 is needed or for new patches. Thanks for the review and comment. CJ > > The same goes for all your other patches too. > > Thanks,
diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c index 67869513e48c..7bf53877e508 100644 --- a/drivers/crypto/hisilicon/zip/zip_crypto.c +++ b/drivers/crypto/hisilicon/zip/zip_crypto.c @@ -606,8 +606,7 @@ static int hisi_zip_create_req_q(struct hisi_zip_ctx *ctx) req_q = &ctx->qp_ctx[i].req_q; req_q->size = QM_Q_DEPTH; - req_q->req_bitmap = kcalloc(BITS_TO_LONGS(req_q->size), - sizeof(long), GFP_KERNEL); + req_q->req_bitmap = bitmap_zalloc(req_q->size, GFP_KERNEL); if (!req_q->req_bitmap) { ret = -ENOMEM; if (i == 0) @@ -631,11 +630,11 @@ static int hisi_zip_create_req_q(struct hisi_zip_ctx *ctx) return 0; 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: kfree(ctx->qp_ctx[HZIP_QPC_COMP].req_q.q); 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; } @@ -645,7 +644,7 @@ static void hisi_zip_release_req_q(struct hisi_zip_ctx *ctx) for (i = 0; i < HZIP_CTX_Q_NUM; i++) { 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); } }
Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> --- drivers/crypto/hisilicon/zip/zip_crypto.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)