Patchwork [1/7] Add scoop post_load callback that sets IRQs to loaded levels

login
register
mail settings
Submitter Dmitry Eremin-Solenikov
Date Feb. 11, 2011, 8:57 p.m.
Message ID <1297457859-15685-1-git-send-email-dbaryshkov@gmail.com>
Download mbox | patch
Permalink /patch/82834/
State New
Headers show

Comments

Dmitry Eremin-Solenikov - Feb. 11, 2011, 8:57 p.m.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 hw/zaurus.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
andrzej zaborowski - Feb. 11, 2011, 10:37 p.m.
On 11 February 2011 21:57, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
>  hw/zaurus.c |   19 ++++++++++++++++++-
>  1 files changed, 18 insertions(+), 1 deletions(-)
>
> diff --git a/hw/zaurus.c b/hw/zaurus.c
> index fca11a5..fb5e228 100644
> --- a/hw/zaurus.c
> +++ b/hw/zaurus.c
> @@ -181,17 +181,34 @@ static int scoop_init(SysBusDevice *dev)
>     return 0;
>  }
>
> +static int scoop_post_load(void *opaque, int version_id)
> +{
> +    ScoopInfo *s = (ScoopInfo *) opaque;
> +    int i;
> +    uint32_t level;
> +
> +    level = s->gpio_level & s->gpio_dir;
> +
> +    for (i = 0; i < 16; i++) {
> +        qemu_set_irq(s->handler[i], (level >> i) & 1);
> +    }
> +
> +    s->prev_level = level;
> +
> +    return 0;
> +}
> +
>  static bool is_version_0 (void *opaque, int version_id)
>  {
>     return version_id == 0;
>  }
>
> -
>  static const VMStateDescription vmstate_scoop_regs = {
>     .name = "scoop",
>     .version_id = 1,
>     .minimum_version_id = 0,
>     .minimum_version_id_old = 0,
> +    .post_load = scoop_post_load,
>     .fields = (VMStateField []) {
>         VMSTATE_UINT16(status, ScoopInfo),
>         VMSTATE_UINT16(power, ScoopInfo),
> --
> 1.7.2.3

Thanks, pushed all 7 changes and also dropped the pxa.h #include in
hw/mst_fpga.c

Cheers

Patch

diff --git a/hw/zaurus.c b/hw/zaurus.c
index fca11a5..fb5e228 100644
--- a/hw/zaurus.c
+++ b/hw/zaurus.c
@@ -181,17 +181,34 @@  static int scoop_init(SysBusDevice *dev)
     return 0;
 }
 
+static int scoop_post_load(void *opaque, int version_id)
+{
+    ScoopInfo *s = (ScoopInfo *) opaque;
+    int i;
+    uint32_t level;
+
+    level = s->gpio_level & s->gpio_dir;
+
+    for (i = 0; i < 16; i++) {
+        qemu_set_irq(s->handler[i], (level >> i) & 1);
+    }
+
+    s->prev_level = level;
+
+    return 0;
+}
+
 static bool is_version_0 (void *opaque, int version_id)
 {
     return version_id == 0;
 }
 
-
 static const VMStateDescription vmstate_scoop_regs = {
     .name = "scoop",
     .version_id = 1,
     .minimum_version_id = 0,
     .minimum_version_id_old = 0,
+    .post_load = scoop_post_load,
     .fields = (VMStateField []) {
         VMSTATE_UINT16(status, ScoopInfo),
         VMSTATE_UINT16(power, ScoopInfo),