Patchwork [v3,057/197] add SMBusDevice to the type hiearchy

login
register
mail settings
Submitter Anthony Liguori
Date Dec. 12, 2011, 8:18 p.m.
Message ID <1323721273-32404-58-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/130864/
State New
Headers show

Comments

Anthony Liguori - Dec. 12, 2011, 8:18 p.m.
---
 hw/smbus.c |   15 +++++++++++++++
 hw/smbus.h |   13 +++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

Patch

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;