diff mbox series

[4/6] hw/watchdog/wdt_i6300esb: Convert away from old_mmio

Message ID 20180601141223.26630-5-peter.maydell@linaro.org
State Superseded
Headers show
Series More conversions away from old_mmio | expand

Commit Message

Peter Maydell June 1, 2018, 2:12 p.m. UTC
Convert the wdt_i6300esb device away from using the old_mmio field
of MemoryRegionOps.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 hw/watchdog/wdt_i6300esb.c | 48 ++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 12 deletions(-)

-- 
2.17.1

Comments

Philippe Mathieu-Daudé June 11, 2018, 3:48 p.m. UTC | #1
On 06/01/2018 11:12 AM, Peter Maydell wrote:
> Convert the wdt_i6300esb device away from using the old_mmio field

> of MemoryRegionOps.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


> ---

>  hw/watchdog/wdt_i6300esb.c | 48 ++++++++++++++++++++++++++++----------

>  1 file changed, 36 insertions(+), 12 deletions(-)

> 

> diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c

> index e596b0804d..7b59469888 100644

> --- a/hw/watchdog/wdt_i6300esb.c

> +++ b/hw/watchdog/wdt_i6300esb.c

> @@ -361,19 +361,43 @@ static void i6300esb_mem_writel(void *vp, hwaddr addr, uint32_t val)

>      }

>  }

>  

> +static uint64_t i6300esb_mem_readfn(void *opaque, hwaddr addr, unsigned size)

> +{

> +    switch (size) {

> +    case 1:

> +        return i6300esb_mem_readb(opaque, addr);

> +    case 2:

> +        return i6300esb_mem_readw(opaque, addr);

> +    case 4:

> +        return i6300esb_mem_readl(opaque, addr);

> +    default:

> +        g_assert_not_reached();

> +    }

> +}

> +

> +static void i6300esb_mem_writefn(void *opaque, hwaddr addr,

> +                                 uint64_t value, unsigned size)

> +{

> +    switch (size) {

> +    case 1:

> +        i6300esb_mem_writeb(opaque, addr, value);

> +        break;

> +    case 2:

> +        i6300esb_mem_writew(opaque, addr, value);

> +        break;

> +    case 4:

> +        i6300esb_mem_writel(opaque, addr, value);

> +        break;

> +    default:

> +        g_assert_not_reached();

> +    }

> +}

> +

>  static const MemoryRegionOps i6300esb_ops = {

> -    .old_mmio = {

> -        .read = {

> -            i6300esb_mem_readb,

> -            i6300esb_mem_readw,

> -            i6300esb_mem_readl,

> -        },

> -        .write = {

> -            i6300esb_mem_writeb,

> -            i6300esb_mem_writew,

> -            i6300esb_mem_writel,

> -        },

> -    },

> +    .read = i6300esb_mem_readfn,

> +    .write = i6300esb_mem_writefn,

> +    .valid.min_access_size = 1,

> +    .valid.max_access_size = 4,

>      .endianness = DEVICE_LITTLE_ENDIAN,

>  };

>  

>
diff mbox series

Patch

diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
index e596b0804d..7b59469888 100644
--- a/hw/watchdog/wdt_i6300esb.c
+++ b/hw/watchdog/wdt_i6300esb.c
@@ -361,19 +361,43 @@  static void i6300esb_mem_writel(void *vp, hwaddr addr, uint32_t val)
     }
 }
 
+static uint64_t i6300esb_mem_readfn(void *opaque, hwaddr addr, unsigned size)
+{
+    switch (size) {
+    case 1:
+        return i6300esb_mem_readb(opaque, addr);
+    case 2:
+        return i6300esb_mem_readw(opaque, addr);
+    case 4:
+        return i6300esb_mem_readl(opaque, addr);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+static void i6300esb_mem_writefn(void *opaque, hwaddr addr,
+                                 uint64_t value, unsigned size)
+{
+    switch (size) {
+    case 1:
+        i6300esb_mem_writeb(opaque, addr, value);
+        break;
+    case 2:
+        i6300esb_mem_writew(opaque, addr, value);
+        break;
+    case 4:
+        i6300esb_mem_writel(opaque, addr, value);
+        break;
+    default:
+        g_assert_not_reached();
+    }
+}
+
 static const MemoryRegionOps i6300esb_ops = {
-    .old_mmio = {
-        .read = {
-            i6300esb_mem_readb,
-            i6300esb_mem_readw,
-            i6300esb_mem_readl,
-        },
-        .write = {
-            i6300esb_mem_writeb,
-            i6300esb_mem_writew,
-            i6300esb_mem_writel,
-        },
-    },
+    .read = i6300esb_mem_readfn,
+    .write = i6300esb_mem_writefn,
+    .valid.min_access_size = 1,
+    .valid.max_access_size = 4,
     .endianness = DEVICE_LITTLE_ENDIAN,
 };