]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mmc: mmc_test: remove BUG_ONs and deploy error handling
authorShawn Lin <shawn.lin@rock-chips.com>
Wed, 2 Nov 2016 07:26:57 +0000 (15:26 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 5 Dec 2016 09:31:13 +0000 (10:31 +0100)
It is unnecessary to panic the kernel when testing mmc. Instead,
cast a warning for folkz to debug and return the error code to
the caller to indicate the failure of this test should be enough.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/card/mmc_test.c

index 5ba6d77b9723c8799418b59d8e0d51899f97ad7c..ec1d1c46eb90069fe4f313e8bb4c877d973a7b7b 100644 (file)
@@ -214,7 +214,8 @@ static void mmc_test_prepare_mrq(struct mmc_test_card *test,
        struct mmc_request *mrq, struct scatterlist *sg, unsigned sg_len,
        unsigned dev_addr, unsigned blocks, unsigned blksz, int write)
 {
-       BUG_ON(!mrq || !mrq->cmd || !mrq->data || !mrq->stop);
+       if (WARN_ON(!mrq || !mrq->cmd || !mrq->data || !mrq->stop))
+               return;
 
        if (blocks > 1) {
                mrq->cmd->opcode = write ?
@@ -694,7 +695,8 @@ static int mmc_test_cleanup(struct mmc_test_card *test)
 static void mmc_test_prepare_broken_mrq(struct mmc_test_card *test,
        struct mmc_request *mrq, int write)
 {
-       BUG_ON(!mrq || !mrq->cmd || !mrq->data);
+       if (WARN_ON(!mrq || !mrq->cmd || !mrq->data))
+               return;
 
        if (mrq->data->blocks > 1) {
                mrq->cmd->opcode = write ?
@@ -714,7 +716,8 @@ static int mmc_test_check_result(struct mmc_test_card *test,
 {
        int ret;
 
-       BUG_ON(!mrq || !mrq->cmd || !mrq->data);
+       if (WARN_ON(!mrq || !mrq->cmd || !mrq->data))
+               return -EINVAL;
 
        ret = 0;
 
@@ -768,7 +771,8 @@ static int mmc_test_check_broken_result(struct mmc_test_card *test,
 {
        int ret;
 
-       BUG_ON(!mrq || !mrq->cmd || !mrq->data);
+       if (WARN_ON(!mrq || !mrq->cmd || !mrq->data))
+               return -EINVAL;
 
        ret = 0;