From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQG3B-0003R0-5u for qemu-devel@nongnu.org; Tue, 24 Feb 2015 09:01:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQG33-0007ea-GJ for qemu-devel@nongnu.org; Tue, 24 Feb 2015 09:01:25 -0500 Received: from cantor2.suse.de ([195.135.220.15]:44195 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQG33-0007dU-7F for qemu-devel@nongnu.org; Tue, 24 Feb 2015 09:01:17 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 24 Feb 2015 14:58:27 +0100 Message-Id: <1424786311-22387-8-git-send-email-afaerber@suse.de> In-Reply-To: <1424786311-22387-1-git-send-email-afaerber@suse.de> References: <1424786311-22387-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 07/10] serial: Factor out common serial_hds_isa_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Markus Armbruster , Blue Swirl , Anthony Liguori , Paolo Bonzini , Leon Alrae , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Aurelien Jarno , Richard Henderson From: Markus Armbruster It's the same old loop copied five times, plus another instance where it's clipped to two iterations and unrolled. No external users of serial_isa_init() are left, so give it internal linkage. Maintainers of affected machines cc'ed. Cc: Richard Henderson Cc: Anthony Liguori Cc: "Michael S. Tsirkin" Cc: Aurelien Jarno Cc: Leon Alrae Cc: Blue Swirl Signed-off-by: Markus Armbruster Signed-off-by: Andreas F=C3=A4rber --- hw/alpha/dp264.c | 6 +----- hw/char/serial-isa.c | 15 ++++++++++++++- hw/i386/pc.c | 6 +----- hw/mips/mips_fulong2e.c | 7 +------ hw/mips/mips_malta.c | 3 +-- hw/mips/mips_r4k.c | 6 +----- hw/sparc64/sun4u.c | 7 ++----- include/hw/char/serial.h | 2 +- 8 files changed, 22 insertions(+), 30 deletions(-) diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index 84a55e4..e82d61d 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -83,11 +83,7 @@ static void clipper_init(MachineState *machine) pci_vga_init(pci_bus); =20 /* Serial code setup. */ - for (i =3D 0; i < MAX_SERIAL_PORTS; ++i) { - if (serial_hds[i]) { - serial_isa_init(isa_bus, i, serial_hds[i]); - } - } + serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); =20 /* Network setup. e1000 is good enough, failing Tulip support. */ for (i =3D 0; i < nb_nics; i++) { diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c index c9fcb27..059ceb8 100644 --- a/hw/char/serial-isa.c +++ b/hw/char/serial-isa.c @@ -119,7 +119,7 @@ static void serial_register_types(void) =20 type_init(serial_register_types) =20 -bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr) +static bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr= ) { DeviceState *dev; ISADevice *isadev; @@ -136,3 +136,16 @@ bool serial_isa_init(ISABus *bus, int index, CharDri= verState *chr) } return true; } + +void serial_hds_isa_init(ISABus *bus, int n) +{ + int i; + + assert(n <=3D MAX_SERIAL_PORTS); + + for (i =3D 0; i < n; ++i) { + if (serial_hds[i]) { + serial_isa_init(bus, i, serial_hds[i]); + } + } +} diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c7af6aa..18ed263 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1419,11 +1419,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_ir= q *gsi, pcspk_init(isa_bus, pit); } =20 - for(i =3D 0; i < MAX_SERIAL_PORTS; i++) { - if (serial_hds[i]) { - serial_isa_init(isa_bus, i, serial_hds[i]); - } - } + serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); =20 for(i =3D 0; i < MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 6a9ebfa..bebf7de 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -277,7 +277,6 @@ static void mips_fulong2e_init(MachineState *machine) PCIBus *pci_bus; ISABus *isa_bus; I2CBus *smbus; - int i; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; MIPSCPU *cpu; CPUMIPSState *env; @@ -384,11 +383,7 @@ static void mips_fulong2e_init(MachineState *machine= ) =20 rtc_init(isa_bus, 2000, NULL); =20 - for(i =3D 0; i < MAX_SERIAL_PORTS; i++) { - if (serial_hds[i]) { - serial_isa_init(isa_bus, i, serial_hds[i]); - } - } + serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); =20 if (parallel_hds[0]) { parallel_init(isa_bus, 0, parallel_hds[0]); diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index 5845158..e57f78c 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -1172,8 +1172,7 @@ void mips_malta_init(MachineState *machine) isa_create_simple(isa_bus, "i8042"); =20 rtc_init(isa_bus, 2000, NULL); - serial_isa_init(isa_bus, 0, serial_hds[0]); - serial_isa_init(isa_bus, 1, serial_hds[1]); + serial_hds_isa_init(isa_bus, 2); if (parallel_hds[0]) parallel_init(isa_bus, 0, parallel_hds[0]); for(i =3D 0; i < MAX_FD; i++) { diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c index a7fe0ce..1698f2d 100644 --- a/hw/mips/mips_r4k.c +++ b/hw/mips/mips_r4k.c @@ -283,11 +283,7 @@ void mips_r4k_init(MachineState *machine) =20 pit =3D pit_init(isa_bus, 0x40, 0, NULL); =20 - for(i =3D 0; i < MAX_SERIAL_PORTS; i++) { - if (serial_hds[i]) { - serial_isa_init(isa_bus, i, serial_hds[i]); - } - } + serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); =20 isa_vga_init(isa_bus); =20 diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 3ff5bd8..082b8e0 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -849,11 +849,8 @@ static void sun4uv_init(MemoryRegion *address_space_= mem, NULL, 115200, serial_hds[i], DEVICE_BIG_ENDIAN); i++; } - for(; i < MAX_SERIAL_PORTS; i++) { - if (serial_hds[i]) { - serial_isa_init(isa_bus, i, serial_hds[i]); - } - } + + serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS); =20 for(i =3D 0; i < MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index f431764..15beb6b 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -92,6 +92,6 @@ SerialState *serial_mm_init(MemoryRegion *address_space= , =20 /* serial-isa.c */ #define TYPE_ISA_SERIAL "isa-serial" -bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr); +void serial_hds_isa_init(ISABus *bus, int n); =20 #endif --=20 2.1.4