Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1640910 > unrolled thread

[PATCH] mmc: core: Delete an error message for a failed memory allocation in three functions

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-05-13 15:00 +0200
Last post2017-05-22 14:10 +0200
Articles 7 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mmc: core: Delete an error message for a failed memory  allocation in three functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-13 15:00 +0200
    RE: [PATCH] mmc: core: Delete an error message for a failed memory  allocation in three functions "Winkler, Tomas" <tomas.winkler@intel.com> - 2017-05-13 19:30 +0200
    Re: [PATCH] mmc: core: Delete an error message for a failed memory  allocation in three functions Ulf Hansson <ulf.hansson@linaro.org> - 2017-05-19 10:00 +0200
      Re: mmc: core: Delete an error message for a failed memory allocation  in three functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-19 11:50 +0200
        Re: mmc: core: Delete an error message for a failed memory allocation  in three functions Ulf Hansson <ulf.hansson@linaro.org> - 2017-05-19 12:10 +0200
          [PATCH v2] mmc: core: Delete an error message for a failed memory  allocation in four functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-19 13:40 +0200
            Re: [PATCH v2] mmc: core: Delete an error message for a failed memory  allocation in four functions Ulf Hansson <ulf.hansson@linaro.org> - 2017-05-22 14:10 +0200

#1640910 — [PATCH] mmc: core: Delete an error message for a failed memory allocation in three functions

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-05-13 15:00 +0200
Subject[PATCH] mmc: core: Delete an error message for a failed memory allocation in three functions
Message-ID<tGEOl-3Ki-19@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 13 May 2017 14:40:08 +0200

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mmc/core/sd.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index d109634fbfce..1d7542daecbe 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -294,12 +294,8 @@ static int mmc_read_switch(struct mmc_card *card)
 	err = -EIO;
 
 	status = kmalloc(64, GFP_KERNEL);
