summaryrefslogtreecommitdiff
path: root/hw/acpi
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-07-07 19:50:23 +0200
committerAndreas Färber <afaerber@suse.de>2013-09-03 12:25:55 +0200
commit38fcbd3f08375eb2986b9b63ccd4f593e71aa99d (patch)
tree59da51d17fb6e9aed5da12c26f2bebd8ccfb6dce /hw/acpi
parentbdc44640cb33c90809376a262df871a1144d339a (diff)
downloadqemu-38fcbd3f08375eb2986b9b63ccd4f593e71aa99d.tar.gz
cpu: Replace qemu_for_each_cpu()
It was introduced to loop over CPUs from target-independent code, but since commit 182735efaf956ccab50b6d74a4fed163e0f35660 target-independent CPUState is used. A loop can be considered more efficient than function calls in a loop, and CPU_FOREACH() hides implementation details just as well, so use that instead. Suggested-by: Markus Armbruster <armbru@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/acpi')
-rw-r--r--hw/acpi/piix4.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 613d98736a..0b8d1d9da9 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -667,22 +667,14 @@ static void piix4_cpu_added_req(Notifier *n, void *opaque)
piix4_cpu_hotplug_req(s, CPU(opaque), PLUG);
}
-static void piix4_init_cpu_status(CPUState *cpu, void *data)
-{
- CPUStatus *g = (CPUStatus *)data;
- CPUClass *k = CPU_GET_CLASS(cpu);
- int64_t id = k->get_arch_id(cpu);
-
- g_assert((id / 8) < PIIX4_PROC_LEN);
- g->sts[id / 8] |= (1 << (id % 8));
-}
-
static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,
PCIHotplugState state);
static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
PCIBus *bus, PIIX4PMState *s)
{
+ CPUState *cpu;
+
memory_region_init_io(&s->io_gpe, OBJECT(s), &piix4_gpe_ops, s,
"acpi-gpe0", GPE_LEN);
memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);
@@ -693,7 +685,13 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
&s->io_pci);
pci_bus_hotplug(bus, piix4_device_hotplug, DEVICE(s));
- qemu_for_each_cpu(piix4_init_cpu_status, &s->gpe_cpu);
+ CPU_FOREACH(cpu) {
+ CPUClass *cc = CPU_GET_CLASS(cpu);
+ int64_t id = cc->get_arch_id(cpu);
+
+ g_assert((id / 8) < PIIX4_PROC_LEN);
+ s->gpe_cpu.sts[id / 8] |= (1 << (id % 8));
+ }
memory_region_init_io(&s->io_cpu, OBJECT(s), &cpu_hotplug_ops, s,
"acpi-cpu-hotplug", PIIX4_PROC_LEN);
memory_region_add_subregion(parent, PIIX4_PROC_BASE, &s->io_cpu);