Skip to content

Commit cfd66a6

Browse files
Longfang Liuherbertx
authored andcommitted
crypto: hisilicon/zip - modify the ZIP probe process
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 <[email protected]> Signed-off-by: Zaibo Xu <[email protected]> Signed-off-by: Shukun Tan <[email protected]> Reviewed-by: Zhou Wang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 5f3a2a5 commit cfd66a6

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

drivers/crypto/hisilicon/zip/zip_main.c

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -701,37 +701,31 @@ static int hisi_zip_pf_probe_init(struct hisi_zip *hisi_zip)
701701
return 0;
702702
}
703703

704-
static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id)
704+
static int hisi_zip_qm_init(struct hisi_qm *qm, struct pci_dev *pdev)
705705
{
706-
struct hisi_zip *hisi_zip;
707706
enum qm_hw_ver rev_id;
708-
struct hisi_qm *qm;
709-
int ret;
710707

711708
rev_id = hisi_qm_get_hw_version(pdev);
712709
if (rev_id == QM_HW_UNKNOWN)
713710
return -EINVAL;
714711

715-
hisi_zip = devm_kzalloc(&pdev->dev, sizeof(*hisi_zip), GFP_KERNEL);
716-
if (!hisi_zip)
717-
return -ENOMEM;
718-
pci_set_drvdata(pdev, hisi_zip);
719-
720-
qm = &hisi_zip->qm;
721712
qm->use_dma_api = true;
722713
qm->pdev = pdev;
723714
qm->ver = rev_id;
724715

725716
qm->algs = "zlib\ngzip";
726717
qm->sqe_size = HZIP_SQE_SIZE;
727718
qm->dev_name = hisi_zip_name;
728-
qm->fun_type = (pdev->device == PCI_DEVICE_ID_ZIP_PF) ? QM_HW_PF :
729-
QM_HW_VF;
730-
ret = hisi_qm_init(qm);
731-
if (ret) {
732-
dev_err(&pdev->dev, "Failed to init qm!\n");
733-
return ret;
734-
}
719+
qm->fun_type = (pdev->device == PCI_DEVICE_ID_ZIP_PF) ?
720+
QM_HW_PF : QM_HW_VF;
721+
722+
return hisi_qm_init(qm);
723+
}
724+
725+
static int hisi_zip_probe_init(struct hisi_zip *hisi_zip)
726+
{
727+
struct hisi_qm *qm = &hisi_zip->qm;
728+
int ret;
735729

736730
if (qm->fun_type == QM_HW_PF) {
737731
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)
754748
qm->qp_num = HZIP_QUEUE_NUM_V1 - HZIP_PF_DEF_Q_NUM;
755749
} else if (qm->ver == QM_HW_V2)
756750
/* v2 starts to support get vft by mailbox */
757-
hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num);
751+
return hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num);
752+
}
753+
754+
return 0;
755+
}
756+
757+
static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id)
758+
{
759+
struct hisi_zip *hisi_zip;
760+
struct hisi_qm *qm;
761+
int ret;
762+
763+
hisi_zip = devm_kzalloc(&pdev->dev, sizeof(*hisi_zip), GFP_KERNEL);
764+
if (!hisi_zip)
765+
return -ENOMEM;
766+
767+
pci_set_drvdata(pdev, hisi_zip);
768+
769+
qm = &hisi_zip->qm;
770+
771+
ret = hisi_zip_qm_init(qm, pdev);
772+
if (ret) {
773+
pci_err(pdev, "Failed to init ZIP QM (%d)!\n", ret);
774+
return ret;
775+
}
776+
777+
ret = hisi_zip_probe_init(hisi_zip);
778+
if (ret) {
779+
pci_err(pdev, "Failed to probe (%d)!\n", ret);
780+
goto err_qm_uninit;
758781
}
759782

760783
ret = hisi_qm_start(qm);
@@ -787,6 +810,7 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id)
787810
hisi_qm_stop(qm);
788811
err_qm_uninit:
789812
hisi_qm_uninit(qm);
813+
790814
return ret;
791815
}
792816

0 commit comments

Comments
 (0)