Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4105391pxj; Tue, 11 May 2021 20:38:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJws9WJJuCRyRdiY7DJWzR0UM+kb9ooGea9W4ktudDKvAQDsbs9gCVkSI9pyqDDQI0QZOqN3 X-Received: by 2002:a17:906:a055:: with SMTP id bg21mr35024139ejb.554.1620790696545; Tue, 11 May 2021 20:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620790696; cv=none; d=google.com; s=arc-20160816; b=IlT+fJXA0h58awDWugeKpUCtzHIS/5FmDyqGI+LI/a7TF/7jjkEkBq814cfhVuS9w5 6emnz1I/eK+2jEed4BpYMm8ni+lwKJNlCKmPrDl+Ya96MwuB7BGGv+1PB1Fx09f0vwZH dqdiRNAm6+SJ+zPkwJFw2Gz51JgSRGu1rAi17RYzZ0Om+Xtzm+Bp/jvSYUYy0PEasYwG frYOn93GNAH8sfR5WHeq8UfPaPICcDvmShC6gnZzD921fcQjNe5D3yeE7vi0R8C4mTqU ORUIjEgE1LzacWHduEm/h2W/FJ7o9WKBgXJj6Dt8bi5pubwnBM7ckwJZ5+5OU+MI1sCQ ezYw== 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=zQAT/AywV0KZBMlRfimDvZnzxDcegeDGCxj8TREi4qS4RmuoOwNJ4b6LZtdHAHZFZX gm/dc6rtSV/h8Rme1qNmYIXSN9l235RehyYZcQfn6pVB/jeaN7f8f0CwINyPe4k9lPi8 V7XxNvzChOYcUb4tyZBSYquIqRBILRQlhlguMF9BSmUQ0fyDNgori8zXloK/sJrmHPhK iceH6R1ueL0Hkyflm7RjaaDZKBszeoLMhj2f/K35/2ndXGOBa9c2SpTQgncD8DrnMyiB kwKiyXIpSU5bDtpUq6XZAHoe19YILEOf71eE1uhDJtsjD41OPzxXNfdlfCSyTjOSKus1 uDxQ== 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 f16si17002295edy.298.2021.05.11.20.37.42; Tue, 11 May 2021 20:38:16 -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 S230109AbhELDir (ORCPT + 99 others); Tue, 11 May 2021 23:38:47 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:2303 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230012AbhELDir (ORCPT ); Tue, 11 May 2021 23:38:47 -0400 Received: from dggeml751-chm.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Fg0kC4r5Tz19MgS; Wed, 12 May 2021 11:33:23 +0800 (CST) Received: from dggemi760-chm.china.huawei.com (10.1.198.146) by dggeml751-chm.china.huawei.com (10.1.199.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 12 May 2021 11:37:38 +0800 Received: from localhost.localdomain (10.67.165.24) by dggemi760-chm.china.huawei.com (10.1.198.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 12 May 2021 11:37:38 +0800 From: Hui Tang To: , CC: , , , Subject: [PATCH v2 3/8] crypto: hisilicon/hpre - replace macro with inline function Date: Wed, 12 May 2021 11:34:26 +0800 Message-ID: <1620790471-16621-4-git-send-email-tanghui20@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1620790471-16621-1-git-send-email-tanghui20@huawei.com> References: <1620790471-16621-1-git-send-email-tanghui20@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggemi760-chm.china.huawei.com (10.1.198.146) 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