Skip to contentSkip to conversation

mmc: core: Assemble the codes of related to eMMC4.5

PATCH Superseded Seungwon Jeon 3 participants 4 messages Oct 24, 2011 – Oct 25, 2011

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

PATCH 1/1 mmc: core: Assemble the codes of related to eMMC4.5

Code cleanup. The codes of related to eMMC4.5 are scattered. This patch removes a duplicate if-statement and assembles all.

---
 drivers/mmc/core/mmc.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
drivers/mmc/core/mmc.c +9 -11
index fb5bf01..3627044 100644
@@ -467,29 +467,27 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
 		card->ext_csd.rst_n_function = ext_csd[EXT_CSD_RST_N_FUNCTION];
 	}
 
-	/* eMMC v4.5 or later */
-	if (card->ext_csd.rev >= 6)
-		card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;
-
 	card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT];
 	if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
 		card->erased_byte = 0xFF;
 	else
 		card->erased_byte = 0x0;
 
+	/* eMMC v4.5 or later */
 	if (card->ext_csd.rev >= 6) {
+		card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;
+
 		card->ext_csd.generic_cmd6_time = 10 *
 			ext_csd[EXT_CSD_GENERIC_CMD6_TIME];
 		card->ext_csd.power_off_longtime = 10 *
 			ext_csd[EXT_CSD_POWER_OFF_LONG_TIME];
-	} else
-		card->ext_csd.generic_cmd6_time = 0;
 
-	card->ext_csd.cache_size =
-		ext_csd[EXT_CSD_CACHE_SIZE + 0] << 0 |
-		ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 |
-		ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 |
-		ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24;
+		card->ext_csd.cache_size =
+			ext_csd[EXT_CSD_CACHE_SIZE + 0] << 0 |
+			ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 |
+			ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 |
+			ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24;
+	}
 
 out:
 	return err;

--
1.7.0.4

#1 lore raw

Hi Seungwon,

Quoted 26 lines · Seungwon Jeon

Code cleanup. The codes of related to eMMC4.5 are scattered. This patch removes a duplicate if-statement and assembles all.

---
 drivers/mmc/core/mmc.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
drivers/mmc/core/mmc.c +0 -4
index fb5bf01..3627044 100644
@@ -467,29 +467,27 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
 		card->ext_csd.rst_n_function = ext_csd[EXT_CSD_RST_N_FUNCTION];
 	}
 
-	/* eMMC v4.5 or later */
-	if (card->ext_csd.rev >= 6)
-		card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;
-
 	card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT];
 	if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
 		card->erased_byte = 0xFF;
 	else
 		card->erased_byte = 0x0;
 

drivers/mmc/core/mmc.c static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) · line 486

Quoted 10 lines
drivers/mmc/core/mmc.c +3 -2
+	/* eMMC v4.5 or later */
 	if (card->ext_csd.rev >= 6) {
+		card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;
+
 		card->ext_csd.generic_cmd6_time = 10 *
 			ext_csd[EXT_CSD_GENERIC_CMD6_TIME];
 		card->ext_csd.power_off_longtime = 10 *
 			ext_csd[EXT_CSD_POWER_OFF_LONG_TIME];
-	} else
-		card->ext_csd.generic_cmd6_time = 0;

Your patch removes this line completely. Why is that? You should explain it in the commit message.

Quoted 5 lines
drivers/mmc/core/mmc.c +0 -4
-	card->ext_csd.cache_size =
-		ext_csd[EXT_CSD_CACHE_SIZE + 0] << 0 |
-		ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 |
-		ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 |

drivers/mmc/core/mmc.c static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) · line 493

Quoted 10 lines
drivers/mmc/core/mmc.c +6 -1
-		ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24;
+		card->ext_csd.cache_size =
+			ext_csd[EXT_CSD_CACHE_SIZE + 0] << 0 |
+			ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 |
+			ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 |
+			ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24;
+	}
 
 out:
 	return err;

The rest looks good, thanks,

- Chris.

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

Hi Seungwon,

Quoted 26 lines · Seungwon Jeon

Code cleanup. The codes of related to eMMC4.5 are scattered. This patch removes a duplicate if-statement and assembles all.

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

 1 files changed, 9 insertions(+), 11 deletions(-)
drivers/mmc/core/mmc.c +0 -4
index fb5bf01..3627044 100644
@@ -467,29 +467,27 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
               card->ext_csd.rst_n_function = ext_csd[EXT_CSD_RST_N_FUNCTION];
       }
 
-     /* eMMC v4.5 or later */
-     if (card->ext_csd.rev >= 6)
-             card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;
-
       card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT];
       if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
               card->erased_byte = 0xFF;

      else
              card->erased_byte = 0x0;

