[PATCH v3 3/4] fdc: Inline fdctrl_connect_drives() into fdctrl_realize_common()

Markus Armbruster posted 4 patches 4 years, 8 months ago
Maintainers: Max Reitz <mreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Markus Armbruster <armbru@redhat.com>, John Snow <jsnow@redhat.com>
There is a newer version of this series
[PATCH v3 3/4] fdc: Inline fdctrl_connect_drives() into fdctrl_realize_common()
Posted by Markus Armbruster 4 years, 8 months ago
The previous commit rendered the name fdctrl_connect_drives() somewhat
misleading.  Get rid of it by inlining the (now pretty simple)
function into its only caller.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/block/fdc.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index f978ddf647..32701c2bc5 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2511,20 +2511,6 @@ void isa_fdc_init_drives(ISADevice *fdc, DriveInfo **fds)
     fdctrl_init_drives(&ISA_FDC(fdc)->state.bus, fds);
 }
 
-static void fdctrl_connect_drives(FDCtrl *fdctrl, DeviceState *fdc_dev,
-                                  Error **errp)
-{
-    unsigned int i;
-    FDrive *drive;
-
-    for (i = 0; i < MAX_FD; i++) {
-        drive = &fdctrl->drives[i];
-        drive->fdctrl = fdctrl;
-        fd_init(drive);
-        fd_revalidate(drive);
-    }
-}
-
 void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
                         hwaddr mmio_base, DriveInfo **fds)
 {
@@ -2565,6 +2551,7 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
                                   Error **errp)
 {
     int i, j;
+    FDrive *drive;
     static int command_tables_inited = 0;
 
     if (fdctrl->fallback == FLOPPY_DRIVE_TYPE_AUTO) {
@@ -2604,7 +2591,13 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
     }
 
     floppy_bus_create(fdctrl, &fdctrl->bus, dev);
-    fdctrl_connect_drives(fdctrl, dev, errp);
+
+    for (i = 0; i < MAX_FD; i++) {
+        drive = &fdctrl->drives[i];
+        drive->fdctrl = fdctrl;
+        fd_init(drive);
+        fd_revalidate(drive);
+    }
 }
 
 static const MemoryRegionPortio fdc_portio_list[] = {
-- 
2.26.2

Re: [PATCH v3 3/4] fdc: Inline fdctrl_connect_drives() into fdctrl_realize_common()
Posted by Richard Henderson 4 years, 8 months ago
On 3/9/21 8:12 AM, Markus Armbruster wrote:
> @@ -2565,6 +2551,7 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
>                                     Error **errp)
>   {
>       int i, j;
> +    FDrive *drive;
>       static int command_tables_inited = 0;
>   
>       if (fdctrl->fallback == FLOPPY_DRIVE_TYPE_AUTO) {
> @@ -2604,7 +2591,13 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
>       }
>   
>       floppy_bus_create(fdctrl, &fdctrl->bus, dev);
> -    fdctrl_connect_drives(fdctrl, dev, errp);
> +
> +    for (i = 0; i < MAX_FD; i++) {
> +        drive = &fdctrl->drives[i];

FWIW, the declaration could be local to this loop.

r~

Re: [PATCH v3 3/4] fdc: Inline fdctrl_connect_drives() into fdctrl_realize_common()
Posted by Markus Armbruster 4 years, 8 months ago
Richard Henderson <richard.henderson@linaro.org> writes:

> On 3/9/21 8:12 AM, Markus Armbruster wrote:
>> @@ -2565,6 +2551,7 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
>>                                     Error **errp)
>>   {
>>       int i, j;
>> +    FDrive *drive;
>>       static int command_tables_inited = 0;
>>         if (fdctrl->fallback == FLOPPY_DRIVE_TYPE_AUTO) {
>> @@ -2604,7 +2591,13 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
>>       }
>>         floppy_bus_create(fdctrl, &fdctrl->bus, dev);
>> -    fdctrl_connect_drives(fdctrl, dev, errp);
>> +
>> +    for (i = 0; i < MAX_FD; i++) {
>> +        drive = &fdctrl->drives[i];
>
> FWIW, the declaration could be local to this loop.

Old-school habits.  John, got a preference?