[MLX4] add VPD data to bus interface. [mlnx: 4456]
[mirror/winof/.git] / hw / mlx4 / kernel / bus / drv / drv.c
index 70b46ba..568685b 100644 (file)
@@ -437,7 +437,9 @@ EvtDeviceD0Entry(
 \r
        // start card (needed after Hibernetion)\r
        if (PreviousState > WdfPowerDeviceD0)\r
-               __start_card( Device, p_fdo );\r
+               status = __start_card( Device, p_fdo );\r
+       if ( !NT_SUCCESS( status ) ) \r
+               goto err;\r
        mdev = pdev->dev;\r
 \r
        // create child device\r
@@ -746,6 +748,7 @@ EvtPrepareHardware(
 {\r
        NTSTATUS status;\r
        PFDO_DEVICE_DATA p_fdo  = FdoGetData(Device);\r
+       struct pci_dev *pdev = &p_fdo->pci_dev;\r
 \r
        MLX4_ENTER(MLX4_DBG_DRV);\r
 \r
@@ -758,6 +761,19 @@ EvtPrepareHardware(
 \r
        // start the card\r
        status = __start_card(Device, p_fdo );\r
+\r
+       // get VPD \r
+       \r
+       if( NT_SUCCESS( status ) ) {\r
+               status = pci_get_vpd( &pdev->bus_pci_ifc, \r
+                       &pdev->pci_cfg_space, &pdev->vpd, &pdev->vpd_size );\r
+               if( !NT_SUCCESS( status ) )\r
+               {\r
+                       MLX4_PRINT(TRACE_LEVEL_ERROR, MLX4_DBG_DRV, \r
+                               ("pci_get_vpd failed,  status=0x%x\n", status));\r
+                       goto err;\r
+               }\r
+       }\r
        \r
 err:\r
        MLX4_EXIT( MLX4_DBG_DRV );\r
@@ -781,11 +797,17 @@ EvtReleaseHardware(
        )\r
 {\r
        PFDO_DEVICE_DATA p_fdo  = FdoGetData(Device);\r
+       struct pci_dev *pdev = &p_fdo->pci_dev;\r
 \r
        UNUSED_PARAM(ResourcesTranslated);\r
 \r
        MLX4_ENTER(MLX4_DBG_DRV);\r
 \r
+       if ( pdev->vpd ) {\r
+               kfree( pdev->vpd );\r
+               pdev->vpd = NULL;\r
+               pdev->vpd_size = 0;\r
+       }\r
        __stop_card( p_fdo );\r
        __put_resources( p_fdo );\r
 \r