Author: imp
Date: Tue Dec 23 05:50:53 2014
New Revision: 276106
URL: https://svnweb.freebsd.org/changeset/base/276106

Log:
  Always select the card before we do the 4.x specific stuff and
  deselect it after setting the block size. This is a similar bug that
  was fixed elsewhere, but not here. This makes sure that we leave the
  card deselected at the end of the loop, and we don't send any commands
  to the card without it selected.
  
  Reviewed by: ian@

Modified:
  head/sys/dev/mmc/mmc.c

Modified: head/sys/dev/mmc/mmc.c
==============================================================================
--- head/sys/dev/mmc/mmc.c      Tue Dec 23 05:37:09 2014        (r276105)
+++ head/sys/dev/mmc/mmc.c      Tue Dec 23 05:50:53 2014        (r276106)
@@ -1446,10 +1446,10 @@ mmc_discover_cards(struct mmc_softc *sc)
                        break;
                }
 
+               mmc_select_card(sc, ivar->rca);
+
                /* Only MMC >= 4.x cards support EXT_CSD. */
                if (ivar->csd.spec_vers >= 4) {
-                       /* Card must be selected to fetch EXT_CSD. */
-                       mmc_select_card(sc, ivar->rca);
                        mmc_send_ext_csd(sc, ivar->raw_ext_csd);
                        /* Handle extended capacity from EXT_CSD */
                        sec_count = ivar->raw_ext_csd[EXT_CSD_SEC_CNT] +
@@ -1479,7 +1479,6 @@ mmc_discover_cards(struct mmc_softc *sc)
                                mmc_switch(sc, EXT_CSD_CMD_SET_NORMAL,
                                    EXT_CSD_ERASE_GRP_DEF, 1);
                        }
-                       mmc_select_card(sc, 0);
                } else {
                        ivar->bus_width = bus_width_1;
                        ivar->timing = bus_timing_normal;
@@ -1506,6 +1505,7 @@ mmc_discover_cards(struct mmc_softc *sc)
                        child = device_add_child(sc->dev, NULL, -1);
                        device_set_ivars(child, ivar);
                }
+               mmc_select_card(sc, 0);
        }
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to