Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp938638imi; Thu, 21 Jul 2022 14:00:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1stVdnYpQq4HimfmAOLJqPNef3qH4YZhePsc3bhwlpORKMmPKnNOeW8ju2h6nIc/1PSog83 X-Received: by 2002:a63:4e11:0:b0:419:e9dd:a867 with SMTP id c17-20020a634e11000000b00419e9dda867mr193325pgb.481.1658437213822; Thu, 21 Jul 2022 14:00:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658437213; cv=none; d=google.com; s=arc-20160816; b=u3pe0/lOOCpQYgfv3YnpW9fzt0t9zSXlrFJIFClH9J5vHPjelH4oyRm0aSZRVlpftf D4n2YC+Ffpreqb6PcapjTq747rEG4hMfcXyIQT7VAqFgxtq9A9q0bK85SOpeosWzvB9q am3uZRw45vD8yXn3SY0MmZSF11VEiIt1ApyYLdOZfCTSJpO5uRE6R9VpQaATycPN03kI jfUs9l3An1ERI22uNbhifshtnTA68Dm+Jtp+XbV1WdMrms0WCFiGHnB3ZkFBFvpbb4iy iu9QdehF5lcBxBGIs3HtsXq4t9DtEXeGthOhUbmTp1AwF0BXDQkNvXm90kFdhOac8/pw i8Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=5itYk0C+X8ll/IT7Kiun3BbeyG9dtS3CqYfcElmSywU=; b=0K9wCpeT8kdmvR+GnjSCa+6gIX/8+nhwwk43wZY8HVnfTwOXKN9Xk8KoKd34EhwOTB FTHhwvqNuj/XXmtUJSgdq55gIRgTXSKHUWhOP6ttB1jo6+a7q4hhQphm/GaxH3KS0t7F PN/0aKXmX2QzHigRgqTIdm9y1FRIF7LEPA6FSc4lM4VcEC2bWKjGarjua3sriE/yrqBo 5OIsRD3o8+k1t3pYNYpU550AXmDicgbjPgM7pHogwN7jLbypNfbS1z/ca+pFToBGGX5r h/OFXlm/4XrF7amSngN+Ik5ibhgvzvn3qqlKawvzSi7eyiJiGb9OyBLVnQ9eRJhFK0Kb 1a6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 3-20020a630003000000b0040cc5d2b9d7si3517981pga.596.2022.07.21.13.59.44; Thu, 21 Jul 2022 14:00:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233588AbiGUU7C (ORCPT + 99 others); Thu, 21 Jul 2022 16:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233072AbiGUU7C (ORCPT ); Thu, 21 Jul 2022 16:59:02 -0400 Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr [80.12.242.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 114428FD7B for ; Thu, 21 Jul 2022 13:59:01 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id EdG2oNF3UGDTnEdG2ovb82; Thu, 21 Jul 2022 22:58:59 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Thu, 21 Jul 2022 22:58:59 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Yang Shen , Zhou Wang , Herbert Xu , "David S. Miller" Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-crypto@vger.kernel.org Subject: [PATCH v2] crypto: hisilicon/zip: Use the bitmap API to allocate bitmaps Date: Thu, 21 Jul 2022 22:58:53 +0200 Message-Id: <456a8b00720d603221c8329c19e38b9f4d96d15a.1658437112.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 . Signed-off-by: Christophe JAILLET --- v1 -> v2 - add the missing include --- drivers/crypto/hisilicon/zip/zip_crypto.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c index 67869513e48c..ad35434a3fdb 100644 --- a/drivers/crypto/hisilicon/zip/zip_crypto.c +++ b/drivers/crypto/hisilicon/zip/zip_crypto.c @@ -2,6 +2,7 @@ /* Copyright (c) 2019 HiSilicon Limited. */ #include #include +#include #include #include #include "zip.h" @@ -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->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 +631,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 +645,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); } } -- 2.34.1