Skip to contentSkip to conversation

mmc: core: skip card initialization if power class selection fails

PATCH Superseded Subhash Jadavani 3 participants 5 messages Apr 9, 2012 – Apr 11, 2012 MMC, SD and SDIO

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: core: skip card initialization if power class selection fails

With current implementation of power class selection, mmc_select_powerclass() should never fail. So treat any error returned by this function as serious enough to skip the card initialization.

---
 drivers/mmc/core/mmc.c |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)
drivers/mmc/core/mmc.c +20 -14
index 54df5ad..d5ff192 100644
@@ -1116,10 +1116,12 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 		ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ?
 				EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4;
 		err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
-		if (err)
-			pr_warning("%s: power class selection to bus width %d"
-				   " failed\n", mmc_hostname(card->host),
-				   1 << bus_width);
+		if (err) {
+			pr_err("%s: power class selection to bus width %d"
+			       " failed\n", mmc_hostname(card->host),
+			       1 << bus_width);
+			goto err;
+		}
 	}
 
 	/*
@@ -1150,11 +1152,13 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 				ddr = 0; /* no DDR for 1-bit width */
 			err = mmc_select_powerclass(card, ext_csd_bits[idx][0],
 						    ext_csd);
-			if (err)
-				pr_warning("%s: power class selection to "
-					   "bus width %d failed\n",
-					   mmc_hostname(card->host),
-					   1 << bus_width);
+			if (err) {
+				pr_err("%s: power class selection to "
+				       "bus width %d failed\n",
+				       mmc_hostname(card->host),
+				       1 << bus_width);
+				goto err;
+			}
 
 			err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
 					 EXT_CSD_BUS_WIDTH,
@@ -1181,11 +1185,13 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 		if (!err && ddr) {
 			err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
 						    ext_csd);
-			if (err)
-				pr_warning("%s: power class selection to "
-					   "bus width %d ddr %d failed\n",
-					   mmc_hostname(card->host),
-					   1 << bus_width, ddr);
+			if (err) {
+				pr_err("%s: power class selection to "
+				       "bus width %d ddr %d failed\n",
+				       mmc_hostname(card->host),
+				       1 << bus_width, ddr);
+				goto err;
+			}
 
 			err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
 					 EXT_CSD_BUS_WIDTH,
Signature · 5 lines
1.7.1.1

--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#1 lore raw

Hi Subhash.
There are duplicate printks in three places. Is there no way to avoid duplicate printks ?

Thanks.

2012/4/9 Subhash Jadavani <[email protected]>:

Quoted 79 lines

With current implementation of power class selection, mmc_select_powerclass() should never fail. So treat any error returned by this function as serious enough to skip the card initialization.

---
 drivers/mmc/core/mmc.c |   34 ++++++++++++++++++++--------------

 1 files changed, 20 insertions(+), 14 deletions(-)
drivers/mmc/core/mmc.c +0 -0
index 54df5ad..d5ff192 100644
@@ -1116,10 +1116,12 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,

               ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4; err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
-               if (err)
-                       pr_warning("%s: power class selection to bus width %d"
-                                  " failed\n", mmc_hostname(card->host),
-                                  1 << bus_width);
+               if (err) {
+                       pr_err("%s: power class selection to bus width %d"
+                              " failed\n", mmc_hostname(card->host),
+                              1 << bus_width);
+                       goto err;
+               }
       }

       /*

drivers/mmc/core/mmc.c +0 -0
@@ -1150,11 +1152,13 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,

                               ddr = 0; /* no DDR for 1-bit width */ err = mmc_select_powerclass(card, ext_csd_bits[idx][0], ext_csd);
-                       if (err)
-                               pr_warning("%s: power class selection to "
-                                          "bus width %d failed\n",
-                                          mmc_hostname(card->host),
-                                          1 << bus_width);
+                       if (err) {
+                               pr_err("%s: power class selection to "
+                                      "bus width %d failed\n",
+                                      mmc_hostname(card->host),
+                                      1 << bus_width);
+                               goto err;
+                       }

                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH,

drivers/mmc/core/mmc.c +7 -6
@@ -1181,11 +1185,13 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
                if (!err && ddr) {
                        err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
                                                    ext_csd);
-                       if (err)
-                               pr_warning("%s: power class selection to "
-                                          "bus width %d ddr %d failed\n",
-                                          mmc_hostname(card->host),
-                                          1 << bus_width, ddr);
+                       if (err) {
+                               pr_err("%s: power class selection to "
+                                      "bus width %d ddr %d failed\n",
+                                      mmc_hostname(card->host),
+                                      1 << bus_width, ddr);
+                               goto err;
+                       }
 
                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                         EXT_CSD_BUS_WIDTH,
--

1.7.1.1

--
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum. --
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

#2 lore raw

Hi,

Quoted 3 lines · Namjae Jeon

Hi Subhash.
There are duplicate printks in three places. Is there no way to avoid duplicate printks ?

The printk can go just before the final "return err" in mmc_select_powerclass().

Thanks,

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#3 lore raw
Quoted 8 lines

-----Original Message-----
From: Chris Ball [mailto:[email protected]]
Sent: Tuesday, April 10, 2012 7:46 PM
To: Namjae Jeon
Cc: Subhash Jadavani; [email protected]; [email protected]
Subject: Re: [PATCH v1 1/1] mmc: core: skip card initialization if power

class

Quoted 10 lines

selection fails

Hi,

Quoted 3 lines · Namjae Jeon

Hi Subhash.
There are duplicate printks in three places. Is there no way to avoid duplicate printks ?

The printk can go just before the final "return err" in

mmc_select_powerclass().
Yes. will fix it and post another patch.

Thanks,
Subhash

Quoted 7 lines

Thanks,

- Chris.
--
Chris Ball <[email protected]> <http://printf.net/>
One Laptop Per Child

#4 lore raw
In reply to Chris Ball

Hi. Chris.

You're right~ we can optmize code properly by moving printk to mmc_select_powerclass.
Thanks for your reply.

2012/4/10 Chris Ball <[email protected]>:

Quoted 16 lines

Hi,

Quoted 3 lines · Namjae Jeon

Hi Subhash.
There are duplicate printks in three places. Is there no way to avoid duplicate printks ?

The printk can go just before the final "return err" in mmc_select_powerclass().

Thanks,

- Chris.
--
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child