All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: qemu-ppc@nongnu.org, clg@kaod.org
Cc: gkurz@kaod.org, qemu-devel@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 2/4] xics: Merge reset and realize hooks
Date: Tue, 24 Sep 2019 14:59:50 +1000	[thread overview]
Message-ID: <20190924045952.11412-3-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20190924045952.11412-1-david@gibson.dropbear.id.au>

Currently TYPE_XICS_BASE and TYPE_XICS_SIMPLE have their own reset and
realize methods, using the standard technique for having the subtype
call the supertype's methods before doing its own thing.

But TYPE_XICS_SIMPLE is the only subtype of TYPE_XICS_BASE ever
instantiated, so there's no point having the split here.  Merge them
together into just ics_reset() and ics_realize() functions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/intc/xics.c        | 97 ++++++++++++++++---------------------------
 include/hw/ppc/xics.h |  3 --
 2 files changed, 35 insertions(+), 65 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 93139b0189..db0e532bd9 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -548,68 +548,13 @@ static void ics_eoi(ICSState *ics, uint32_t nr)
     }
 }
 
-static void ics_simple_reset(DeviceState *dev)
-{
-    ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev);
-
-    icsc->parent_reset(dev);
-
-    if (kvm_irqchip_in_kernel()) {
-        Error *local_err = NULL;
-
-        ics_set_kvm_state(ICS_BASE(dev), &local_err);
-        if (local_err) {
-            error_report_err(local_err);
-        }
-    }
-}
-
-static void ics_simple_reset_handler(void *dev)
-{
-    ics_simple_reset(dev);
-}
-
-static void ics_simple_realize(DeviceState *dev, Error **errp)
-{
-    ICSState *ics = ICS_SIMPLE(dev);
-    ICSStateClass *icsc = ICS_BASE_GET_CLASS(ics);
-    Error *local_err = NULL;
-
-    icsc->parent_realize(dev, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-        return;
-    }
-
-    qemu_register_reset(ics_simple_reset_handler, ics);
-}
-
-static void ics_simple_class_init(ObjectClass *klass, void *data)
-{
-    DeviceClass *dc = DEVICE_CLASS(klass);
-    ICSStateClass *isc = ICS_BASE_CLASS(klass);
-
-    device_class_set_parent_realize(dc, ics_simple_realize,
-                                    &isc->parent_realize);
-    device_class_set_parent_reset(dc, ics_simple_reset,
-                                  &isc->parent_reset);
-}
-
-static const TypeInfo ics_simple_info = {
-    .name = TYPE_ICS_SIMPLE,
-    .parent = TYPE_ICS_BASE,
-    .instance_size = sizeof(ICSState),
-    .class_init = ics_simple_class_init,
-    .class_size = sizeof(ICSStateClass),
-};
-
 static void ics_reset_irq(ICSIRQState *irq)
 {
     irq->priority = 0xff;
     irq->saved_priority = 0xff;
 }
 
-static void ics_base_reset(DeviceState *dev)
+static void ics_reset(DeviceState *dev)
 {
     ICSState *ics = ICS_BASE(dev);
     int i;
@@ -625,17 +570,31 @@ static void ics_base_reset(DeviceState *dev)
         ics_reset_irq(ics->irqs + i);
         ics->irqs[i].flags = flags[i];
     }
+
+    if (kvm_irqchip_in_kernel()) {
+        Error *local_err = NULL;
+
+        ics_set_kvm_state(ICS_BASE(dev), &local_err);
+        if (local_err) {
+            error_report_err(local_err);
+        }
+    }
+}
+
+static void ics_reset_handler(void *dev)
+{
+    ics_reset(dev);
 }
 
