From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8xad-0002Ef-M5 for qemu-devel@nongnu.org; Tue, 15 Dec 2015 16:57:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a8xac-0006Qo-HD for qemu-devel@nongnu.org; Tue, 15 Dec 2015 16:56:59 -0500 References: <1449531275-30362-1-git-send-email-jsnow@redhat.com> <1449531275-30362-2-git-send-email-jsnow@redhat.com> <56708B48.9030901@reactos.org> From: John Snow Message-ID: <56708CA3.8010803@redhat.com> Date: Tue, 15 Dec 2015 16:56:51 -0500 MIME-Version: 1.0 In-Reply-To: <56708B48.9030901@reactos.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-2.6 v2 01/10] fdc: move pick_geometry List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Herv=c3=a9_Poussineau?= , qemu-block@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org On 12/15/2015 04:51 PM, Herv=E9 Poussineau wrote: > Le 08/12/2015 00:34, John Snow a =E9crit : >> Code motion: I want to refactor this function to work with FDrive >> directly, so shuffle it below that definition. >> >> Signed-off-by: John Snow >> --- >> hw/block/fdc.c | 90 >> +++++++++++++++++++++++++++++----------------------------- >> 1 file changed, 45 insertions(+), 45 deletions(-) >> >> diff --git a/hw/block/fdc.c b/hw/block/fdc.c >> index 4292ece..246b631 100644 >> --- a/hw/block/fdc.c >> +++ b/hw/block/fdc.c >> @@ -114,51 +114,6 @@ static const FDFormat fd_formats[] =3D { >> { FDRIVE_DRV_NONE, -1, -1, 0, 0, }, >> }; >> >> -static void pick_geometry(BlockBackend *blk, int *nb_heads, >> - int *max_track, int *last_sect, >> - FDriveType drive_in, FDriveType *drive, >> - FDriveRate *rate) >> -{ >> - const FDFormat *parse; >> - uint64_t nb_sectors, size; >> - int i, first_match, match; >> - >> - blk_get_geometry(blk, &nb_sectors); >> - match =3D -1; >> - first_match =3D -1; >> - for (i =3D 0; ; i++) { >> - parse =3D &fd_formats[i]; >> - if (parse->drive =3D=3D FDRIVE_DRV_NONE) { >> - break; >> - } >> - if (drive_in =3D=3D parse->drive || >> - drive_in =3D=3D FDRIVE_DRV_NONE) { >> - size =3D (parse->max_head + 1) * parse->max_track * >> - parse->last_sect; >> - if (nb_sectors =3D=3D size) { >> - match =3D i; >> - break; >> - } >> - if (first_match =3D=3D -1) { >> - first_match =3D i; >> - } >> - } >> - } >> - if (match =3D=3D -1) { >> - if (first_match =3D=3D -1) { >> - match =3D 1; >> - } else { >> - match =3D first_match; >> - } >> - parse =3D &fd_formats[match]; >> - } >> - *nb_heads =3D parse->max_head + 1; >> - *max_track =3D parse->max_track; >> - *last_sect =3D parse->last_sect; >> - *drive =3D parse->drive; >> - *rate =3D parse->rate; >> -} >> - >> #define GET_CUR_DRV(fdctrl) ((fdctrl)->cur_drv) >> #define SET_CUR_DRV(fdctrl, drive) ((fdctrl)->cur_drv =3D (drive)) >> >> @@ -286,6 +241,51 @@ static void fd_recalibrate(FDrive *drv) >> fd_seek(drv, 0, 0, 1, 1); >> } >> >> +static void pick_geometry(BlockBackend *blk, int *nb_heads, >> + int *max_track, int *last_sect, >> + FDriveType drive_in, FDriveType *drive, >> + FDriveRate *rate) >> +{ >> + const FDFormat *parse; >> + uint64_t nb_sectors, size; >> + int i, first_match, match; >> + >> + blk_get_geometry(blk, &nb_sectors); >> + match =3D -1; >> + first_match =3D -1; >> + for (i =3D 0; ; i++) { >> + parse =3D &fd_formats[i]; >> + if (parse->drive =3D=3D FDRIVE_DRV_NONE) { >> + break; >> + } >> + if (drive_in =3D=3D parse->drive || >> + drive_in =3D=3D FDRIVE_DRV_NONE) { >> + size =3D (parse->max_head + 1) * parse->max_track * >> + parse->last_sect; >> + if (nb_sectors =3D=3D size) { >> + match =3D i; >> + break; >> + } >> + if (first_match =3D=3D -1) { >> + first_match =3D i; >> + } >> + } >> + } >> + if (match =3D=3D -1) { >> + if (first_match =3D=3D -1) { >> + match =3D 1; >> + } else { >> + match =3D first_match; >> + } >> + parse =3D &fd_formats[match]; >> + } >> + *nb_heads =3D parse->max_head + 1; >> + *max_track =3D parse->max_track; >> + *last_sect =3D parse->last_sect; >> + *drive =3D parse->drive; >> + *rate =3D parse->rate; >> +} >> + >> /* Revalidate a disk drive after a disk change */ >> static void fd_revalidate(FDrive *drv) >> { >=20 > I think it would be better to move the FDiskFlags enum, FDrive, FDCtrl, > FDCtrlISABus structures to include/hw/block/fdc.h > That way, we can embed the floppy controller into another chip. I'll > need it soon for some PIIX4 improvements. >=20 > Regards, >=20 > Herv=E9 >=20 Deal. (Why are you embedding a floppy controller? :) --js