qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6 v2 01/10] fdc: move pick_ge


From: John Snow
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH for-2.6 v2 01/10] fdc: move pick_geometry
Date: Wed, 16 Dec 2015 16:14:16 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0


On 12/15/2015 04:51 PM, Hervé Poussineau wrote:
> Le 08/12/2015 00:34, John Snow a écrit :
>> Code motion: I want to refactor this function to work with FDrive
>> directly, so shuffle it below that definition.
>>
>> Signed-off-by: John Snow <address@hidden>
>> ---
>>   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[] = {
>>       { 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 = -1;
>> -    first_match = -1;
>> -    for (i = 0; ; i++) {
>> -        parse = &fd_formats[i];
>> -        if (parse->drive == FDRIVE_DRV_NONE) {
>> -            break;
>> -        }
>> -        if (drive_in == parse->drive ||
>> -            drive_in == FDRIVE_DRV_NONE) {
>> -            size = (parse->max_head + 1) * parse->max_track *
>> -                parse->last_sect;
>> -            if (nb_sectors == size) {
>> -                match = i;
>> -                break;
>> -            }
>> -            if (first_match == -1) {
>> -                first_match = i;
>> -            }
>> -        }
>> -    }
>> -    if (match == -1) {
>> -        if (first_match == -1) {
>> -            match = 1;
>> -        } else {
>> -            match = first_match;
>> -        }
>> -        parse = &fd_formats[match];
>> -    }
>> -    *nb_heads = parse->max_head + 1;
>> -    *max_track = parse->max_track;
>> -    *last_sect = parse->last_sect;
>> -    *drive = parse->drive;
>> -    *rate = parse->rate;
>> -}
>> -
>>   #define GET_CUR_DRV(fdctrl) ((fdctrl)->cur_drv)
>>   #define SET_CUR_DRV(fdctrl, drive) ((fdctrl)->cur_drv = (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 = -1;
>> +    first_match = -1;
>> +    for (i = 0; ; i++) {
>> +        parse = &fd_formats[i];
>> +        if (parse->drive == FDRIVE_DRV_NONE) {
>> +            break;
>> +        }
>> +        if (drive_in == parse->drive ||
>> +            drive_in == FDRIVE_DRV_NONE) {
>> +            size = (parse->max_head + 1) * parse->max_track *
>> +                parse->last_sect;
>> +            if (nb_sectors == size) {
>> +                match = i;
>> +                break;
>> +            }
>> +            if (first_match == -1) {
>> +                first_match = i;
>> +            }
>> +        }
>> +    }
>> +    if (match == -1) {
>> +        if (first_match == -1) {
>> +            match = 1;
>> +        } else {
>> +            match = first_match;
>> +        }
>> +        parse = &fd_formats[match];
>> +    }
>> +    *nb_heads = parse->max_head + 1;
>> +    *max_track = parse->max_track;
>> +    *last_sect = parse->last_sect;
>> +    *drive = parse->drive;
>> +    *rate = parse->rate;
>> +}
>> +
>>   /* Revalidate a disk drive after a disk change */
>>   static void fd_revalidate(FDrive *drv)
>>   {
> 
> 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.
> 
> Regards,
> 
> Hervé
> 

Actually, I'm going to decline on this -- I don't know precisely what
you need moved, and it's trivial for you to cut the headers out when you
need them. It'll be more work re-shuffling this series than it's worth
for me to then not get it completely right anyway.

Just ping me with a patch to move what you need and I will get that done
for you then, thanks.

--js



reply via email to

[Prev in Thread] Current Thread [Next in Thread]