-static void ics_base_realize(DeviceState *dev, Error **errp)
+static void ics_realize(DeviceState *dev, Error **errp)
 {
     ICSState *ics = ICS_BASE(dev);
+    Error *local_err = NULL;
     Object *obj;
-    Error *err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err);
+    obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &local_err);
     if (!obj) {
-        error_propagate_prepend(errp, err,
+        error_propagate_prepend(errp, local_err,
                                 "required link '" ICS_PROP_XICS
                                 "' not found: ");
         return;
@@ -647,8 +606,22 @@ static void ics_base_realize(DeviceState *dev, Error **errp)
         return;
     }
     ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));
+
+    qemu_register_reset(ics_reset_handler, ics);
+}
+
+static void ics_simple_class_init(ObjectClass *klass, void *data)
+{
 }
 
+static const TypeInfo ics_simple_info = {
+    .name = TYPE_ICS_SIMPLE,
+    .parent = TYPE_ICS_BASE,
+    .instance_size = sizeof(ICSState),
+    .class_init = ics_simple_class_init,
+    .class_size = sizeof(ICSStateClass),
+};
+
 static void ics_base_instance_init(Object *obj)
 {
     ICSState *ics = ICS_BASE(obj);
@@ -725,9 +698,9 @@ static void ics_base_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->realize = ics_base_realize;
+    dc->realize = ics_realize;
     dc->props = ics_base_properties;
-    dc->reset = ics_base_reset;
+    dc->reset = ics_reset;
     dc->vmsd = &vmstate_ics_base;
 }
 
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 34d7985b7c..0eb39c2561 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -103,9 +103,6 @@ struct PnvICPState {
 
 struct ICSStateClass {
     DeviceClass parent_class;
-
-    DeviceRealize parent_realize;
-    DeviceReset parent_reset;
 };
 
 struct ICSState {
-- 
2.21.0



  parent reply	other threads:[~2019-09-24  5:06 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-24  4:59 [PATCH 0/4] xics: Eliminate unnecessary class David Gibson
2019-09-24  4:59 ` [PATCH 1/4] xics: Eliminate 'reject', 'resend' and 'eoi' class hooks David Gibson
2019-09-24  5:23   ` Cédric Le Goater
2019-09-24  7:28   ` Greg Kurz
2019-09-24  4:59 ` David Gibson [this message]
2019-09-24  5:26   ` [PATCH 2/4] xics: Merge reset and realize hooks Cédric Le Goater
2019-09-24  7:36   ` Greg Kurz
2019-09-24  9:44   ` Philippe Mathieu-Daudé
2019-09-24 11:40     ` David Gibson
2019-09-24  4:59 ` [PATCH 3/4] xics: Rename misleading ics_simple_*() functions David Gibson
2019-09-24  5:26   ` Cédric Le Goater
2019-09-24  7:38   ` Greg Kurz
2019-09-24  4:59 ` [PATCH 4/4] xics: Merge TYPE_ICS_BASE and TYPE_ICS_SIMPLE classes David Gibson
2019-09-24  5:31   ` Cédric Le Goater
2019-09-24 11:41     ` David Gibson
2019-09-24 14:06       ` Cédric Le Goater
2019-09-25  1:46         ` David Gibson
2019-09-25  6:04           ` Cédric Le Goater
2019-10-03 17:53             ` Cédric Le Goater
2019-09-24  7:40   ` Greg Kurz
2019-09-24  9:46   ` Philippe Mathieu-Daudé
2019-09-24  5:22 ` [PATCH 0/4] xics: Eliminate unnecessary class Cédric Le Goater
2019-09-24  7:52   ` Greg Kurz
2019-09-24  9:55     ` Cédric Le Goater
2019-09-24 10:04       ` Philippe Mathieu-Daudé
2019-09-24 11:00         ` Cédric Le Goater
2019-09-26  1:28           ` David Gibson
2019-09-24  9:47 ` Philippe Mathieu-Daudé
2019-09-24 10:06   ` Greg Kurz
2019-09-24 10:22     ` Philippe Mathieu-Daudé

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=20190924045952.11412-3-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=gkurz@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.