qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 27/27] omap: remove PROP_PTR properties


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH v2 27/27] omap: remove PROP_PTR properties
Date: Mon, 06 Feb 2012 08:43:27 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15

On 02/04/2012 02:02 AM, Paolo Bonzini wrote:
Everything is already in place to turn the clock properties into links.

w00t!

Reviewed-by: Anthony Liguori <address@hidden>

Regards,

Anthony Liguori


Cc: Peter Maydell<address@hidden>
Signed-off-by: Paolo Bonzini<address@hidden>
---
  hw/omap_clk.c  |    2 +-
  hw/omap_gpio.c |   46 ++++++++++++++++++++++++----------------------
  hw/omap_intc.c |   26 +++++++++++++++++++++-----
  3 files changed, 46 insertions(+), 28 deletions(-)

diff --git a/hw/omap_clk.c b/hw/omap_clk.c
index c4c2b80..4723ac1 100644
--- a/hw/omap_clk.c
+++ b/hw/omap_clk.c
@@ -1305,7 +1305,7 @@ void omap_prop_set_clk(struct omap_mpu_state_s *s, 
DeviceState *dev,
                         const char *name, const char *clk)
  {
      struct clk *target = omap_findclk(s, clk);
-    qdev_prop_set_ptr(dev, name, target);
+    object_property_set_link(OBJECT(dev), OBJECT(target), name, NULL);
  }

  static void omap_clk_register(void)
diff --git a/hw/omap_gpio.c b/hw/omap_gpio.c
index 9a9a8e1..e9a0cdb 100644
--- a/hw/omap_gpio.c
+++ b/hw/omap_gpio.c
@@ -39,7 +39,7 @@ struct omap_gpif_s {
      SysBusDevice busdev;
      MemoryRegion iomem;
      int mpu_model;
-    void *clk;
+    struct clk *clk;
      struct omap_gpio_s omap1;
  };

@@ -207,8 +207,8 @@ struct omap2_gpif_s {
      SysBusDevice busdev;
      MemoryRegion iomem;
      int mpu_model;
-    void *iclk;
-    void *fclk[6];
+    struct clk *iclk;
+    struct clk *fclk[6];
      int modulecount;
      struct omap2_gpio_s *modules;
      qemu_irq *handler;
@@ -719,21 +719,15 @@ static int omap2_gpio_init(SysBusDevice *dev)
      return 0;
  }

-/* Using qdev pointer properties for the clocks is not ideal.
- * qdev should support a generic means of defining a 'port' with
- * an arbitrary interface for connecting two devices. Then we
- * could reframe the omap clock API in terms of clock ports,
- * and get some type safety. For now the best qdev provides is
- * passing an arbitrary pointer.
- * (It's not possible to pass in the string which is the clock
- * name, because this device does not have the necessary information
- * (ie the struct omap_mpu_state_s*) to do the clockname to pointer
- * translation.)
- */
+static void omap_gpio_initfn(Object *obj)
+{
+    struct omap_gpif_s *s = FROM_SYSBUS(struct omap_gpif_s, 
SYS_BUS_DEVICE(obj));
+
+    object_property_add_link(obj, "clk", TYPE_OMAP_CLK, (Object **)&s->clk, 
NULL);
+}

  static Property omap_gpio_properties[] = {
      DEFINE_PROP_INT32("mpu_model", struct omap_gpif_s, mpu_model, 0),
-    DEFINE_PROP_PTR("clk", struct omap_gpif_s, clk),
      DEFINE_PROP_END_OF_LIST(),
  };

@@ -752,17 +746,24 @@ static TypeInfo omap_gpio_info = {
      .parent        = TYPE_SYS_BUS_DEVICE,
      .instance_size = sizeof(struct omap_gpif_s),
      .class_init    = omap_gpio_class_init,
+    .instance_init = omap_gpio_initfn,
  };

