hd-geometry: Clean up confusing use of prior translation hint
authorMarkus Armbruster <armbru@redhat.com>
Tue, 10 Jul 2012 09:12:36 +0000 (11:12 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 17 Jul 2012 14:48:30 +0000 (16:48 +0200)
commitdc28c0cd30d7b122500b17eedc7e070624fd7c86
tree589893555d582b68dc0f0a5e2a86300c56c60855
parent82b11662be5b6e462ae843363b316779a9c88a61
hd-geometry: Clean up confusing use of prior translation hint

When hd_geometry_guess() picks a geometry, it also picks the
appropriate translation, but only when the prior translation hint is
BIOS_ATA_TRANSLATION_AUTO.  Looks wrong, because such a prior
translation would be passed to the BIOS whether it's suitable for the
geometry or not.

Fortunately, that can't happen.  There are just two ways for the
translation hint to get set to something other than
BIOS_ATA_TRANSLATION_AUTO: drive_init() on behalf of -drive trans=...,
and hd_geometry_guess().  Both set it only when they also set a valid
geometry hint, i.e. one with a non-zero number of cylinders.

Since hd_geometry_guess() returns right away when it finds a valid
geometry hint, translation can only be BIOS_ATA_TRANSLATION_AUTO in
the remainder of the function.

Assert this, and simplify accordingly.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/hd-geometry.c