[edk2-devel] [edk2-platforms PATCH 7/8] Marvell/Drivers: Pp2Dxe: Fix Pp2SnpReset

Marcin Wojtas posted 8 patches 3 years, 11 months ago
[edk2-devel] [edk2-platforms PATCH 7/8] Marvell/Drivers: Pp2Dxe: Fix Pp2SnpReset
Posted by Marcin Wojtas 3 years, 11 months ago
This patch adds missing parameter's and SNP instance
status checks.

igned-off-by: Marcin Wojtas <mw@semihalf.com>
---
 Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 27 ++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
index deb3f34625..841a1c8f84 100644
--- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
+++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
@@ -647,6 +647,33 @@ Pp2SnpReset (
   IN BOOLEAN                     ExtendedVerification
   )
 {
+  PP2DXE_CONTEXT *Pp2Context;
+
+  /* Check This Instance. */
+  if (This == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Pp2Context = INSTANCE_FROM_SNP (This);
+
+  /* Check that driver was started and initialized. */
+  if (This->Mode->State != EfiSimpleNetworkInitialized) {
+    switch (This->Mode->State) {
+    case EfiSimpleNetworkStopped:
+      DEBUG ((DEBUG_WARN, "Pp2Dxe%d: not started\n", Pp2Context->Instance));
+      return EFI_NOT_STARTED;
+    case EfiSimpleNetworkStarted:
+      DEBUG ((DEBUG_WARN, "Pp2Dxe%d: not initialized\n", Pp2Context->Instance));
+      return EFI_DEVICE_ERROR;
+    default:
+      DEBUG ((DEBUG_WARN,
+        "Pp2Dxe%d: wrong state: %u\n",
+        Pp2Context->Instance,
+        This->Mode->State));
+      return EFI_DEVICE_ERROR;
+    }
+  }
+
   return EFI_SUCCESS;
 }
 
-- 
2.29.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87546): https://edk2.groups.io/g/devel/message/87546
Mute This Topic: https://groups.io/mt/89776258/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-