@@ -623,6 +623,22 @@ static int32_t executeCommand(struct mtd_k64f_data *context)
623623}
624624
625625#if ASYNC_OPS
626+ static inline void launchCommandFromIRQ (const struct mtd_k64f_data * context )
627+ {
628+ launchCommand ();
629+
630+ while (!controllerCurrentlyBusy () && !failedWithAccessError () && !failedWithProtectionError ());
631+ if (failedWithAccessError () || failedWithProtectionError ()) {
632+ clearErrorStatusBits ();
633+ if (context -> commandCompletionCallback ) {
634+ context -> commandCompletionCallback (ARM_DRIVER_ERROR_PARAMETER , context -> currentCommand );
635+ }
636+ return ;
637+ }
638+
639+ enableCommandCompletionInterrupt ();
640+ }
641+
626642static void ftfe_ccie_irq_handler (void )
627643{
628644 disbleCommandCompletionInterrupt ();
@@ -654,18 +670,7 @@ static void ftfe_ccie_irq_handler(void)
654670
655671 /* start the successive program operation */
656672 setupNextProgramData (context );
657- launchCommand ();
658-
659- while (!controllerCurrentlyBusy () && !failedWithAccessError () && !failedWithProtectionError ());
660- if (failedWithAccessError () || failedWithProtectionError ()) {
661- clearErrorStatusBits ();
662- if (context -> commandCompletionCallback ) {
663- context -> commandCompletionCallback (ARM_DRIVER_ERROR_PARAMETER , ARM_STORAGE_OPERATION_PROGRAM_DATA );
664- }
665- return ;
666- }
667-
668- enableCommandCompletionInterrupt ();
673+ launchCommandFromIRQ (context );
669674 break ;
670675
671676 case ARM_STORAGE_OPERATION_ERASE :
@@ -677,18 +682,7 @@ static void ftfe_ccie_irq_handler(void)
677682 }
678683
679684 setupNextErase (context );
680- launchCommand ();
681-
682- while (!controllerCurrentlyBusy () && !failedWithAccessError () && !failedWithProtectionError ());
683- if (failedWithAccessError () || failedWithProtectionError ()) {
684- clearErrorStatusBits ();
685- if (context -> commandCompletionCallback ) {
686- context -> commandCompletionCallback (ARM_DRIVER_ERROR_PARAMETER , ARM_STORAGE_OPERATION_ERASE );
687- }
688- return ;
689- }
690-
691- enableCommandCompletionInterrupt ();
685+ launchCommandFromIRQ (context );
692686 break ;
693687
694688 default :
0 commit comments