Skip to content

Commit

Permalink
pc: Use PCMachineState for pc_cmos_init() argument
Browse files Browse the repository at this point in the history
pc_cmos_init() already expects a PCMachineState object, there's no point
in upcasting it to MachineState before calling the function.

While doing it, reorder the arguments so PCMachineState is the first
function argument.

Signed-off-by: Eduardo Habkost <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
ehabkost authored and mstsirkin committed Aug 13, 2015
1 parent 4458fb3 commit 23d3040
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
10 changes: 5 additions & 5 deletions hw/i386/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,14 @@ static void pc_cmos_init_late(void *opaque)
qemu_unregister_reset(pc_cmos_init_late, opaque);
}

void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device, MachineState *machine,
void pc_cmos_init(PCMachineState *pcms,
ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device,
BusState *idebus0, BusState *idebus1,
ISADevice *s)
{
int val;
static pc_cmos_init_late_arg arg;
PCMachineState *pcms = PC_MACHINE(machine);
Error *local_err = NULL;

/* various important CMOS locations needed by PC/Bochs bios */
Expand Down Expand Up @@ -476,12 +476,12 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
/* set the number of CPU */
rtc_set_memory(s, 0x5f, smp_cpus - 1);

object_property_add_link(OBJECT(machine), "rtc_state",
object_property_add_link(OBJECT(pcms), "rtc_state",
TYPE_ISA_DEVICE,
(Object **)&pcms->rtc,
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
object_property_set_link(OBJECT(machine), OBJECT(s),
object_property_set_link(OBJECT(pcms), OBJECT(s),
"rtc_state", &error_abort);

set_boot_dev(s, boot_device, &local_err);
Expand Down
5 changes: 3 additions & 2 deletions hw/i386/pc_piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ static void pc_init1(MachineState *machine)
}
}

pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
machine, idebus[0], idebus[1], rtc_state);
pc_cmos_init(pcms,
below_4g_mem_size, above_4g_mem_size, machine->boot_order,
idebus[0], idebus[1], rtc_state);

if (pci_enabled && usb_enabled()) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
Expand Down
5 changes: 3 additions & 2 deletions hw/i386/pc_q35.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ static void pc_q35_init(MachineState *machine)
0xb100),
8, NULL, 0);

pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
machine, idebus[0], idebus[1], rtc_state);
pc_cmos_init(pcms,
below_4g_mem_size, above_4g_mem_size, machine->boot_order,
idebus[0], idebus[1], rtc_state);

/* the rest devices to which pci devfn is automatically assigned */
pc_vga_init(isa_bus, host_bus);
Expand Down
5 changes: 3 additions & 2 deletions include/hw/i386/pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
bool no_vmport,
uint32 hpet_irqs);
void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device, MachineState *machine,
void pc_cmos_init(PCMachineState *pcms,
ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device,
BusState *ide0, BusState *ide1,
ISADevice *s);
void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus);
Expand Down

0 comments on commit 23d3040

Please sign in to comment.