Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Shawn Lin <shawn.lin@rock-chips.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org, Shawn Lin <shawn.lin@rock-chips.com>
Subject: [RFC PATCH 8/8] mmc: mmc_test: remove BUG_ONs and deploy error handling
Date: Tue, 18 Oct 2016 20:04:48 +0800	[thread overview]
Message-ID: <1476792288-6595-1-git-send-email-shawn.lin@rock-chips.com> (raw)
In-Reply-To: <1476792192-6265-1-git-send-email-shawn.lin@rock-chips.com>

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>
---

 drivers/mmc/card/mmc_test.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index 5a8dc5a..db1a7ac 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -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;
 
@@ -755,7 +758,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;
 
-- 
2.3.7



  parent reply	other threads:[~2016-10-18 11:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18 12:03 [RFC PATCH 0/8] Attempt to clean up BUG_ONs for mmc-tree Shawn Lin
2016-10-18 12:03 ` [RFC PATCH 1/8] mmc: core: remove BUG_ONs from sdio Shawn Lin
2016-10-27  8:03   ` Ulf Hansson
2016-10-18 12:03 ` [RFC PATCH 2/8] mmc: debugfs: remove BUG_ON from mmc_ext_csd_open Shawn Lin
2016-10-18 12:04 ` [RFC PATCH 3/8] mmc: core: remove BUG_ONs from mmc Shawn Lin
2016-10-27  8:14   ` Ulf Hansson
2016-10-18 12:04 ` [RFC PATCH 4/8] mmc: core: remove BUG_ONs from sd Shawn Lin
2016-10-18 12:04 ` [RFC PATCH 5/8] mmc: core: remove BUG_ONs from core.c Shawn Lin
2016-10-18 12:04 ` [RFC PATCH 6/8] mmc: sdio_uart: remove meaningless BUG_ON Shawn Lin
2016-10-18 12:04 ` [RFC PATCH 7/8] mmc: queue: remove BUG_ON for bounce_sg Shawn Lin
2016-10-18 12:04 ` Shawn Lin [this message]
2016-10-27  8:19 ` [RFC PATCH 0/8] Attempt to clean up BUG_ONs for mmc-tree Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476792288-6595-1-git-send-email-shawn.lin@rock-chips.com \
    --to=shawn.lin@rock-chips.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox