aboutsummaryrefslogtreecommitdiff
path: root/hw/sd.c
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2011-07-25 16:19:05 -0700
committerAndrzej Zaborowski <andrew.zaborowski@intel.com>2011-07-30 07:26:40 +0200
commit5e37141bbb9796ef139aee902a882ca97d59b84d (patch)
tree1150fda952e77c34e2282209be5d0057ac843377 /hw/sd.c
parent4b5dfd8246321d2cdca0508f6837a681f7873f43 (diff)
downloadqemu-5e37141bbb9796ef139aee902a882ca97d59b84d.zip
qemu-5e37141bbb9796ef139aee902a882ca97d59b84d.tar.gz
qemu-5e37141bbb9796ef139aee902a882ca97d59b84d.tar.bz2
sd: do not add one sector to the disk size
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> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
Diffstat (limited to 'hw/sd.c')
-rw-r--r--hw/sd.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/hw/sd.c b/hw/sd.c
index 219a0dd..c2c80ab 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;