Patchwork [1/7] sd: do not add one sector to the disk size

login
register
mail settings
Submitter Vincent Palatin
Date July 25, 2011, 11:19 p.m.
Message ID <1311635951-11047-2-git-send-email-vpalatin@chromium.org>
Download mbox | patch
Permalink /patch/106764/
State New
Headers show

Comments

Vincent Palatin - July 25, 2011, 11:19 p.m.
This leads to random off-by-one error.
When the size of the SD is exactly 1GB, the emulation was returning a
wrong SDHC CSD descriptor.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
---
 hw/sd.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

Patch

diff --git a/hw/sd.c b/hw/sd.c
index cedfb20..f48d589 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -393,9 +393,7 @@  static void sd_reset(SDState *sd, BlockDriverState *bdrv)
     } else {
         sect = 0;
     }
-    sect <<= 9;
-
-    size = sect + 1;
+    size = sect << 9;
 
     sect = (size >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT)) + 1;