From patchwork Mon Dec 12 20:18:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 130832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0042A1007DE for ; Tue, 13 Dec 2011 07:27:13 +1100 (EST) Received: from localhost ([::1]:36205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCSo-0003qk-DW for incoming@patchwork.ozlabs.org; Mon, 12 Dec 2011 15:27:06 -0500 Received: from eggs.gnu.org ([140.186.70.92]:42523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCST-0003IW-KH for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:26:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaCSS-0001ZJ-G7 for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:26:45 -0500 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:56024 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCSS-0001Z6-4m for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:26:44 -0500 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu1) with ESMTP id pBCKQ8YR000372; Mon, 12 Dec 2011 14:26:10 -0600 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id pBCKQ5AY000368; Mon, 12 Dec 2011 14:26:05 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 12 Dec 2011 14:18:52 -0600 Message-Id: <1323721273-32404-57-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1323721273-32404-1-git-send-email-aliguori@us.ibm.com> References: <1323721273-32404-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 70.123.132.139 Cc: Kevin Wolf , Peter Maydell , Anthony Liguori , Stefan Hajnoczi , Jan Kiszka , Markus Armbruster , Luiz Capitulino Subject: [Qemu-devel] [PATCH v3 056/197] add I2CSlave to the type hierarchy X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org --- 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;