qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v3 056/197] add I2CSlave to the type hierarchy


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH v3 056/197] add I2CSlave to the type hierarchy
Date: Mon, 12 Dec 2011 14:18:52 -0600

---
 hw/i2c.c |   15 +++++++++++++++
 hw/i2c.h |   13 +++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/hw/i2c.c b/hw/i2c.c
index 9efe70c..cdf88f2 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -194,3 +194,18 @@ DeviceState *i2c_create_slave(i2c_bus *bus, const char 
*name, uint8_t addr)
     qdev_init_nofail(dev);
     return dev;
 }
+
+static TypeInfo i2c_slave_type_info = {
+    .name = TYPE_I2C_SLAVE,
+    .parent = TYPE_DEVICE,
+    .instance_size = sizeof(I2CSlave),
+    .abstract = true,
+    .class_size = sizeof(I2CSlaveClass),
+};
+
+static void i2c_slave_register_devices(void)
+{
+    type_register_static(&i2c_slave_type_info);
+}
+
+device_init(i2c_slave_register_devices);
diff --git a/hw/i2c.h b/hw/i2c.h
index 28401f0..cc4d76b 100644
--- a/hw/i2c.h
+++ b/hw/i2c.h
@@ -26,6 +26,19 @@ typedef void (*i2c_event_cb)(I2CSlave *s, enum i2c_event 
event);
 
 typedef int (*i2c_slave_initfn)(I2CSlave *dev);
 
+#define TYPE_I2C_SLAVE "i2c-slave"
+#define I2C_SLAVE(obj) \
+     OBJECT_CHECK(I2CSlave, (obj), TYPE_I2C_SLAVE)
+#define I2C_SLAVE_CLASS(klass) \
+     OBJECT_CLASS_CHECK(I2CSlaveClass, (klass), TYPE_I2C_SLAVE)
+#define I2C_SLAVE_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(I2CSlaveClass, (obj), TYPE_I2C_SLAVE)
+
+typedef struct I2CSlaveClass
+{
+    DeviceClass parent_class;
+} I2CSlaveClass;
+
 typedef struct {
     DeviceInfo qdev;
 
-- 
1.7.4.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]