@@ -686,6 +686,12 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
686686 goto out_ret_state ;
687687 }
688688
689+ /*
690+ * The state transitions are encoded in a state machine crossing
691+ * the edges in this switch statement.
692+ */
693+ switch (host -> busy_state ) {
694+
689695 /*
690696 * Before unmasking for the busy end IRQ, confirm that the
691697 * command was sent successfully. To keep track of having a
@@ -696,7 +702,7 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
696702 * it starts signaling busy on DAT0, hence re-read the
697703 * MMCISTATUS register here, to allow the busy bit to be set.
698704 */
699- if ( host -> busy_state == MMCI_BUSY_DONE ) {
705+ case MMCI_BUSY_DONE :
700706 /*
701707 * Save the first status register read to be sure to catch
702708 * all bits that may be lost will retrying. If the command
@@ -722,8 +728,7 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
722728 writel (readl (base + MMCIMASK0 ) &
723729 ~host -> variant -> busy_detect_mask , base + MMCIMASK0 );
724730 host -> busy_state = MMCI_BUSY_DONE ;
725- goto out_ret_state ;
726- }
731+ break ;
727732
728733 /*
729734 * If there is a command in-progress that has been successfully
@@ -736,12 +741,11 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
736741 * both the start and the end interrupts needs to be cleared,
737742 * one after the other. So, clear the busy start IRQ here.
738743 */
739- if ( host -> busy_state == MMCI_BUSY_WAITING_FOR_START_IRQ ) {
744+ case MMCI_BUSY_WAITING_FOR_START_IRQ :
740745 if (status & host -> variant -> busy_detect_flag ) {
741746 host -> busy_status |= status & (MCI_CMDSENT | MCI_CMDRESPEND );
742747 writel (host -> variant -> busy_detect_mask , base + MMCICLEAR );
743748 host -> busy_state = MMCI_BUSY_WAITING_FOR_END_IRQ ;
744- goto out_ret_state ;
745749 } else {
746750 dev_dbg (mmc_dev (host -> mmc ),
747751 "lost busy status when waiting for busy start IRQ\n" );
@@ -750,23 +754,24 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
750754 ~host -> variant -> busy_detect_mask , base + MMCIMASK0 );
751755 host -> busy_state = MMCI_BUSY_DONE ;
752756 host -> busy_status = 0 ;
753- goto out_ret_state ;
754757 }
755- }
758+ break ;
756759
757- if ( host -> busy_state == MMCI_BUSY_WAITING_FOR_END_IRQ ) {
760+ case MMCI_BUSY_WAITING_FOR_END_IRQ :
758761 if (!(status & host -> variant -> busy_detect_flag )) {
759762 host -> busy_status |= status & (MCI_CMDSENT | MCI_CMDRESPEND );
760763 host -> busy_state = MMCI_BUSY_DONE ;
761- goto out_ret_state ;
762764 } else {
763765 dev_dbg (mmc_dev (host -> mmc ),
764766 "busy status still asserted when handling busy end IRQ - will keep waiting\n" );
765- goto out_ret_state ;
766767 }
767- }
768+ break ;
768769
769- return true;
770+ default :
771+ dev_dbg (mmc_dev (host -> mmc ), "fell through on state %d\n" ,
772+ host -> busy_state );
773+ break ;
774+ }
770775
771776out_ret_state :
772777 return (host -> busy_state == MMCI_BUSY_DONE );
0 commit comments