Patchwork [1/2] applesmc: convert portio to memory API

login
register
mail settings
Submitter Benoit Canet
Date Dec. 1, 2011, 4:57 p.m.
Message ID <1322758625-15384-2-git-send-email-benoit.canet@gmail.com>
Download mbox | patch
Permalink /patch/128731/
State New
Headers show

Comments

Benoit Canet - Dec. 1, 2011, 4:57 p.m.
Signed-off-by: BenoƮt Canet <benoit.canet@gmail.com>
---
 hw/applesmc.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

Patch

diff --git a/hw/applesmc.c b/hw/applesmc.c
index c47b592..fb11bdf 100644
--- a/hw/applesmc.c
+++ b/hw/applesmc.c
@@ -165,6 +165,16 @@  static uint32_t applesmc_io_cmd_readb(void *opaque, uint32_t addr1)
     return s->status;
 }
 
+static const MemoryRegionPortio applesmc_portio_list[] = {
+    { APPLESMC_DATA_PORT, 4, 1,
+      .read = applesmc_io_data_readb,
+      .write = applesmc_io_data_writeb },
+    { APPLESMC_CMD_PORT, 4, 1,
+      .read = applesmc_io_cmd_readb,
+      .write = applesmc_io_cmd_writeb },
+    PORTIO_END_OF_LIST(),
+};
+
 static void applesmc_add_key(struct AppleSMCStatus *s, const char *key,
                              int len, const char *data)
 {
@@ -200,14 +210,8 @@  static int applesmc_isa_init(ISADevice *dev)
 {
     struct AppleSMCStatus *s = DO_UPCAST(struct AppleSMCStatus, dev, dev);
 
-    register_ioport_read(s->iobase + APPLESMC_DATA_PORT, 4, 1,
-                         applesmc_io_data_readb, s);
-    register_ioport_read(s->iobase + APPLESMC_CMD_PORT, 4, 1,
-                         applesmc_io_cmd_readb, s);
-    register_ioport_write(s->iobase + APPLESMC_DATA_PORT, 4, 1,
-                          applesmc_io_data_writeb, s);
-    register_ioport_write(s->iobase + APPLESMC_CMD_PORT, 4, 1,
-                          applesmc_io_cmd_writeb, s);
+    isa_register_portio_list(dev, s->iobase, applesmc_portio_list, s,
+                             "applesmc");
 
     if (!s->osk || (strlen(s->osk) != 64)) {
         fprintf(stderr, "WARNING: Using AppleSMC with invalid key\n");