aboutsummaryrefslogtreecommitdiff
path: root/hw/hd-geometry.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2012-07-10 11:12:37 +0200
committerKevin Wolf <kwolf@redhat.com>2012-07-17 16:48:30 +0200
commite2f3dc2b6a205cf969ba5d1307293db17fd9621f (patch)
tree1dd5ac8c21df718fadaced876fadb92114d19492 /hw/hd-geometry.c
parentdc28c0cd30d7b122500b17eedc7e070624fd7c86 (diff)
hd-geometry: Cut out block layer translation middleman
hd_geometry_guess() picks geometry and translation. Callers can get the geometry directly, via parameters, but for translation they need to go through the block layer. Add a parameter for translation, so it can optionally be gotten just like geometry. In preparation of purging translation from the block layer, which will happen later in this series. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/hd-geometry.c')
-rw-r--r--hw/hd-geometry.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/hw/hd-geometry.c b/hw/hd-geometry.c
index 241aed9352..4d746b7155 100644
--- a/hw/hd-geometry.c
+++ b/hw/hd-geometry.c
@@ -117,7 +117,8 @@ static void guess_chs_for_size(BlockDriverState *bs,
}
void hd_geometry_guess(BlockDriverState *bs,
- int *pcyls, int *pheads, int *psecs)
+ int *pcyls, int *pheads, int *psecs,
+ int *ptrans)
{
int cylinders, heads, secs, translation;
@@ -129,6 +130,9 @@ void hd_geometry_guess(BlockDriverState *bs,
*pcyls = cylinders;
*pheads = heads;
*psecs = secs;
+ if (ptrans) {
+ *ptrans = translation;
+ }
return;
}
@@ -142,10 +146,10 @@ void hd_geometry_guess(BlockDriverState *bs,
translation was active, so a standard physical disk
geometry is OK */
guess_chs_for_size(bs, pcyls, pheads, psecs);
- bdrv_set_translation_hint(bs,
- *pcyls * *pheads <= 131072
- ? BIOS_ATA_TRANSLATION_LARGE
- : BIOS_ATA_TRANSLATION_LBA);
+ translation = *pcyls * *pheads <= 131072
+ ? BIOS_ATA_TRANSLATION_LARGE
+ : BIOS_ATA_TRANSLATION_LBA;
+ bdrv_set_translation_hint(bs, translation);
} else {
/* LCHS guess with heads <= 16: use as physical geometry */
*pcyls = cylinders;
@@ -153,7 +157,11 @@ void hd_geometry_guess(BlockDriverState *bs,
*psecs = secs;
/* disable any translation to be in sync with
the logical geometry */
- bdrv_set_translation_hint(bs, BIOS_ATA_TRANSLATION_NONE);
+ translation = BIOS_ATA_TRANSLATION_NONE;
+ bdrv_set_translation_hint(bs, translation);
+ }
+ if (ptrans) {
+ *ptrans = translation;
}
bdrv_set_geometry_hint(bs, *pcyls, *pheads, *psecs);
trace_hd_geometry_guess(bs, *pcyls, *pheads, *psecs, translation);