+static void omap2_gpio_initfn(Object *obj)
+{
+    struct omap2_gpif_s *s = FROM_SYSBUS(struct omap2_gpif_s, 
SYS_BUS_DEVICE(obj));
+
+    object_property_add_link(obj, "iclk", TYPE_OMAP_CLK, (Object **)&s->iclk, 
NULL);
+    object_property_add_link(obj, "fclk0", TYPE_OMAP_CLK, (Object 
**)&s->fclk[0], NULL);
+    object_property_add_link(obj, "fclk1", TYPE_OMAP_CLK, (Object 
**)&s->fclk[1], NULL);
+    object_property_add_link(obj, "fclk2", TYPE_OMAP_CLK, (Object 
**)&s->fclk[2], NULL);
+    object_property_add_link(obj, "fclk3", TYPE_OMAP_CLK, (Object 
**)&s->fclk[3], NULL);
+    object_property_add_link(obj, "fclk4", TYPE_OMAP_CLK, (Object 
**)&s->fclk[4], NULL);
+    object_property_add_link(obj, "fclk5", TYPE_OMAP_CLK, (Object 
**)&s->fclk[5], NULL);
+}
+
  static Property omap2_gpio_properties[] = {
      DEFINE_PROP_INT32("mpu_model", struct omap2_gpif_s, mpu_model, 0),
-    DEFINE_PROP_PTR("iclk", struct omap2_gpif_s, iclk),
-    DEFINE_PROP_PTR("fclk0", struct omap2_gpif_s, fclk[0]),
-    DEFINE_PROP_PTR("fclk1", struct omap2_gpif_s, fclk[1]),
-    DEFINE_PROP_PTR("fclk2", struct omap2_gpif_s, fclk[2]),
-    DEFINE_PROP_PTR("fclk3", struct omap2_gpif_s, fclk[3]),
-    DEFINE_PROP_PTR("fclk4", struct omap2_gpif_s, fclk[4]),
-    DEFINE_PROP_PTR("fclk5", struct omap2_gpif_s, fclk[5]),
      DEFINE_PROP_END_OF_LIST(),
  };

@@ -781,6 +782,7 @@ static TypeInfo omap2_gpio_info = {
      .parent        = TYPE_SYS_BUS_DEVICE,
      .instance_size = sizeof(struct omap2_gpif_s),
      .class_init    = omap2_gpio_class_init,
+    .instance_init = omap2_gpio_initfn,
  };

  static void omap_gpio_register_device(void)
diff --git a/hw/omap_intc.c b/hw/omap_intc.c
index 5aa98a8..cc263ef 100644
--- a/hw/omap_intc.c
+++ b/hw/omap_intc.c
@@ -37,8 +37,8 @@ struct omap_intr_handler_s {
      qemu_irq *pins;
      qemu_irq parent_intr[2];
      MemoryRegion mmio;
-    void *iclk;
-    void *fclk;
+    struct clk *iclk;
+    struct clk *fclk;
      unsigned char nbanks;
      int level_only;
      uint32_t size;
@@ -373,9 +373,16 @@ static int omap_intc_init(SysBusDevice *dev)
      return 0;
  }

+static void omap_intc_initfn(Object *obj)
+{
+    struct omap_intr_handler_s *s = FROM_SYSBUS(struct omap_intr_handler_s,
+                                                SYS_BUS_DEVICE(obj));
+
+    object_property_add_link(obj, "clk", TYPE_OMAP_CLK, (Object **)&s->iclk, 
NULL);
+}
+
  static Property omap_intc_properties[] = {
      DEFINE_PROP_UINT32("size", struct omap_intr_handler_s, size, 0x100),
-    DEFINE_PROP_PTR("clk", struct omap_intr_handler_s, iclk),
      DEFINE_PROP_END_OF_LIST(),
  };

@@ -394,6 +401,7 @@ static TypeInfo omap_intc_info = {
      .parent        = TYPE_SYS_BUS_DEVICE,
      .instance_size = sizeof(struct omap_intr_handler_s),
      .class_init    = omap_intc_class_init,
+    .instance_init = omap_intc_initfn,
  };

  static uint64_t omap2_inth_read(void *opaque, target_phys_addr_t addr,
@@ -615,11 +623,18 @@ static int omap2_intc_init(SysBusDevice *dev)
      return 0;
  }

+static void omap2_intc_initfn(Object *obj)
+{
+    struct omap_intr_handler_s *s = FROM_SYSBUS(struct omap_intr_handler_s,
+                                                SYS_BUS_DEVICE(obj));
+
+    object_property_add_link(obj, "iclk", TYPE_OMAP_CLK, (Object **)&s->iclk, 
NULL);
+    object_property_add_link(obj, "fclk", TYPE_OMAP_CLK, (Object **)&s->fclk, 
NULL);
+}
+
  static Property omap2_intc_properties[] = {
      DEFINE_PROP_UINT8("revision", struct omap_intr_handler_s,
      revision, 0x21),
-    DEFINE_PROP_PTR("iclk", struct omap_intr_handler_s, iclk),
-    DEFINE_PROP_PTR("fclk", struct omap_intr_handler_s, fclk),
      DEFINE_PROP_END_OF_LIST(),
  };

@@ -638,6 +653,7 @@ static TypeInfo omap2_intc_info = {
      .parent        = TYPE_SYS_BUS_DEVICE,
      .instance_size = sizeof(struct omap_intr_handler_s),
      .class_init    = omap2_intc_class_init,
+    .instance_init = omap2_intc_initfn,
  };

  static void omap_intc_register_device(void)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]