Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1400689ybj; Fri, 8 May 2020 00:01:15 -0700 (PDT) X-Google-Smtp-Source: APiQypLK3BPb9K9ONKiwdhADZiK329RltYh1wU5pb4jXJx664Tl4SiH4reGVY7GdRDdJ1VPkAS/6 X-Received: by 2002:aa7:c0d2:: with SMTP id j18mr959352edp.283.1588921275232; Fri, 08 May 2020 00:01:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588921275; cv=none; d=google.com; s=arc-20160816; b=b5Cp32Tdj6BfILkFnB/Xja0/uJZpuIPT4knmk8qMhck2tAuhj4ciLthEKSLjZLdU8d PlJPjEOZpYrLEfPGdvrDWgHaYle5H3ZZLFT+drjIYnkCmDewqwRuOTIhwryuMkCjMOOc V2LWs3jK0oVSUSCeFsGnJH95nmpgTaw0OBPRJa/zT7S+7oMJeME8fTfuMeDB99qXdnks NCHNH85+pEDBjF4c/7pRy1v8AHE6XMkrvUxmEgFhQ1jug+90TQZThW2eL7Uin25XGiO8 C3tRUbmeaV/RaTDBJ3MRIHlyQXB9hdXaUoi8jWTtv44YYAZnD05DkkksGgnH6Ux7d+LI 4IiA== 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=lj2JXQQBa6rcKh1jNFrBZIZqb9mRd2e1jZpdHBAh0jM=; b=QACM4zshTycO8/7tKkoE0BILvPNfBRJtMaGHSp7fZQU5FfJLVY7/MbY1w1M0ln/R8v eAKaiw2ZJuD1aUCClxJAXo1npYTBZxQiBviJ7EQt+a0rV3EDESFJi972AmZqjZxRSqYv WwYBkF+K7GVmTdiJt8WEa3I+sIV314pIIhQvsTlDyn50f45i5FTAN60ICDlO7K1tH3Gn vE2yG7IRaXTDlEkIF2PY0ekJWFwCYCUW6LqUW7csRzPuvkqZx6A2ajPVydCspUfJjnj0 fLa4YD9KHCRCNkuJDGs58kAjeiBTn/vOdOfBf51oCz7nELeZPbHgbwCCYcuK5W7mYRfH zvMw== 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 j13si472172edt.371.2020.05.08.00.00.49; Fri, 08 May 2020 00:01:15 -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 S1726797AbgEHG7H (ORCPT + 99 others); Fri, 8 May 2020 02:59:07 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:42786 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726767AbgEHG7F (ORCPT ); Fri, 8 May 2020 02:59:05 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 14EBC3E0DC26F2AD3C51; Fri, 8 May 2020 14:59:00 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 8 May 2020 14:58:52 +0800 From: Shukun Tan To: , CC: , , Subject: [PATCH 03/13] crypto: hisilicon/zip - modify the ZIP probe process Date: Fri, 8 May 2020 14:57:38 +0800 Message-ID: <1588921068-20739-4-git-send-email-tanshukun1@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1588921068-20739-1-git-send-email-tanshukun1@huawei.com> References: <1588921068-20739-1-git-send-email-tanshukun1@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 From: Longfang Liu Misc fixes on coding style: 1.Merge QM initialization code into a function 2.Merge QM's PF and VF initialization into a function Signed-off-by: Longfang Liu Signed-off-by: Zaibo Xu Signed-off-by: Shukun Tan Reviewed-by: Zhou Wang --- drivers/crypto/hisilicon/zip/zip_main.c | 60 +++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index 37db11f..4672eaa 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -701,23 +701,14 @@ static int hisi_zip_pf_probe_init(struct hisi_zip *hisi_zip) return 0; } -static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) +static int hisi_zip_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) { - struct hisi_zip *hisi_zip; enum qm_hw_ver rev_id; - struct hisi_qm *qm; - int ret; rev_id = hisi_qm_get_hw_version(pdev); if (rev_id == QM_HW_UNKNOWN) return -EINVAL; - hisi_zip = devm_kzalloc(&pdev->dev, sizeof(*hisi_zip), GFP_KERNEL); - if (!hisi_zip) - return -ENOMEM; - pci_set_drvdata(pdev, hisi_zip); - - qm = &hisi_zip->qm; qm->use_dma_api = true; qm->pdev = pdev; qm->ver = rev_id; @@ -725,13 +716,16 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) qm->algs = "zlib\ngzip"; qm->sqe_size = HZIP_SQE_SIZE; qm->dev_name = hisi_zip_name; - qm->fun_type = (pdev->device == PCI_DEVICE_ID_ZIP_PF) ? QM_HW_PF : - QM_HW_VF; - ret = hisi_qm_init(qm); - if (ret) { - dev_err(&pdev->dev, "Failed to init qm!\n"); - return ret; - } + qm->fun_type = (pdev->device == PCI_DEVICE_ID_ZIP_PF) ? + QM_HW_PF : QM_HW_VF; + + return hisi_qm_init(qm); +} + +static int hisi_zip_probe_init(struct hisi_zip *hisi_zip) +{ + struct hisi_qm *qm = &hisi_zip->qm; + int ret; if (qm->fun_type == QM_HW_PF) { ret = hisi_zip_pf_probe_init(hisi_zip); @@ -754,7 +748,36 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) qm->qp_num = HZIP_QUEUE_NUM_V1 - HZIP_PF_DEF_Q_NUM; } else if (qm->ver == QM_HW_V2) /* v2 starts to support get vft by mailbox */ - hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num); + return hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num); + } + + return 0; +} + +static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct hisi_zip *hisi_zip; + struct hisi_qm *qm; + int ret; + + hisi_zip = devm_kzalloc(&pdev->dev, sizeof(*hisi_zip), GFP_KERNEL); + if (!hisi_zip) + return -ENOMEM; + + pci_set_drvdata(pdev, hisi_zip); + + qm = &hisi_zip->qm; + + ret = hisi_zip_qm_init(qm, pdev); + if (ret) { + pci_err(pdev, "Failed to init ZIP QM (%d)!\n", ret); + return ret; + } + + ret = hisi_zip_probe_init(hisi_zip); + if (ret) { + pci_err(pdev, "Failed to probe (%d)!\n", ret); + goto err_qm_uninit; } ret = hisi_qm_start(qm); @@ -787,6 +810,7 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) hisi_qm_stop(qm); err_qm_uninit: hisi_qm_uninit(qm); + return ret; } -- 2.7.4