diff mbox

[8/8] mmc: mmc_test: remove BUG_ONs and deploy error handling

Message ID 1478071617-12984-1-git-send-email-shawn.lin@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shawn Lin Nov. 2, 2016, 7:26 a.m. UTC
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(-)

Comments

Ulf Hansson Nov. 29, 2016, 12:41 p.m. UTC | #1
On 2 November 2016 at 08:26, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> 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>

Thanks, applied for next!

Kind regards
Uffe


> ---
>
>  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
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;