Skip to contentSkip to conversation

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

PATCH In review SF Markus Elfring 3 participants 7 messages May 13, 2017 – May 22, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

From: Markus Elfring <[email protected]>
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.

---
 drivers/mmc/core/sd.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/mmc/core/sd.c +3 -13
index d109634fbfce..1d7542daecbe 100644
@@ -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) &&
Signature · 1 line
2.12.3
#1 lore raw

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogU0YgTWFya3VzIEVsZnJp bmcgW21haWx0bzplbGZya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cmV0dXJuIC1F Tk9NRU07DQo+IC0JfQ0KPiANCj4gIAkvKiBTZXQgNC1iaXQgYnVzIHdpZHRoICovDQo+ICAJaWYg KChjYXJkLT5ob3N0LT5jYXBzICYgTU1DX0NBUF80X0JJVF9EQVRBKSAmJg0KPiAtLQ0KPiAyLjEy LjMNCg0K

#2 lore raw
In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
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.

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

Kind regards
Uffe

Quoted 55 lines
---
 drivers/mmc/core/sd.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/mmc/core/sd.c +3 -14
index d109634fbfce..1d7542daecbe 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

PATCH v2 1/1 mmc: core: Delete an error message for a failed memory allocation in four functions

From: Markus Elfring <[email protected]>
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.

---

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(-)
drivers/mmc/core/mmc_test.c +0 -2
index fd1b4b8510b9..7a304a6e5bf1 100644
@@ -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;
 	}
 
drivers/mmc/core/sd.c +3 -13
index d109634fbfce..1d7542daecbe 100644
@@ -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) &&
Signature · 1 line
2.13.0
Applied
#6 lore raw

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

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
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.

Thanks, applied for next!

Kind regards
Uffe

Quoted 77 lines

---

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(-)
drivers/mmc/core/mmc_test.c +0 -2
index fd1b4b8510b9..7a304a6e5bf1 100644
@@ -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;
        }
 
drivers/mmc/core/sd.c +3 -14
index d109634fbfce..1d7542daecbe 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html