Skip to content

Commit

Permalink
hw/i386/pc: Merge two if statements into one
Browse files Browse the repository at this point in the history
By being the only entity assigning a non-NULL value to "rtc_irq", the first if
statement determines whether the second if statement is executed. So merge the
two statements into one.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-Id: <20231007123843.127151-2-shentey@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
shentok authored and mstsirkin committed Oct 19, 2023
1 parent 8d87983 commit 068f463
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions hw/i386/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
DeviceState *hpet = NULL;
int pit_isa_irq = 0;
qemu_irq pit_alt_irq = NULL;
qemu_irq rtc_irq = NULL;
ISADevice *pit = NULL;
MemoryRegion *ioport80_io = g_new(MemoryRegion, 1);
MemoryRegion *ioportF0_io = g_new(MemoryRegion, 1);
Expand All @@ -1219,6 +1218,8 @@ void pc_basic_device_init(struct PCMachineState *pcms,
*/
if (pcms->hpet_enabled && (!kvm_irqchip_in_kernel() ||
kvm_has_pit_state2())) {
qemu_irq rtc_irq;

hpet = qdev_try_new(TYPE_HPET);
if (!hpet) {
error_report("couldn't create HPET device");
Expand All @@ -1243,16 +1244,14 @@ void pc_basic_device_init(struct PCMachineState *pcms,
pit_isa_irq = -1;
pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);
rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);
}

if (rtc_irq) {
qdev_connect_gpio_out(DEVICE(rtc_state), 0, rtc_irq);
} else {
uint32_t irq = object_property_get_uint(OBJECT(rtc_state),
"irq",
&error_fatal);
isa_connect_gpio_out(rtc_state, 0, irq);
}

object_property_add_alias(OBJECT(pcms), "rtc-time", OBJECT(rtc_state),
"date");

Expand Down

0 comments on commit 068f463

Please sign in to comment.