All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
To: afaerber@suse.de, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH qom-next v1 3/6] misc: max111x: Create abstract max111x class
Date: Tue, 11 Feb 2014 16:29:00 -0800	[thread overview]
Message-ID: <bfc0d33b0c728408954429d1e601fb3dcd379d5f.1392164348.git.peter.crosthwaite@xilinx.com> (raw)
In-Reply-To: <cover.1392164348.git.peter.crosthwaite@xilinx.com>

Create an abstract class that encompasses both max111x variants. This is
needed for QOM cast macro creation (and is the right thing to do
anyway). Macroify type-names in the process.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 hw/misc/max111x.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/hw/misc/max111x.c b/hw/misc/max111x.c
index fcf2a4d..9e50e7e 100644
--- a/hw/misc/max111x.c
+++ b/hw/misc/max111x.c
@@ -22,6 +22,11 @@ typedef struct {
     int inputs, com;
 } MAX111xState;
 
+#define TYPE_MAX_111X "max111x"
+
+#define TYPE_MAX_1110 "max1110"
+#define TYPE_MAX_1111 "max1111"
+
 /* Control-byte bitfields */
 #define CB_PD0		(1 << 0)
 #define CB_PD1		(1 << 1)
@@ -154,18 +159,31 @@ void max111x_set_input(DeviceState *dev, int line, uint8_t value)
     s->input[line] = value;
 }
 
-static void max1110_class_init(ObjectClass *klass, void *data)
+static void max111x_class_init(ObjectClass *klass, void *data)
 {
     SSISlaveClass *k = SSI_SLAVE_CLASS(klass);
 
-    k->init = max1110_init;
     k->transfer = max111x_transfer;
 }
 
-static const TypeInfo max1110_info = {
-    .name          = "max1110",
+static const TypeInfo max111x_info = {
+    .name          = TYPE_MAX_111X,
     .parent        = TYPE_SSI_SLAVE,
     .instance_size = sizeof(MAX111xState),
+    .class_init    = max111x_class_init,
+    .abstract      = true,
+};
+
+static void max1110_class_init(ObjectClass *klass, void *data)
+{
+    SSISlaveClass *k = SSI_SLAVE_CLASS(klass);
+
+    k->init = max1110_init;
+}
+
+static const TypeInfo max1110_info = {
+    .name          = TYPE_MAX_1110,
+    .parent        = TYPE_MAX_111X,
     .class_init    = max1110_class_init,
 };
 
@@ -174,18 +192,17 @@ static void max1111_class_init(ObjectClass *klass, void *data)
     SSISlaveClass *k = SSI_SLAVE_CLASS(klass);
 
     k->init = max1111_init;
-    k->transfer = max111x_transfer;
 }
 
 static const TypeInfo max1111_info = {
-    .name          = "max1111",
-    .parent        = TYPE_SSI_SLAVE,
-    .instance_size = sizeof(MAX111xState),
+    .name          = TYPE_MAX_1111,
+    .parent        = TYPE_MAX_111X,
     .class_init    = max1111_class_init,
 };
 
 static void max111x_register_types(void)
 {
+    type_register_static(&max111x_info);
     type_register_static(&max1110_info);
     type_register_static(&max1111_info);
 }
-- 
1.8.5.4

  parent reply	other threads:[~2014-02-12  0:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12  0:27 [Qemu-devel] [PATCH qom-next v1 0/6] SSI QOM cleanups Peter Crosthwaite
2014-02-12  0:27 ` [Qemu-devel] [PATCH qom-next v1 1/6] ssi: Convert legacy casts from SSI_SLAVE->DEVICE Peter Crosthwaite
2014-03-04 22:07   ` Andreas Färber
2014-03-04 22:23     ` Andreas Färber
2014-02-12  0:28 ` [Qemu-devel] [PATCH qom-next v1 2/6] ssi: Remove legacy SSI_BUS->BUS cast Peter Crosthwaite
2014-03-04 20:43   ` Andreas Färber
2014-02-12  0:29 ` Peter Crosthwaite [this message]
2014-02-12  0:29 ` [Qemu-devel] [PATCH qom-next v1 4/6] misc: max111x: QOM casting sweep Peter Crosthwaite
2014-03-04 20:51   ` Andreas Färber
2014-02-12  0:30 ` [Qemu-devel] [PATCH qom-next v1 5/6] ssi: Remove SSI_SLAVE_FROM_QDEV macro Peter Crosthwaite
2014-02-12  0:30 ` [Qemu-devel] [PATCH qom-next v1 6/6] block/m25p80: Remove FROM_SSI_SLAVE usages Peter Crosthwaite
2014-03-04 20:57   ` Andreas Färber
2014-02-25  8:46 ` [Qemu-devel] [PATCH qom-next v1 0/6] SSI QOM cleanups Peter Crosthwaite
2014-02-25  8:51   ` Andreas Färber
2014-03-04 22:39     ` Andreas Färber
2014-03-04 23:32       ` Peter Crosthwaite

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=bfc0d33b0c728408954429d1e601fb3dcd379d5f.1392164348.git.peter.crosthwaite@xilinx.com \
    --to=peter.crosthwaite@xilinx.com \
    --cc=afaerber@suse.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@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.