On Tue, May 11, 2010 at 9:15 PM, Guennadi Liakhovetski <g.liakhovetski@xxxxxx> wrote: > On Tue, 11 May 2010, Magnus Damm wrote: > >> Hi Guennadi, >> >> Many thanks for your work on this! >> >> On Tue, May 11, 2010 at 6:52 PM, Guennadi Liakhovetski >> <g.liakhovetski@xxxxxx> wrote: >> > Write-protection status is not always available, e.g., micro-SD cards do not >> > have a write-protection switch at all. This patch adds a flag to let platforms >> > force tmio_mmc to consider the card writable. >> > >> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@xxxxxx> >> > --- >> > drivers/mmc/host/tmio_mmc.c | 5 ++++- >> > include/linux/mfd/tmio.h | 4 ++++ >> > 2 files changed, 8 insertions(+), 1 deletions(-) >> > >> > diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c >> > index 7e79ba4..11c19b0 100644 >> > --- a/drivers/mmc/host/tmio_mmc.c >> > +++ b/drivers/mmc/host/tmio_mmc.c >> > @@ -640,8 +640,11 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) >> > static int tmio_mmc_get_ro(struct mmc_host *mmc) >> > { >> > struct tmio_mmc_host *host = mmc_priv(mmc); >> > + struct mfd_cell *cell = host->pdev->dev.platform_data; >> > + struct tmio_mmc_data *pdata = cell->driver_data; >> > >> > - return (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT) ? 0 : 1; >> > + return ((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) || >> > + (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)) ? 0 : 1; >> > } >> >> It's a bit late so perhaps I'm thinking backwards, but isn't this >> logic inverted? >> >> Fact: The WP signal is missing from the micro-sd slot on the kfr2r09 >> board, and the card incorrectly comes up write protected. >> >> Solution: TMIO_MMC_WRPROTECT_DISABLE is set to make sure the card is >> _not_ write protected by mistake. >> >> But: The code using the ->reg_ro() callback assumes that the card is >> read-only if 1 is returned according to drivers/mmc/core/sd.c. The >> code above returns 1 if TMIO_MMC_WRPROTECT_DISABLE is set. So the card >> will be forced read-only on kfr2r09 unless i'm mistaken, and this does >> not help so much. =) > > I think above is right, please, look again. If TMIO_MMC_WRPROTECT_DISABLE > is set, the function returns 0. Err, yeah, you are correct. I overlooked the "?" part... Looking good! Thanks, / magnus -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html