Quoted 13 lines
Quoted 10 lines

+     /* eMMC v4.5 or later */
      if (card->ext_csd.rev >= 6) {
+             card->ext_csd.feature_support |= MMC_DISCARD_FEATURE; +
              card->ext_csd.generic_cmd6_time = 10 * ext_csd[EXT_CSD_GENERIC_CMD6_TIME]; card->ext_csd.power_off_longtime = 10 * ext_csd[EXT_CSD_POWER_OFF_LONG_TIME];
-     } else
-             card->ext_csd.generic_cmd6_time = 0;

Your patch removes this line completely.  Why is that?  You should explain it in the commit message.

By tracing the code what i understand is mmc_read_ext_csd is called from mmc_card_init. In the init function the card instance is created. When the card instance is created kzalloc is used. This will initialize all the card structure members to 0.
So the deleted line is implicit.

Quoted 28 lines
Quoted 14 lines

-     card->ext_csd.cache_size =
-             ext_csd[EXT_CSD_CACHE_SIZE + 0] << 0 |
-             ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 |
-             ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 |
-             ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24;
+             card->ext_csd.cache_size =
+                     ext_csd[EXT_CSD_CACHE_SIZE + 0] << 0 |
+                     ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 |
+                     ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 |
+                     ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24;
+     }

Quoted 2 lines

 out:
      return err;

The rest looks good, thanks,

- Chris.
--
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
--
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

#3 lore raw
In reply to Chris Ball
Quoted 32 lines · Chris Ball

Hi Seungwon,

drivers/mmc/core/mmc.c static int mmc_read_ext_csd(struct mmc_card *card,

Quoted 13 lines · Seungwon Jeon

Code cleanup. The codes of related to eMMC4.5 are scattered. This patch removes a duplicate if-statement and assembles all.

---
 drivers/mmc/core/mmc.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
drivers/mmc/core/mmc.c +0 -0
index fb5bf01..3627044 100644
@@ -467,29 +467,27 @@ static int mmc_read_ext_csd(struct mmc_card *card,

u8 *ext_csd)

drivers/mmc/core/mmc.c static int mmc_read_ext_csd(struct mmc_card *card, · line 467

Quoted 1 line
drivers/mmc/core/mmc.c +0 -0
 		card->ext_csd.rst_n_function =

ext_csd[EXT_CSD_RST_N_FUNCTION];

drivers/mmc/core/mmc.c static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)

Quoted 7 lines
drivers/mmc/core/mmc.c +0 -4
 	}
 
-	/* eMMC v4.5 or later */
-	if (card->ext_csd.rev >= 6)
-		card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;
-
 	card->ext_csd.raw_erased_mem_count =

ext_csd[EXT_CSD_ERASED_MEM_CONT];

Quoted 5 lines
drivers/mmc/core/mmc.c +0 -0
 	if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
 		card->erased_byte = 0xFF;
 	else
 		card->erased_byte = 0x0;
 
Quoted 13 lines

drivers/mmc/core/mmc.c static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) · line 486

Quoted 10 lines
drivers/mmc/core/mmc.c +3 -2
+	/* eMMC v4.5 or later */
 	if (card->ext_csd.rev >= 6) {
+		card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;
+
 		card->ext_csd.generic_cmd6_time = 10 *
 			ext_csd[EXT_CSD_GENERIC_CMD6_TIME];
 		card->ext_csd.power_off_longtime = 10 *
 			ext_csd[EXT_CSD_POWER_OFF_LONG_TIME];
-	} else
-		card->ext_csd.generic_cmd6_time = 0;

Your patch removes this line completely. Why is that? You should explain it in the commit message.

Sure, I will.
Removed line is just for explicit initialization considering previous version
even though generic_cmd6_time is zeroed at card init-time. So it seems be unnecessary.

Best regards,
Seungwon Jeon.

Quoted 23 lines
Quoted 6 lines
drivers/mmc/core/mmc.c +0 -4
-	card->ext_csd.cache_size =
-		ext_csd[EXT_CSD_CACHE_SIZE + 0] << 0 |
-		ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 |
-		ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 |

drivers/mmc/core/mmc.c static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) · line 493

Quoted 10 lines
drivers/mmc/core/mmc.c +6 -1
-		ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24;
+		card->ext_csd.cache_size =
+			ext_csd[EXT_CSD_CACHE_SIZE + 0] << 0 |
+			ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 |
+			ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 |
+			ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24;
+	}
 
 out:
 	return err;

The rest looks good, thanks,

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