mmc: mmc: fix check on mmc_select_bus_width return value
PATCH 1/1 mmc: mmc: fix check on mmc_select_bus_width return value
This fixes a bug introduced by commit 287980e49ffc ("remove lots of IS_ERR_VALUE abuses"). mmc_select_bus_width can return positive integer values upon success, so the (!err) check is incorrect here. This causes mmc initialisation failure, and subsequently boot failure, on some platforms.
--- drivers/mmc/core/mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/core/mmc.c +2 -2
@@ -1276,7 +1276,7 @@ static int mmc_select_hs200(struct mmc_card *card)* switch to HS200 mode if bus width is set successfully. */ err =mmc_select_bus_width (card); -if (!err) { +if (err >=0 ) { val =EXT_CSD_TIMING_HS200 | card->drive_strength <<EXT_CSD_DRV_STR_SHIFT ; err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
@@ -1583,7 +1583,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, }else if (mmc_card_hs (card)) {/* Select the desired bus width optionally */ err =mmc_select_bus_width (card); -if (!err) { +if (err >=0 ) { err =mmc_select_hs_ddr (card);if (err) goto free_card;
Signature · 1 line
2.1.4
Quoted 5 lines · Dan O'Donovan
This fixes a bug introduced by commit
287980e49ffc("remove lots ofIS_ERR_VALUEabuses").mmc_select_bus_widthcan return positive integer values upon success, so the (!err) check is incorrect here. This causes mmc initialisation failure, and subsequently boot failure, on some platforms.
Refer to below patch.
https://patchwork.kernel.org/patch/9139673/
Best Regards,
Jaehoon Chung
Quoted 29 lines
Signed-off-by Dan O'Donovan <[email protected]>--- drivers/mmc/core/mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mmc/core/mmc.c +2
-2@@ -1276,7 +1276,7 @@ static int mmc_select_hs200(struct mmc_card *card)* switch to HS200 mode if bus width is set successfully. */ err =mmc_select_bus_width (card); -if (!err) { +if (err >=0 ) { val =EXT_CSD_TIMING_HS200 | card->drive_strength <<EXT_CSD_DRV_STR_SHIFT ; err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,@@ -1583,7 +1583,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, }else if (mmc_card_hs (card)) {/* Select the desired bus width optionally */ err =mmc_select_bus_width (card); -if (!err) { +if (err >=0 ) { err =mmc_select_hs_ddr (card);if (err) goto free_card;
Quoted 6 lines · Jaehoon Chung
Quoted 5 lines · Dan O'Donovan
This fixes a bug introduced by commit
287980e49ffc("remove lots ofIS_ERR_VALUEabuses").mmc_select_bus_widthcan return positive integer values upon success, so the (!err) check is incorrect here. This causes mmc initialisation failure, and subsequently boot failure, on some platforms.
Quoted 6 lines
Refer to below patch.
https://patchwork.kernel.org/patch/9139673/
Best Regards,
Jaehoon Chung
Ah, sorry I missed that. Glad to see a fix is on the way already. Please disregard my patch. Thanks!
Quoted 29 lines
Quoted 29 lines
Signed-off-by Dan O'Donovan <[email protected]>--- drivers/mmc/core/mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mmc/core/mmc.c +2
-2@@ -1276,7 +1276,7 @@ static int mmc_select_hs200(struct mmc_card *card)* switch to HS200 mode if bus width is set successfully. */ err =mmc_select_bus_width (card); -if (!err) { +if (err >=0 ) { val =EXT_CSD_TIMING_HS200 | card->drive_strength <<EXT_CSD_DRV_STR_SHIFT ; err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,@@ -1583,7 +1583,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, }else if (mmc_card_hs (card)) {/* Select the desired bus width optionally */ err =mmc_select_bus_width (card); -if (!err) { +if (err >=0 ) { err =mmc_select_hs_ddr (card);if (err) goto free_card;