MdeModulePkg/SetupBrowser: Send discard info to driver when fail to submit

When fail to submit data and user discard the change, we should send
the discard info to driver with EFI_BROWSER_ACTION_CHANGED callback.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 2aded89..7547814 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -3275,6 +3275,7 @@
 

         Status = EFI_SUCCESS;

       }

+      SendDiscardInfoToDriver (FormSet,Form);

     } else {

       Status = EFI_UNSUPPORTED;

     }

@@ -3336,9 +3337,11 @@
   BOOLEAN                 HasInserted;

   FORM_BROWSER_STATEMENT  *Question;

   BOOLEAN                 SubmitFormSetFail;

+  BOOLEAN                 DiscardChange;

 

   HasInserted = FALSE;

   SubmitFormSetFail = FALSE;

+  DiscardChange     = FALSE;

 

   if (!IsNvUpdateRequiredForFormSet (FormSet)) {

     return EFI_SUCCESS;

@@ -3439,6 +3442,7 @@
       // If not in system level, just handl the save failed storage here.

       //

       if (ConfirmSaveFail (Form->FormTitle, FormSet->HiiHandle) == BROWSER_ACTION_DISCARD) {

+        DiscardChange = TRUE;

         Link = GetFirstNode (&FormSet->SaveFailStorageListHead);

         while (!IsNull (&FormSet->SaveFailStorageListHead, Link)) {

           FormSetStorage = FORMSET_STORAGE_FROM_SAVE_FAIL_LINK (Link);

@@ -3488,6 +3492,21 @@
   }

 

   //

+  // If user discard the change, send the discard info to driver.

+  //

+  if (DiscardChange) {

+    Link = GetFirstNode (&FormSet->FormListHead);

+    while (!IsNull (&FormSet->FormListHead, Link)) {

+      Form = FORM_BROWSER_FORM_FROM_LINK (Link);

+      Link = GetNextNode (&FormSet->FormListHead, Link);

+      //

+      // Call callback with Changed type to inform the driver.

+      //

+      SendDiscardInfoToDriver (FormSet, Form);

+    }

+  }

+

+  //

   // 5. Update the NV flag.

   // 

   ValueChangeResetFlagUpdate(TRUE, FormSet, NULL);

@@ -3606,6 +3625,16 @@
         }

       }

 

+      Link = GetFirstNode (&LocalFormSet->FormListHead);

+      while (!IsNull (&LocalFormSet->FormListHead, Link)) {

+        Form = FORM_BROWSER_FORM_FROM_LINK (Link);

+        Link = GetNextNode (&LocalFormSet->FormListHead, Link);

+        //

+        // Call callback with Changed type to inform the driver.

+        //

+        SendDiscardInfoToDriver (LocalFormSet, Form);

+      }

+

       if (!IsHiiHandleInBrowserContext (LocalFormSet->HiiHandle)) {

         CleanBrowserStorage(LocalFormSet);

         RemoveEntryList (&LocalFormSet->Link);