If some peoples rely on this function, then we need to remove the below codes from 'mmc_init': if (mmc->has_init) return 0;
when we use command "mmcinfo" every time, the driver must initialize the SD card again, instead of assuming the card has been initialized. Best Regards Jerry Huang > -----Original Message----- > From: Andy Fleming [mailto:aflem...@gmail.com] > Sent: Wednesday, May 09, 2012 6:17 AM > To: Huang Changming-R66093 > Cc: u-boot@lists.denx.de > Subject: Re: [PATCH 2/2] SDHC/MMC: remove the member has_init > > I am highly inclined to apply this patch, as it was originally the > intent that the init function get called every time. If it doesn't, > it's impossible to deal with cards being inserted and removed after > U-Boot comes up. > > However, I've seen some recent chatter on the list where it sounds > like people are relying on this functionality, now. So we need some > discussion. Assuming I don't apply this patch, how do we deal with the > problem of cards being removed or inserted after U-Boot boots? > > On Tue, Mar 27, 2012 at 5:25 AM, <chang-ming.hu...@freescale.com> wrote: > > From: Jerry Huang <chang-ming.hu...@freescale.com> > > > > When first inserting the SD card to slot, the command "mmcinfo" can > > display the card information correctly. > > But, then removing the SD card or inserting another SD card to slot, > > the command "mmcinfo" can't display the information correctly. > > > > Therefore remove this member 'has_init' from 'structure mmc', > > and add the codes to check the mmc_init, only when mmc_init return > > the right value, driver will print the information. > > > > Below is the error log SD card removed: > > => mmcinfo > > MMC: no card present > > Device: FSL_SDHC > > Manufacturer ID: 3 > > OEM: 5344 > > Name: SD02G > > Tran Speed: 25000000 > > Rd Block Len: 512 > > SD version 2.0 > > High Capacity: No > > Capacity: 1.8 GiB > > Bus Width: 4-bit > > > > Signed-off-by: Jerry Huang <chang-ming.hu...@freescale.com> > > CC: Andy Fleming <aflem...@gmail.com> > > --- > > common/cmd_mmc.c | 7 ++----- > > drivers/mmc/mmc.c | 9 +-------- > > include/mmc.h | 1 - > > 3 files changed, 3 insertions(+), 14 deletions(-) > > > > diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c > > index 8f13c22..382ea4e 100644 > > --- a/common/cmd_mmc.c > > +++ b/common/cmd_mmc.c > > @@ -131,9 +131,8 @@ int do_mmcinfo (cmd_tbl_t *cmdtp, int flag, int > argc, char * const argv[]) > > mmc = find_mmc_device(curr_device); > > > > if (mmc) { > > - mmc_init(mmc); > > - > > - print_mmcinfo(mmc); > > + if (!mmc_init(mmc)) > > + print_mmcinfo(mmc); > > return 0; > > } else { > > printf("no mmc device at slot %x\n", curr_device); > > @@ -172,8 +171,6 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, > char * const argv[]) > > return 1; > > } > > > > - mmc->has_init = 0; > > - > > if (mmc_init(mmc)) > > return 1; > > else > > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c > > index 9055b01..ad0ebc3 100644 > > --- a/drivers/mmc/mmc.c > > +++ b/drivers/mmc/mmc.c > > @@ -1235,14 +1235,10 @@ int mmc_init(struct mmc *mmc) > > int err; > > > > if (mmc_getcd(mmc) == 0) { > > - mmc->has_init = 0; > > printf("MMC: no card present\n"); > > return NO_CARD_ERR; > > } > > > > - if (mmc->has_init) > > - return 0; > > - > > err = mmc->init(mmc); > > > > if (err) > > @@ -1277,10 +1273,7 @@ int mmc_init(struct mmc *mmc) > > } > > > > err = mmc_startup(mmc); > > - if (err) > > - mmc->has_init = 0; > > - else > > - mmc->has_init = 1; > > + > > return err; > > } > > > > diff --git a/include/mmc.h b/include/mmc.h > > index 8744604..8e37504 100644 > > --- a/include/mmc.h > > +++ b/include/mmc.h > > @@ -277,7 +277,6 @@ struct mmc { > > void *priv; > > uint voltages; > > uint version; > > - uint has_init; > > uint f_min; > > uint f_max; > > int high_capacity; > > -- > > 1.7.5.4 > > > > _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot