Patchwork [49/61] pci hot add: pass opaque argument to callback.

login
register
mail settings
Submitter Isaku Yamahata
Date Sept. 30, 2009, 10:18 a.m.
Message ID <1254305917-14784-50-git-send-email-yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/34547/
State Superseded
Headers show

Comments

Isaku Yamahata - Sept. 30, 2009, 10:18 a.m.
pass opaque argument to callback.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/acpi.c       |    8 ++++++--
 hw/acpi_piix4.c |    6 +++---
 sysemu.h        |    4 ++--
 3 files changed, 11 insertions(+), 7 deletions(-)

Patch

diff --git a/hw/acpi.c b/hw/acpi.c
index 44056a1..4b1c5c8 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -22,15 +22,19 @@ 
 #include "acpi.h"
 
 static qemu_system_device_hot_add_t device_hot_add_callback;
-void qemu_system_device_hot_add_register(qemu_system_device_hot_add_t callback)
+static void *device_hot_add_arg;
+
+void qemu_system_device_hot_add_register(qemu_system_device_hot_add_t callback,
+void *opaque)
 {
     device_hot_add_callback = callback;
+    device_hot_add_arg = opaque;
 }
 
 void qemu_system_device_hot_add(int pcibus, int slot, int state)
 {
     if (device_hot_add_callback)
-        device_hot_add_callback(pcibus, slot, state);
+        device_hot_add_callback(pcibus, slot, state, device_hot_add_arg);
 }
 
 struct acpi_table_header
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 5f3ee9a..c11e1b9 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -526,7 +526,7 @@  static void pciej_write(void *opaque, uint32_t addr, uint32_t val)
 #endif
 }
 
-static void piix4_device_hot_add(int bus, int slot, int state);
+static void piix4_device_hot_add(int bus, int slot, int state, void* opaque);
 
 void piix4_acpi_system_hot_add_init(void)
 {
@@ -539,7 +539,7 @@  void piix4_acpi_system_hot_add_init(void)
     register_ioport_write(PCI_EJ_BASE, 4, 4, pciej_write, NULL);
     register_ioport_read(PCI_EJ_BASE, 4, 4,  pciej_read, NULL);
 
-    qemu_system_device_hot_add_register(piix4_device_hot_add);
+    qemu_system_device_hot_add_register(piix4_device_hot_add, NULL);
 }
 
 static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot)
@@ -554,7 +554,7 @@  static void disable_device(struct pci_status *p, struct gpe_regs *g, int slot)
     p->down |= (1 << slot);
 }
 
-static void piix4_device_hot_add(int bus, int slot, int state)
+static void piix4_device_hot_add(int bus, int slot, int state, void *opaque)
 {
     pci0_status.up = 0;
     pci0_status.down = 0;
diff --git a/sysemu.h b/sysemu.h
index 8bf90ee..1450c65 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -198,8 +198,8 @@  extern QemuOpts *drive_add(const char *file, const char *fmt, ...);
 extern DriveInfo *drive_init(QemuOpts *arg, void *machine, int *fatal_error);
 
 /* acpi */
-typedef void (*qemu_system_device_hot_add_t)(int pcibus, int slot, int state);
-void qemu_system_device_hot_add_register(qemu_system_device_hot_add_t callback);
+typedef void (*qemu_system_device_hot_add_t)(int pcibus, int slot, int state, void *opaque);
+void qemu_system_device_hot_add_register(qemu_system_device_hot_add_t callback, void *opaque);
 void qemu_system_device_hot_add(int pcibus, int slot, int state);
 
 /* device-hotplug */