Skip to contentSkip to conversation

aux-to-i2c-bridge: don't allow user to create one

PATCH Applied KONRAD Frederic 3 participants 3 messages Aug 25, 2017 – Sep 14, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aux-to-i2c-bridge: don't allow user to create one

This device is private and is created once per aux-bus. So don't allow the user to create one from command-line.

---
 hw/misc/auxbus.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
hw/misc/auxbus.c +11 -0
index 8a90ddd..1182745 100644
@@ -210,6 +210,16 @@ struct AUXTOI2CState {
     I2CBus *i2c_bus;
 };
 
+static void aux_bridge_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(oc);
+
+    /* This device is private and is created only once for each
+     * aux-bus in aux_init_bus(..). So don't allow the user to add one.
+     */
+    dc->user_creatable = false;
+}
+
 static void aux_bridge_init(Object *obj)
 {
     AUXTOI2CState *s = AUXTOI2C(obj);
@@ -225,6 +235,7 @@ static inline I2CBus *aux_bridge_get_i2c_bus(AUXTOI2CState *bridge)
 static const TypeInfo aux_to_i2c_type_info = {
     .name = TYPE_AUXTOI2C,
     .parent = TYPE_DEVICE,
+    .class_init = aux_bridge_class_init,
     .instance_size = sizeof(AUXTOI2CState),
     .instance_init = aux_bridge_init
 };
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 32 lines · KONRAD Frederic

This device is private and is created once per aux-bus. So don't allow the user to create one from command-line.

---
 hw/misc/auxbus.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
hw/misc/auxbus.c +10 -0
index 8a90ddd..1182745 100644
@@ -210,6 +210,16 @@ struct AUXTOI2CState {
     I2CBus *i2c_bus;
 };
 
+static void aux_bridge_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(oc);
+
+    /* This device is private and is created only once for each
+     * aux-bus in aux_init_bus(..). So don't allow the user to add one.
+     */
+    dc->user_creatable = false;
+}
+
 static void aux_bridge_init(Object *obj)
 {
     AUXTOI2CState *s = AUXTOI2C(obj);

hw/misc/auxbus.c static inline I2CBus *aux_bridge_get_i2c_bus(AUXTOI2CState *bridge) · line 241

Quoted 7 lines
hw/misc/auxbus.c +1 -0
@@ -225,6 +235,7 @@ static inline I2CBus *aux_bridge_get_i2c_bus(AUXTOI2CState *bridge)
 static const TypeInfo aux_to_i2c_type_info = {
     .name = TYPE_AUXTOI2C,
     .parent = TYPE_DEVICE,
+    .class_init = aux_bridge_class_init,
     .instance_size = sizeof(AUXTOI2CState),
     .instance_init = aux_bridge_init
 };
#2 lore raw
In reply to KONRAD Frederic
Quoted 2 lines · KONRAD Frederic

This device is private and is created once per aux-bus. So don't allow the user to create one from command-line.

Applied to -trivial, thanks!

/mjt