aboutsummaryrefslogtreecommitdiff
path: root/hw/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/i2c')
-rw-r--r--hw/i2c/core.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index acf34a12d6..144786f17a 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -267,13 +267,13 @@ const VMStateDescription vmstate_i2c_slave = {
}
};
-DeviceState *i2c_try_create_slave(const char *name, uint8_t addr)
+I2CSlave *i2c_slave_new(const char *name, uint8_t addr)
{
DeviceState *dev;
dev = qdev_new(name);
qdev_prop_set_uint8(dev, "address", addr);
- return dev;
+ return I2C_SLAVE(dev);
}
bool i2c_realize_and_unref(DeviceState *dev, I2CBus *bus, Error **errp)
@@ -283,12 +283,11 @@ bool i2c_realize_and_unref(DeviceState *dev, I2CBus *bus, Error **errp)
DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr)
{
- DeviceState *dev;
+ I2CSlave *dev = i2c_slave_new(name, addr);
- dev = i2c_try_create_slave(name, addr);
- i2c_realize_and_unref(dev, bus, &error_fatal);
+ i2c_realize_and_unref(DEVICE(dev), bus, &error_fatal);
- return dev;
+ return DEVICE(dev);
}
static void i2c_slave_class_init(ObjectClass *klass, void *data)