@@ -79,8 +79,56 @@ int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send);
79
79
int i2c_send (I2CBus * bus , uint8_t data );
80
80
uint8_t i2c_recv (I2CBus * bus );
81
81
82
+ /**
83
+ * Create an I2C slave device on the heap.
84
+ * @name: a device type name
85
+ * @addr: I2C address of the slave when put on a bus
86
+ *
87
+ * This only initializes the device state structure and allows
88
+ * properties to be set. Type @name must exist. The device still
89
+ * needs to be realized. See qdev-core.h.
90
+ */
82
91
I2CSlave * i2c_slave_new (const char * name , uint8_t addr );
92
+
93
+ /**
94
+ * Create and realize an I2C slave device on the heap.
95
+ * @bus: I2C bus to put it on
96
+ * @name: I2C slave device type name
97
+ * @addr: I2C address of the slave when put on a bus
98
+ *
99
+ * Create the device state structure, initialize it, put it on the
100
+ * specified @bus, and drop the reference to it (the device is realized).
101
+ */
83
102
I2CSlave * i2c_slave_create_simple (I2CBus * bus , const char * name , uint8_t addr );
103
+
104
+ /**
105
+ * Realize and and drop a reference an I2C slave device
106
+ * @dev: I2C slave device to realize
107
+ * @bus: I2C bus to put it on
108
+ * @addr: I2C address of the slave on the bus
109
+ * @errp: pointer to NULL initialized error object
110
+ *
111
+ * Returns: %true on success, %false on failure.
112
+ *
113
+ * Call 'realize' on @dev, put it on the specified @bus, and drop the
114
+ * reference to it.
115
+ *
116
+ * This function is useful if you have created @dev via qdev_new(),
117
+ * i2c_slave_new() or i2c_slave_try_new() (which take a reference to
118
+ * the device it returns to you), so that you can set properties on it
119
+ * before realizing it. If you don't need to set properties then
120
+ * i2c_slave_create_simple() is probably better (as it does the create,
121
+ * init and realize in one step).
122
+ *
123
+ * If you are embedding the I2C slave into another QOM device and
124
+ * initialized it via some variant on object_initialize_child() then
125
+ * do not use this function, because that family of functions arrange
126
+ * for the only reference to the child device to be held by the parent
127
+ * via the child<> property, and so the reference-count-drop done here
128
+ * would be incorrect. (Instead you would want i2c_slave_realize(),
129
+ * which doesn't currently exist but would be trivial to create if we
130
+ * had any code that wanted it.)
131
+ */
84
132
bool i2c_slave_realize_and_unref (I2CSlave * dev , I2CBus * bus , Error * * errp );
85
133
86
134
/* lm832x.c */
0 commit comments