-	if (!status) {
-		pr_err("%s: could not allocate a buffer for "
-			"switch capabilities.\n",
-			mmc_hostname(card->host));
+	if (!status)
 		return -ENOMEM;
-	}
 
 	/*
 	 * Find out the card's support bits with a mode 0 operation.
@@ -359,11 +355,8 @@ int mmc_sd_switch_hs(struct mmc_card *card)
 		return 0;
 
 	status = kmalloc(64, GFP_KERNEL);
-	if (!status) {
-		pr_err("%s: could not allocate a buffer for "
-			"switch capabilities.\n", mmc_hostname(card->host));
+	if (!status)
 		return -ENOMEM;
-	}
 
 	err = mmc_sd_switch(card, 1, 0, 1, status);
 	if (err)
@@ -596,11 +589,8 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)
 		return 0;
 
 	status = kmalloc(64, GFP_KERNEL);
-	if (!status) {
-		pr_err("%s: could not allocate a buffer for "
-			"switch capabilities.\n", mmc_hostname(card->host));
+	if (!status)
 		return -ENOMEM;
-	}
 
 	/* Set 4-bit bus width */
 	if ((card->host->caps & MMC_CAP_4_BIT_DATA) &&
-- 
2.12.3

[toc] | [next] | [standalone]


#1640969

From"Winkler, Tomas" <tomas.winkler@intel.com>
Date2017-05-13 19:30 +0200
Message-ID<tGJ1E-6H5-17@gated-at.bofh.it>
In reply to#1640910

> -----Original Message-----
> From: SF Markus Elfring [mailto:elfring@users.sourceforge.net]
> Sent: Saturday, May 13, 2017 15:54
> To: linux-mmc@vger.kernel.org; Bojan Prtvar <prtvar.b@gmail.com>; Linus
> Walleij <linus.walleij@linaro.org>; Paul Burton <paul.burton@imgtec.com>;
> Shawn Lin <shawn.lin@rock-chips.com>; Ulf Hansson
> <ulf.hansson@linaro.org>; Uri Yanai <uri.yanai@sandisk.com>; Winkler,
> Tomas <tomas.winkler@intel.com>
> Cc: LKML <linux-kernel@vger.kernel.org>; kernel-janitors@vger.kernel.org
> Subject: [PATCH] mmc: core: Delete an error message for a failed memory
> allocation in three functions
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 13 May 2017 14:40:08 +0200
> 
> Omit an extra message for a memory allocation failure in these functions.
> 
> This issue was detected by using the Coccinelle software.
> 
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-
> Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Looks, OK to me.
Tomas

> ---
>  drivers/mmc/core/sd.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index
> d109634fbfce..1d7542daecbe 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -294,12 +294,8 @@ static int mmc_read_switch(struct mmc_card *card)
>  	err = -EIO;
> 
>  	status = kmalloc(64, GFP_KERNEL);
> -	if (!status) {
> -		pr_err("%s: could not allocate a buffer for "
> -			"switch capabilities.\n",
> -			mmc_hostname(card->host));
> +	if (!status)
>  		return -ENOMEM;
> -	}
> 
>  	/*
>  	 * Find out the card's support bits with a mode 0 operation.
> @@ -359,11 +355,8 @@ int mmc_sd_switch_hs(struct mmc_card *card)
>  		return 0;
> 
>  	status = kmalloc(64, GFP_KERNEL);
> -	if (!status) {
> -		pr_err("%s: could not allocate a buffer for "
> -			"switch capabilities.\n", mmc_hostname(card-
> >host));
> +	if (!status)
>  		return -ENOMEM;
> -	}
> 
>  	err = mmc_sd_switch(card, 1, 0, 1, status);
>  	if (err)
> @@ -596,11 +589,8 @@ static int mmc_sd_init_uhs_card(struct mmc_card
> *card)
>  		return 0;
> 
>  	status = kmalloc(64, GFP_KERNEL);
> -	if (!status) {
> -		pr_err("%s: could not allocate a buffer for "
> -			"switch capabilities.\n", mmc_hostname(card-
> >host));
> +	if (!status)
>  		return -ENOMEM;
> -	}
> 
>  	/* Set 4-bit bus width */
>  	if ((card->host->caps & MMC_CAP_4_BIT_DATA) &&
> --
> 2.12.3

[toc] | [prev] | [next] | [standalone]


#1645300

FromUlf Hansson <ulf.hansson@linaro.org>
Date2017-05-19 10:00 +0200
Message-ID<tIKZk-7rF-13@gated-at.bofh.it>
In reply to#1640910
On 13 May 2017 at 14:54, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 13 May 2017 14:40:08 +0200
>
> Omit an extra message for a memory allocation failure in these functions.
>
> This issue was detected by using the Coccinelle software.
>
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

It's a nice cleanup. However I found one more occasion in mmc_test.c,
please fix that and re-spin.

Kind regards
Uffe

> ---
>  drivers/mmc/core/sd.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index d109634fbfce..1d7542daecbe 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -294,12 +294,8 @@ static int mmc_read_switch(struct mmc_card *card)
>         err = -EIO;
>
>         status = kmalloc(64, GFP_KERNEL);
> -       if (!status) {
> -               pr_err("%s: could not allocate a buffer for "
> -                       "switch capabilities.\n",
> -                       mmc_hostname(card->host));
> +       if (!status)
>                 return -ENOMEM;
> -       }
>
>         /*
>          * Find out the card's support bits with a mode 0 operation.
> @@ -359,11 +355,8 @@ int mmc_sd_switch_hs(struct mmc_card *card)
>                 return 0;
>
>         status = kmalloc(64, GFP_KERNEL);
> -       if (!status) {
> -               pr_err("%s: could not allocate a buffer for "
> -                       "switch capabilities.\n", mmc_hostname(card->host));
> +       if (!status)
>                 return -ENOMEM;
> -       }
>
>         err = mmc_sd_switch(card, 1, 0, 1, status);
>         if (err)
> @@ -596,11 +589,8 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)
>                 return 0;
>
>         status = kmalloc(64, GFP_KERNEL);
> -       if (!status) {
> -               pr_err("%s: could not allocate a buffer for "
> -                       "switch capabilities.\n", mmc_hostname(card->host));
> +       if (!status)
>                 return -ENOMEM;
> -       }
>
>         /* Set 4-bit bus width */
>         if ((card->host->caps & MMC_CAP_4_BIT_DATA) &&
> --
> 2.12.3
>
> --
> 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

[toc] | [prev] | [next] | [standalone]


#1645474 — Re: mmc: core: Delete an error message for a failed memory allocation in three functions

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-05-19 11:50 +0200
SubjectRe: mmc: core: Delete an error message for a failed memory allocation in three functions
Message-ID<tIMHM-hj-21@gated-at.bofh.it>
In reply to#1645300
> It's a nice cleanup. However I found one more occasion in mmc_test.c,
> please fix that and re-spin.

To which source code place does this feedback refer?

Does it mean that another message removal would make sense in the
function “__mmc_test_register_dbgfs_file”?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mmc/core/mmc_test.c?h=v4.11#n3202

Regards,
Markus

[toc] | [prev] | [next] | [standalone]


#1645487 — Re: mmc: core: Delete an error message for a failed memory allocation in three functions

FromUlf Hansson <ulf.hansson@linaro.org>
Date2017-05-19 12:10 +0200
SubjectRe: mmc: core: Delete an error message for a failed memory allocation in three functions
Message-ID<tIN17-GC-7@gated-at.bofh.it>
In reply to#1645474
On 19 May 2017 at 11:39, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> It's a nice cleanup. However I found one more occasion in mmc_test.c,
>> please fix that and re-spin.
>
> To which source code place does this feedback refer?
>
> Does it mean that another message removal would make sense in the
> function “__mmc_test_register_dbgfs_file”?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mmc/core/mmc_test.c?h=v4.11#n3202

Yes!

Br
Uffe

[toc] | [prev] | [next] | [standalone]


#1645544 — [PATCH v2] mmc: core: Delete an error message for a failed memory allocation in four functions

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-05-19 13:40 +0200
Subject[PATCH v2] mmc: core: Delete an error message for a failed memory allocation in four functions
Message-ID<tIOqe-1ui-15@gated-at.bofh.it>
In reply to#1645487
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 19 May 2017 13:15:27 +0200

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
This refactoring superseded the update suggestion "mmc: core: Delete
an error message for a failed memory allocation in three functions"
from 2017-05-13 because another adjustment was requested by Ulf Hansson.
https://patchwork.kernel.org/patch/9725233/
https://lkml.org/lkml/2017/5/19/308

 drivers/mmc/core/mmc_test.c |  2 --
 drivers/mmc/core/sd.c       | 16 +++-------------
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
index fd1b4b8510b9..7a304a6e5bf1 100644
--- a/drivers/mmc/core/mmc_test.c
+++ b/drivers/mmc/core/mmc_test.c
@@ -3220,8 +3220,6 @@ static int __mmc_test_register_dbgfs_file(struct mmc_card *card,
 	df = kmalloc(sizeof(*df), GFP_KERNEL);
 	if (!df) {
 		debugfs_remove(file);
-		dev_err(&card->dev,
-			"Can't allocate memory for internal usage.\n");
 		return -ENOMEM;
 	}
 
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index d109634fbfce..1d7542daecbe 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -294,12 +294,8 @@ static int mmc_read_switch(struct mmc_card *card)
 	err = -EIO;
 
 	status = kmalloc(64, GFP_KERNEL);
-	if (!status) {
-		pr_err("%s: could not allocate a buffer for "
-			"switch capabilities.\n",
-			mmc_hostname(card->host));
+	if (!status)
 		return -ENOMEM;
-	}
 
 	/*
 	 * Find out the card's support bits with a mode 0 operation.
@@ -359,11 +355,8 @@ int mmc_sd_switch_hs(struct mmc_card *card)
 		return 0;
 
 	status = kmalloc(64, GFP_KERNEL);
-	if (!status) {
-		pr_err("%s: could not allocate a buffer for "
-			"switch capabilities.\n", mmc_hostname(card->host));
+	if (!status)
 		return -ENOMEM;
-	}
 
 	err = mmc_sd_switch(card, 1, 0, 1, status);
 	if (err)
@@ -596,11 +589,8 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)
 		return 0;
 
 	status = kmalloc(64, GFP_KERNEL);
-	if (!status) {
-		pr_err("%s: could not allocate a buffer for "
-			"switch capabilities.\n", mmc_hostname(card->host));
+	if (!status)
 		return -ENOMEM;
-	}
 
 	/* Set 4-bit bus width */
 	if ((card->host->caps & MMC_CAP_4_BIT_DATA) &&
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1646797 — Re: [PATCH v2] mmc: core: Delete an error message for a failed memory allocation in four functions

FromUlf Hansson <ulf.hansson@linaro.org>
Date2017-05-22 14:10 +0200
SubjectRe: [PATCH v2] mmc: core: Delete an error message for a failed memory allocation in four functions
Message-ID<tJUjT-5vZ-1@gated-at.bofh.it>
In reply to#1645544
On 19 May 2017 at 13:34, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 19 May 2017 13:15:27 +0200
>
> Omit an extra message for a memory allocation failure in these functions.
>
> This issue was detected by using the Coccinelle software.
>
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied for next!

Kind regards
Uffe

> ---
>
> v2:
> This refactoring superseded the update suggestion "mmc: core: Delete
> an error message for a failed memory allocation in three functions"
> from 2017-05-13 because another adjustment was requested by Ulf Hansson.
> https://patchwork.kernel.org/patch/9725233/
> https://lkml.org/lkml/2017/5/19/308
>
>  drivers/mmc/core/mmc_test.c |  2 --
>  drivers/mmc/core/sd.c       | 16 +++-------------
>  2 files changed, 3 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
> index fd1b4b8510b9..7a304a6e5bf1 100644
> --- a/drivers/mmc/core/mmc_test.c
> +++ b/drivers/mmc/core/mmc_test.c
> @@ -3220,8 +3220,6 @@ static int __mmc_test_register_dbgfs_file(struct mmc_card *card,
>         df = kmalloc(sizeof(*df), GFP_KERNEL);
>         if (!df) {
>                 debugfs_remove(file);
> -               dev_err(&card->dev,
> -                       "Can't allocate memory for internal usage.\n");
>                 return -ENOMEM;
>         }
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index d109634fbfce..1d7542daecbe 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -294,12 +294,8 @@ static int mmc_read_switch(struct mmc_card *card)
>         err = -EIO;
>
>         status = kmalloc(64, GFP_KERNEL);
> -       if (!status) {
> -               pr_err("%s: could not allocate a buffer for "
> -                       "switch capabilities.\n",
> -                       mmc_hostname(card->host));
> +       if (!status)
>                 return -ENOMEM;
> -       }
>
>         /*
>          * Find out the card's support bits with a mode 0 operation.
> @@ -359,11 +355,8 @@ int mmc_sd_switch_hs(struct mmc_card *card)
>                 return 0;
>
>         status = kmalloc(64, GFP_KERNEL);
> -       if (!status) {
> -               pr_err("%s: could not allocate a buffer for "
> -                       "switch capabilities.\n", mmc_hostname(card->host));
> +       if (!status)
>                 return -ENOMEM;
> -       }
>
>         err = mmc_sd_switch(card, 1, 0, 1, status);
>         if (err)
> @@ -596,11 +589,8 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)
>                 return 0;
>
>         status = kmalloc(64, GFP_KERNEL);
> -       if (!status) {
> -               pr_err("%s: could not allocate a buffer for "
> -                       "switch capabilities.\n", mmc_hostname(card->host));
> +       if (!status)
>                 return -ENOMEM;
> -       }
>
>         /* Set 4-bit bus width */
>         if ((card->host->caps & MMC_CAP_4_BIT_DATA) &&
> --
> 2.13.0
>
> --
> 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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web