Skip to content

Commit 5f3a2a5

Browse files
Longfang Liuherbertx
authored andcommitted
crypto: hisilicon/hpre - modify the HPRE probe process
Misc fixes on coding style: 1.Merge pre-initialization and initialization of QM 2.Package the initialization of QM's PF and VF into a function Signed-off-by: Longfang Liu <[email protected]> Signed-off-by: Zaibo Xu <[email protected]> Signed-off-by: Shukun Tan <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 1861423 commit 5f3a2a5

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

drivers/crypto/hisilicon/hpre/hpre_main.c

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ static void hpre_debugfs_exit(struct hpre *hpre)
666666
debugfs_remove_recursive(qm->debug.debug_root);
667667
}
668668

669-
static int hpre_qm_pre_init(struct hisi_qm *qm, struct pci_dev *pdev)
669+
static int hpre_qm_init(struct hisi_qm *qm, struct pci_dev *pdev)
670670
{
671671
enum qm_hw_ver rev_id;
672672

@@ -685,13 +685,14 @@ static int hpre_qm_pre_init(struct hisi_qm *qm, struct pci_dev *pdev)
685685
qm->dev_name = hpre_name;
686686
qm->fun_type = (pdev->device == HPRE_PCI_DEVICE_ID) ?
687687
QM_HW_PF : QM_HW_VF;
688+
688689
if (pdev->is_physfn) {
689690
qm->qp_base = HPRE_PF_DEF_Q_BASE;
690691
qm->qp_num = hpre_pf_q_num;
691692
}
692693
qm->use_dma_api = true;
693694

694-
return 0;
695+
return hisi_qm_init(qm);
695696
}
696697

697698
static void hpre_log_hw_error(struct hisi_qm *qm, u32 err_sts)
@@ -766,6 +767,20 @@ static int hpre_pf_probe_init(struct hpre *hpre)
766767
return 0;
767768
}
768769

770+
static int hpre_probe_init(struct hpre *hpre)
771+
{
772+
struct hisi_qm *qm = &hpre->qm;
773+
int ret = -ENODEV;
774+
775+
if (qm->fun_type == QM_HW_PF)
776+
ret = hpre_pf_probe_init(hpre);
777+
else if (qm->fun_type == QM_HW_VF && qm->ver == QM_HW_V2)
778+
/* v2 starts to support get vft by mailbox */
779+
ret = hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num);
780+
781+
return ret;
782+
}
783+
769784
static int hpre_probe(struct pci_dev *pdev, const struct pci_device_id *id)
770785
{
771786
struct hisi_qm *qm;
@@ -779,23 +794,16 @@ static int hpre_probe(struct pci_dev *pdev, const struct pci_device_id *id)
779794
pci_set_drvdata(pdev, hpre);
780795

781796
qm = &hpre->qm;
782-
ret = hpre_qm_pre_init(qm, pdev);
783-
if (ret)
784-
return ret;
785-
786-
ret = hisi_qm_init(qm);
787-
if (ret)
797+
ret = hpre_qm_init(qm, pdev);
798+
if (ret) {
799+
pci_err(pdev, "Failed to init HPRE QM (%d)!\n", ret);
788800
return ret;
801+
}
789802

790-
if (pdev->is_physfn) {
791-
ret = hpre_pf_probe_init(hpre);
792-
if (ret)
793-
goto err_with_qm_init;
794-
} else if (qm->fun_type == QM_HW_VF && qm->ver == QM_HW_V2) {
795-
/* v2 starts to support get vft by mailbox */
796-
ret = hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num);
797-
if (ret)
798-
goto err_with_qm_init;
803+
ret = hpre_probe_init(hpre);
804+
if (ret) {
805+
pci_err(pdev, "Failed to probe (%d)!\n", ret);
806+
goto err_with_qm_init;
799807
}
800808

801809
ret = hisi_qm_start(qm);

0 commit comments

Comments
 (0)