Patchwork [v1,2/6] i2c: Add no_init version of i2c_create_slave

login
register
mail settings
Submitter Peter Crosthwaite
Date Feb. 20, 2013, 5:29 a.m.
Message ID <39c6213ff89afdff8709597c67011fabee910fda.1361337686.git.peter.crosthwaite@xilinx.com>
Download mbox | patch
Permalink /patch/221949/
State New
Headers show

Comments

Peter Crosthwaite - Feb. 20, 2013, 5:29 a.m.
Add a version of i2c_create_slave that does not qdev init the created device.
This give the machine model a chance to set properites of the created device
before qdev_init time. Based on equivalent function in ssi.c.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 hw/i2c.c |   11 ++++++++++-
 hw/i2c.h |    2 ++
 2 files changed, 12 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/i2c.c b/hw/i2c.c
index a9004e6..db2a5d9 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -216,12 +216,21 @@  static int i2c_slave_qdev_init(DeviceState *dev)
     return sc->init(s);
 }
 
-DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr)
+
+DeviceState *i2c_create_slave_no_init(i2c_bus *bus, const char *name,
+                                      uint8_t addr)
 {
     DeviceState *dev;
 
     dev = qdev_create(&bus->qbus, name);
     qdev_prop_set_uint8(dev, "address", addr);
+    return dev;
+}
+
+DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr)
+{
+    DeviceState *dev = i2c_create_slave_no_init(bus, name, addr);
+
     qdev_init_nofail(dev);
     return dev;
 }
diff --git a/hw/i2c.h b/hw/i2c.h
index 0021125..9f761bc 100644
--- a/hw/i2c.h
+++ b/hw/i2c.h
@@ -68,6 +68,8 @@  int i2c_recv(i2c_bus *bus);
 #define FROM_I2C_SLAVE(type, dev) DO_UPCAST(type, i2c, dev)
 
 DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr);
+DeviceState *i2c_create_slave_no_init(i2c_bus *bus, const char *name,
+                                      uint8_t addr);
 
 /* wm8750.c */
 void wm8750_data_req_set(DeviceState *dev,