qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: mst@redhat.com, qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Cc: Stefan Berger <stefanb@us.ibm.com>,
	Stefan Berger <stefanb@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH] tpm: Move memory initialization into realize function
Date: Mon,  9 Mar 2015 19:51:39 -0400	[thread overview]
Message-ID: <1425945099-215293-1-git-send-email-stefanb@linux.vnet.ibm.com> (raw)

From: Stefan Berger <stefanb@us.ibm.com>

Move the memory initialization into the DeviceClass realize function due to
isa_address_space crashing if called in the instance init function.
A recent change must have changed the order in which structures are
initialized so that this move is now necessary.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
 hw/tpm/tpm_tis.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index d0bb97f..339e1bf 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -959,18 +959,12 @@ static void tpm_tis_realizefn(DeviceState *dev, Error **errp)
     tis->bh = qemu_bh_new(tpm_tis_receive_bh, s);
 
     isa_init_irq(&s->busdev, &tis->irq, tis->irq_num);
-}
-
-static void tpm_tis_initfn(Object *obj)
-{
-    ISADevice *dev = ISA_DEVICE(obj);
-    TPMState *s = TPM(obj);
 
     memory_region_init_io(&s->mmio, OBJECT(s), &tpm_tis_memory_ops,
                           s, "tpm-tis-mmio",
                           TPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT);
-    memory_region_add_subregion(isa_address_space(dev), TPM_TIS_ADDR_BASE,
-                                &s->mmio);
+    memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
+                                TPM_TIS_ADDR_BASE, &s->mmio);
 }
 
 static void tpm_tis_class_init(ObjectClass *klass, void *data)
@@ -987,7 +981,6 @@ static const TypeInfo tpm_tis_info = {
     .name = TYPE_TPM_TIS,
     .parent = TYPE_ISA_DEVICE,
     .instance_size = sizeof(TPMState),
-    .instance_init = tpm_tis_initfn,
     .class_init  = tpm_tis_class_init,
 };
 
-- 
2.1.0

             reply	other threads:[~2015-03-09 23:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09 23:51 Stefan Berger [this message]
2015-03-10  9:35 ` [Qemu-devel] [PATCH] tpm: Move memory initialization into realize function Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425945099-215293-1-git-send-email-stefanb@linux.vnet.ibm.com \
    --to=stefanb@linux.vnet.ibm.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanb@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).