Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3050761pxk; Mon, 7 Sep 2020 01:27:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz081lJL18U8iRpZzCwsxFJVFxLhr+BM74xs0rdkHusiQlrKsR9226zD92/tmDukQ+YCth8 X-Received: by 2002:a17:906:729e:: with SMTP id b30mr19529768ejl.479.1599467247265; Mon, 07 Sep 2020 01:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599467247; cv=none; d=google.com; s=arc-20160816; b=HlX6OFHfkHMKd6eBOPNMfpXyAzE+xLGyr85ombGmW2GKD/RownZmcXaOORegSUnPhP XmjZ8Fk+MTD0ZT2zhqtgy7kQYe5uYeMlOt4JVIHlPYus4GUVqhKuzPh3jQbnZS4/OMjF BJkj+YlRGe/nuqRG6EkMaV1vYRT0Vhi6nHo5AZ54j3vVB5YnalcXIzgt/CInnmmzjJQV uyT7Qb7gOGUMyfJNWieA2GfyKNVtRLm5uEIBl/IdmuTunWWYJgHFysmevlAYkj3qFj4G HjxozOjUvVHNN9VYmQkQ+iEw3wm4mJpmR4x4hrP7IAwGF00/LYKMva7waC2mFTEEslbW ITvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=spisvv0PLQb/0MrL2zFBJQ8EwGEX8n7T5Gakt4IejsE=; b=atGOsvfFZb01ZUxuL7vpKDiv6YgNaATit31jaBNqHJZZ9m6JSd/7DkQJ4vgxm2oMdT g0eUCtyr1xupz2fw/vFeP6avrE2+HNGSpZ4TTg6ZZH6KZr1l9TdiBgKb2+ZS8SkYomcO EaPuuSYf5p3F4TIQ+pSNb+tAFUq7jh1bmkS2Awk0gg8i0g+c3/VSf+dsIB5ns4b4nVnl +aiSEYrpS/lU9El2A7hANDNX1olABAx0e8tyyAa/Zt3MYoqwbszJzf7vTcvGijrnSwMs mt+noAJ0UcDe57BX89PydY/dI2fqABccFf+CRUn0ljvcNqU6pFLCR0IOZisigo63XjDe qGZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s3si9403167ejv.383.2020.09.07.01.27.02; Mon, 07 Sep 2020 01:27:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727954AbgIGIZz (ORCPT + 99 others); Mon, 7 Sep 2020 04:25:55 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:10781 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727943AbgIGIYj (ORCPT ); Mon, 7 Sep 2020 04:24:39 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D6AE1E99CC644FB78895; Mon, 7 Sep 2020 16:24:34 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Mon, 7 Sep 2020 16:24:25 +0800 From: Yang Shen To: , CC: , , , Subject: [PATCH v2 05/10] crypto: hisilicon/zip - use a enum parameter instead of some macros Date: Mon, 7 Sep 2020 16:21:57 +0800 Message-ID: <1599466922-10323-6-git-send-email-shenyang39@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599466922-10323-1-git-send-email-shenyang39@huawei.com> References: <1599466922-10323-1-git-send-email-shenyang39@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Macros 'QPC_COMP', 'QPC_DECOMP' and 'HZIP_CTX_Q_NUM' are relative and incremental. So, use an enum instead. Signed-off-by: Yang Shen Reviewed-by: Zhou Wang --- drivers/crypto/hisilicon/zip/zip_crypto.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c index aba1600..c2ea849 100644 --- a/drivers/crypto/hisilicon/zip/zip_crypto.c +++ b/drivers/crypto/hisilicon/zip/zip_crypto.c @@ -19,7 +19,6 @@ #define GZIP_HEAD_FEXTRA_XLEN 2 #define GZIP_HEAD_FHCRC_SIZE 2 -#define HZIP_CTX_Q_NUM 2 #define HZIP_GZIP_HEAD_BUF 256 #define HZIP_ALG_PRIORITY 300 #define HZIP_SGL_SGE_NR 10 @@ -32,6 +31,12 @@ enum hisi_zip_alg_type { HZIP_ALG_TYPE_DECOMP = 1, }; +enum { + HZIP_QPC_COMP, + HZIP_QPC_DECOMP, + HZIP_CTX_Q_NUM +}; + #define COMP_NAME_TO_TYPE(alg_name) \ (!strcmp((alg_name), "zlib-deflate") ? HZIP_ALG_TYPE_ZLIB : \ !strcmp((alg_name), "gzip") ? HZIP_ALG_TYPE_GZIP : 0) \ @@ -71,8 +76,6 @@ struct hisi_zip_qp_ctx { }; struct hisi_zip_ctx { -#define QPC_COMP 0 -#define QPC_DECOMP 1 struct hisi_zip_qp_ctx qp_ctx[HZIP_CTX_Q_NUM]; }; @@ -264,11 +267,11 @@ static int hisi_zip_create_req_q(struct hisi_zip_ctx *ctx) return 0; err_free_loop1: - kfree(ctx->qp_ctx[QPC_DECOMP].req_q.req_bitmap); + kfree(ctx->qp_ctx[HZIP_QPC_DECOMP].req_q.req_bitmap); err_free_loop0: - kfree(ctx->qp_ctx[QPC_COMP].req_q.q); + kfree(ctx->qp_ctx[HZIP_QPC_COMP].req_q.q); err_free_bitmap: - kfree(ctx->qp_ctx[QPC_COMP].req_q.req_bitmap); + kfree(ctx->qp_ctx[HZIP_QPC_COMP].req_q.req_bitmap); return ret; } @@ -303,8 +306,8 @@ static int hisi_zip_create_sgl_pool(struct hisi_zip_ctx *ctx) return 0; err_free_sgl_pool0: - hisi_acc_free_sgl_pool(&ctx->qp_ctx[QPC_COMP].qp->qm->pdev->dev, - ctx->qp_ctx[QPC_COMP].sgl_pool); + hisi_acc_free_sgl_pool(&ctx->qp_ctx[HZIP_QPC_COMP].qp->qm->pdev->dev, + ctx->qp_ctx[HZIP_QPC_COMP].sgl_pool); return -ENOMEM; } @@ -539,7 +542,7 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, static int hisi_zip_acompress(struct acomp_req *acomp_req) { struct hisi_zip_ctx *ctx = crypto_tfm_ctx(acomp_req->base.tfm); - struct hisi_zip_qp_ctx *qp_ctx = &ctx->qp_ctx[QPC_COMP]; + struct hisi_zip_qp_ctx *qp_ctx = &ctx->qp_ctx[HZIP_QPC_COMP]; struct hisi_zip_req *req; int head_size; int ret; @@ -563,7 +566,7 @@ static int hisi_zip_acompress(struct acomp_req *acomp_req) static int hisi_zip_adecompress(struct acomp_req *acomp_req) { struct hisi_zip_ctx *ctx = crypto_tfm_ctx(acomp_req->base.tfm); - struct hisi_zip_qp_ctx *qp_ctx = &ctx->qp_ctx[QPC_DECOMP]; + struct hisi_zip_qp_ctx *qp_ctx = &ctx->qp_ctx[HZIP_QPC_DECOMP]; struct hisi_zip_req *req; size_t head_size; int ret; -- 2.7.4