Patchwork [RFC,3/8] uhci: do not use old_portio-style callbacks

login
register
mail settings
Submitter Hervé Poussineau
Date Dec. 23, 2012, 3:32 p.m.
Message ID <1356276769-7357-4-git-send-email-hpoussin@reactos.org>
Download mbox | patch
Permalink /patch/207980/
State New
Headers show

Comments

Hervé Poussineau - Dec. 23, 2012, 3:32 p.m.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/usb/hcd-uhci.c |   43 +++++++++++++++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 10 deletions(-)

Patch

diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index d053791..cc47635 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1213,18 +1213,41 @@  static void uhci_frame_timer(void *opaque)
     qemu_mod_timer(s->frame_timer, s->expire_time);
 }
 
-static const MemoryRegionPortio uhci_portio[] = {
-    { 0, 32, 2, .write = uhci_ioport_writew, },
-    { 0, 32, 2, .read = uhci_ioport_readw, },
-    { 0, 32, 4, .write = uhci_ioport_writel, },
-    { 0, 32, 4, .read = uhci_ioport_readl, },
-    { 0, 32, 1, .write = uhci_ioport_writeb, },
-    { 0, 32, 1, .read = uhci_ioport_readb, },
-    PORTIO_END_OF_LIST()
-};
+static uint64_t uhci_ioport_read(void *opaque, hwaddr addr, unsigned int size)
+{
+    switch (size) {
+    case 1:
+        return uhci_ioport_readb(opaque, (uint32_t)addr);
+    case 2:
+        return uhci_ioport_readw(opaque, (uint32_t)addr);
+    case 4:
+        return uhci_ioport_readl(opaque, (uint32_t)addr);
+    default:
+        return ~0UL;
+    }
+}
+
+static void uhci_ioport_write(void *opaque, hwaddr addr, uint64_t data,
+                              unsigned int size)
+{
+    switch (size) {
+    case 1:
+        uhci_ioport_writeb(opaque, (uint32_t)addr, (uint32_t)data);
+        break;
+    case 2:
+        uhci_ioport_writew(opaque, (uint32_t)addr, (uint32_t)data);
+        break;
+    case 4:
+        uhci_ioport_writel(opaque, (uint32_t)addr, (uint32_t)data);
+        break;
+    default:
+        break;
+    }
+}
 
 static const MemoryRegionOps uhci_ioport_ops = {
-    .old_portio = uhci_portio,
+    .read = uhci_ioport_read,
+    .write = uhci_ioport_write,
 };
 
 static USBPortOps uhci_port_ops = {