qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v3 057/197] add SMBusDevice to the type hiearchy


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH v3 057/197] add SMBusDevice to the type hiearchy
Date: Mon, 12 Dec 2011 14:18:53 -0600

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

diff --git a/hw/smbus.c b/hw/smbus.c
index 0cb3566..a75d404 100644
--- a/hw/smbus.c
+++ b/hw/smbus.c
@@ -316,3 +316,18 @@ void smbus_write_block(i2c_bus *bus, uint8_t addr, uint8_t 
command, uint8_t *dat
         i2c_send(bus, data[i]);
     i2c_end_transfer(bus);
 }
+
+static TypeInfo smbus_device_type_info = {
+    .name = TYPE_SMBUS_DEVICE,
+    .parent = TYPE_I2C_SLAVE,
+    .instance_size = sizeof(SMBusDevice),
+    .abstract = true,
+    .class_size = sizeof(SMBusDeviceClass),
+};
+
+static void smbus_device_register_devices(void)
+{
+    type_register_static(&smbus_device_type_info);
+}
+
+device_init(smbus_device_register_devices);
diff --git a/hw/smbus.h b/hw/smbus.h
index 2f2d49e..9dd055c 100644
--- a/hw/smbus.h
+++ b/hw/smbus.h
@@ -24,6 +24,19 @@
 
 #include "i2c.h"
 
+#define TYPE_SMBUS_DEVICE "smbus-device"
+#define SMBUS_DEVICE(obj) \
+     OBJECT_CHECK(SMBUSDevice, (obj), TYPE_SMBUS_DEVICE)
+#define SMBUS_DEVICE_CLASS(klass) \
+     OBJECT_CLASS_CHECK(SMBUSDeviceClass, (klass), TYPE_SMBUS_DEVICE)
+#define SMBUS_DEVICE_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(SMBUSDeviceClass, (obj), TYPE_SMBUS_DEVICE)
+
+typedef struct SMBusDeviceClass
+{
+    I2CSlaveClass parent_class;
+} SMBusDeviceClass;
+
 struct SMBusDevice {
     /* The SMBus protocol is implemented on top of I2C.  */
     I2CSlave i2c;
-- 
1.7.4.1




reply via email to

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