From 667ff8a104f23cddfaeb14863430b1debea174be Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Thu, 17 Jan 2013 15:11:47 +0000 Subject: [PATCH] mmc_attach_mmc: only call mmc_select_voltage if host->ocr_avail_mmc host->ocr_avail_mmc can be 0, in fact mmc_attach_mmc checks if host->ocr_avail_mmc is not 0 before setting host->ocr_avail. However later on, is going to call mmc_select_voltage regardeless of its value. If host->ocr_avail_mmc is 0, host->ocr ends up being 0 too, and mmc_select_voltage errors out. This patch fixes that by only calling mmc_select_voltage iff host->ocr_avail_mmc != 0. Signed-off-by: Stefano Stabellini --- drivers/mmc/core/mmc.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index e6e39111e05..0edd33b5770 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1529,14 +1529,15 @@ int mmc_attach_mmc(struct mmc_host *host) ocr &= ~0x7F; } - host->ocr = mmc_select_voltage(host, ocr); - - /* - * Can we support the voltage of the card? - */ - if (!host->ocr) { - err = -EINVAL; - goto err; + if (host->ocr_avail_mmc) { + host->ocr = mmc_select_voltage(host, ocr); + /* + * Can we support the voltage of the card? + */ + if (!host->ocr) { + err = -EINVAL; + goto err; + } } /* -- 2.39.5