Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4198299pxj; Tue, 11 May 2021 23:30:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL+viELdY9632kbXj4HQE07Q/v0Si/57Pz4Qjq3EePcNFSVVxlP4rTUKqzmPsIelmYMdeh X-Received: by 2002:a50:d54c:: with SMTP id f12mr18182271edj.301.1620801052034; Tue, 11 May 2021 23:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620801052; cv=none; d=google.com; s=arc-20160816; b=W4gSHSSiQl/lYPkOgl4/Hca2sj3GW+n4gz2wbgJlQP9m6Yafxz/bTddNF7khdP9Cvi zkPBQiEg1HzWhKeAIqri6WV41KfQUh/eKojx9irujbJzp5ifbqYC/utmOitYmIr5cIwl 350EvMwlHYk04b4BbDhWYSpbCgTVybo2so/g4cARnhoHn+7j69US5Mmum8qpqA3H31BY BFF5rGrT5RFCGppTYAQEZN9m93rANbtJTNZi8+0TE6CMT6+Rj+9TchDct+9Tis8qumiO NpLdZ2q59ZTKiEEZcNYi1aIuHE24QI9o3xrAeH4ucGxqHVbQUA6CHHTYvOeoA0ya1gH/ mYnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=11kzTFOUj/+bXi/zqtL4LsOsN9AuO6EDIyLGXsoQKXY=; b=DJHNuRVTz9HEFXKjo3vlC9kazSC8UpaOZLtsLLAf2xFUlT9rvbCsPLvWa+mBKPxR0l 1tEG4NYC0M9iwWE8KsIyqjbRIjCCWVxvNkfdV4rUGnSOlsXpDbwd1PR+1d9TfUo/wegp XwUXlzJw+6B+t/OwdodE+Wuv8pFLCRK5EZpg+x2tf3zjvFyExY4axJWKpRtEyz2l+vWV HNFz27TMC5wPHjOTtYUuhh2Bg5bUfWVGaQCnIgp5wGL6TeuPMIrjj7YQv9KKBsQyvahE qBxJAkOuh3lGh9PpqVtS/9uSjsUDUeUtmf9RH7wbnkh+S3H2YWgzoNTwsBSEx2D7s2LR NfQQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si18176370edu.170.2021.05.11.23.30.28; Tue, 11 May 2021 23:30:52 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230160AbhELGbb (ORCPT + 99 others); Wed, 12 May 2021 02:31:31 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2790 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230145AbhELGb2 (ORCPT ); Wed, 12 May 2021 02:31:28 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Fg4ZS35fSzmgKm; Wed, 12 May 2021 14:26:56 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Wed, 12 May 2021 14:30:09 +0800 From: Hui Tang To: , CC: , , , Subject: [PATCH v2 3/8] crypto: hisilicon/hpre - replace macro with inline function Date: Wed, 12 May 2021 14:27:06 +0800 Message-ID: <1620800831-53346-4-git-send-email-tanghui20@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1620800831-53346-1-git-send-email-tanghui20@huawei.com> References: <1620800831-53346-1-git-send-email-tanghui20@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Functional macro lacks type checking, which is not as strict as function call checking. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 47a169c..1e7d1fb 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -87,11 +87,6 @@ #define HPRE_QM_PM_FLR BIT(11) #define HPRE_QM_SRIOV_FLR BIT(12) -#define HPRE_CLUSTERS_NUM(qm) \ - (((qm)->ver >= QM_HW_V3) ? HPRE_CLUSTERS_NUM_V3 : HPRE_CLUSTERS_NUM_V2) -#define HPRE_CLUSTER_CORE_MASK(qm) \ - (((qm)->ver >= QM_HW_V3) ? HPRE_CLUSTER_CORE_MASK_V3 :\ - HPRE_CLUSTER_CORE_MASK_V2) #define HPRE_VIA_MSI_DSM 1 #define HPRE_SQE_MASK_OFFSET 8 #define HPRE_SQE_MASK_LEN 24 @@ -251,6 +246,18 @@ static u32 vfs_num; module_param_cb(vfs_num, &vfs_num_ops, &vfs_num, 0444); MODULE_PARM_DESC(vfs_num, "Number of VFs to enable(1-63), 0(default)"); +static inline int hpre_cluster_num(struct hisi_qm *qm) +{ + return (qm->ver >= QM_HW_V3) ? HPRE_CLUSTERS_NUM_V3 : + HPRE_CLUSTERS_NUM_V2; +} + +static inline int hpre_cluster_core_mask(struct hisi_qm *qm) +{ + return (qm->ver >= QM_HW_V3) ? + HPRE_CLUSTER_CORE_MASK_V3 : HPRE_CLUSTER_CORE_MASK_V2; +} + struct hisi_qp *hpre_create_qp(u8 type) { int node = cpu_to_node(smp_processor_id()); @@ -317,8 +324,8 @@ static int hpre_cfg_by_dsm(struct hisi_qm *qm) static int hpre_set_cluster(struct hisi_qm *qm) { - u32 cluster_core_mask = HPRE_CLUSTER_CORE_MASK(qm); - u8 clusters_num = HPRE_CLUSTERS_NUM(qm); + u32 cluster_core_mask = hpre_cluster_core_mask(qm); + u8 clusters_num = hpre_cluster_num(qm); struct device *dev = &qm->pdev->dev; unsigned long offset; u32 val = 0; @@ -424,7 +431,7 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) static void hpre_cnt_regs_clear(struct hisi_qm *qm) { - u8 clusters_num = HPRE_CLUSTERS_NUM(qm); + u8 clusters_num = hpre_cluster_num(qm); unsigned long offset; int i; @@ -677,7 +684,7 @@ static int hpre_pf_comm_regs_debugfs_init(struct hisi_qm *qm) static int hpre_cluster_debugfs_init(struct hisi_qm *qm) { - u8 clusters_num = HPRE_CLUSTERS_NUM(qm); + u8 clusters_num = hpre_cluster_num(qm); struct device *dev = &qm->pdev->dev; char buf[HPRE_DBGFS_VAL_MAX_LEN]; struct debugfs_regset32 *regset; -- 2.8.1