Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: core: remove BUG_ONs from sdio

BUG_ONs doesn't help anything except for stop the system from
running. If it occurs, it implies we should deploy proper error
handling for that. So this patch is gonna discard these meaningless
BUG_ONs and deploy error handling if needed.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Shawn Lin and committed by
Ulf Hansson
5df0e823 925ff3a7

+11 -21
+2 -15
drivers/mmc/core/sdio.c
··· 63 63 int ret; 64 64 struct sdio_func *func; 65 65 66 - BUG_ON(fn > SDIO_MAX_FUNCS); 66 + if (WARN_ON(fn > SDIO_MAX_FUNCS)) 67 + return -EINVAL; 67 68 68 69 func = sdio_alloc_func(card); 69 70 if (IS_ERR(func)) ··· 556 555 u32 rocr = 0; 557 556 u32 ocr_card = ocr; 558 557 559 - BUG_ON(!host); 560 558 WARN_ON(!host->claimed); 561 559 562 560 /* to query card if 1.8V signalling is supported */ ··· 791 791 { 792 792 int i; 793 793 794 - BUG_ON(!host); 795 - BUG_ON(!host->card); 796 - 797 794 for (i = 0;i < host->card->sdio_funcs;i++) { 798 795 if (host->card->sdio_func[i]) { 799 796 sdio_remove_func(host->card->sdio_func[i]); ··· 816 819 static void mmc_sdio_detect(struct mmc_host *host) 817 820 { 818 821 int err; 819 - 820 - BUG_ON(!host); 821 - BUG_ON(!host->card); 822 822 823 823 /* Make sure card is powered before detecting it */ 824 824 if (host->caps & MMC_CAP_POWER_OFF_CARD) { ··· 910 916 { 911 917 int err = 0; 912 918 913 - BUG_ON(!host); 914 - BUG_ON(!host->card); 915 - 916 919 /* Basic card reinitialization. */ 917 920 mmc_claim_host(host); 918 921 ··· 960 969 static int mmc_sdio_power_restore(struct mmc_host *host) 961 970 { 962 971 int ret; 963 - 964 - BUG_ON(!host); 965 - BUG_ON(!host->card); 966 972 967 973 mmc_claim_host(host); 968 974 ··· 1051 1063 u32 ocr, rocr; 1052 1064 struct mmc_card *card; 1053 1065 1054 - BUG_ON(!host); 1055 1066 WARN_ON(!host->claimed); 1056 1067 1057 1068 err = mmc_send_io_op_cond(host, 0, &ocr);
+2 -1
drivers/mmc/core/sdio_cis.c
··· 262 262 else 263 263 prev = &card->tuples; 264 264 265 - BUG_ON(*prev); 265 + if (*prev) 266 + return -EINVAL; 266 267 267 268 do { 268 269 unsigned char tpl_code, tpl_link;
+7 -5
drivers/mmc/core/sdio_irq.c
··· 214 214 struct mmc_host *host = card->host; 215 215 216 216 WARN_ON(!host->claimed); 217 - BUG_ON(host->sdio_irqs < 1); 217 + 218 + if (host->sdio_irqs < 1) 219 + return -EINVAL; 218 220 219 221 if (!--host->sdio_irqs) { 220 222 if (!(host->caps2 & MMC_CAP2_SDIO_IRQ_NOTHREAD)) { ··· 263 261 int ret; 264 262 unsigned char reg; 265 263 266 - BUG_ON(!func); 267 - BUG_ON(!func->card); 264 + if (!func) 265 + return -EINVAL; 268 266 269 267 pr_debug("SDIO: Enabling IRQ for %s...\n", sdio_func_id(func)); 270 268 ··· 306 304 int ret; 307 305 unsigned char reg; 308 306 309 - BUG_ON(!func); 310 - BUG_ON(!func->card); 307 + if (!func) 308 + return -EINVAL; 311 309 312 310 pr_debug("SDIO: Disabling IRQ for %s...\n", sdio_func_id(func)); 313 311