All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 13/30] hw/gpio: QOM'ify omap_gpio.c
Date: Tue, 14 Jun 2016 15:13:48 +0100	[thread overview]
Message-ID: <1465913645-19346-14-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1465913645-19346-1-git-send-email-peter.maydell@linaro.org>

From: xiaoqiang zhao <zxq_yx_007@163.com>

* Split the old SysBus init into an instance_init and
  DeviceClass::realize function
* Drop the SysBus init function

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
Message-id: 1465815255-21776-6-git-send-email-zxq_yx_007@163.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/gpio/omap_gpio.c | 61 +++++++++++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
index 9b1b004..dabef4a 100644
--- a/hw/gpio/omap_gpio.c
+++ b/hw/gpio/omap_gpio.c
@@ -23,6 +23,7 @@
 #include "hw/arm/omap.h"
 #include "hw/sysbus.h"
 #include "qemu/error-report.h"
+#include "qapi/error.h"
 
 struct omap_gpio_s {
     qemu_irq irq;
@@ -678,48 +679,46 @@ static const MemoryRegionOps omap2_gpif_top_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-static int omap_gpio_init(SysBusDevice *sbd)
+static void omap_gpio_init(Object *obj)
 {
-    DeviceState *dev = DEVICE(sbd);
-    struct omap_gpif_s *s = OMAP1_GPIO(dev);
+    DeviceState *dev = DEVICE(obj);
+    struct omap_gpif_s *s = OMAP1_GPIO(obj);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
 
-    if (!s->clk) {
-        error_report("omap-gpio: clk not connected");
-        return -1;
-    }
     qdev_init_gpio_in(dev, omap_gpio_set, 16);
     qdev_init_gpio_out(dev, s->omap1.handler, 16);
     sysbus_init_irq(sbd, &s->omap1.irq);
-    memory_region_init_io(&s->iomem, OBJECT(s), &omap_gpio_ops, &s->omap1,
+    memory_region_init_io(&s->iomem, obj, &omap_gpio_ops, &s->omap1,
                           "omap.gpio", 0x1000);
     sysbus_init_mmio(sbd, &s->iomem);
-    return 0;
 }
 
-static int omap2_gpio_init(SysBusDevice *sbd)
+static void omap_gpio_realize(DeviceState *dev, Error **errp)
+{
+    struct omap_gpif_s *s = OMAP1_GPIO(dev);
+
+    if (!s->clk) {
+        error_setg(errp, "omap-gpio: clk not connected");
+    }
+}
+
+static void omap2_gpio_realize(DeviceState *dev, Error **errp)
 {
-    DeviceState *dev = DEVICE(sbd);
     struct omap2_gpif_s *s = OMAP2_GPIO(dev);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     int i;
 
     if (!s->iclk) {
-        error_report("omap2-gpio: iclk not connected");
-        return -1;
+        error_setg(errp, "omap2-gpio: iclk not connected");
+        return;
     }
 
     s->modulecount = s->mpu_model < omap2430 ? 4
-                   : s->mpu_model < omap3430 ? 5
-                   : 6;
-
-    for (i = 0; i < s->modulecount; i++) {
-        if (!s->fclk[i]) {
-            error_report("omap2-gpio: fclk%d not connected", i);
-            return -1;
-        }
-    }
+        : s->mpu_model < omap3430 ? 5
+        : 6;
 
     if (s->mpu_model < omap3430) {
-        memory_region_init_io(&s->iomem, OBJECT(s), &omap2_gpif_top_ops, s,
+        memory_region_init_io(&s->iomem, OBJECT(dev), &omap2_gpif_top_ops, s,
                               "omap2.gpio", 0x1000);
         sysbus_init_mmio(sbd, &s->iomem);
     }
@@ -732,17 +731,20 @@ static int omap2_gpio_init(SysBusDevice *sbd)
     for (i = 0; i < s->modulecount; i++) {
         struct omap2_gpio_s *m = &s->modules[i];
 
+        if (!s->fclk[i]) {
+            error_setg(errp, "omap2-gpio: fclk%d not connected", i);
+            return;
+        }
+
         m->revision = (s->mpu_model < omap3430) ? 0x18 : 0x25;
         m->handler = &s->handler[i * 32];
         sysbus_init_irq(sbd, &m->irq[0]); /* mpu irq */
         sysbus_init_irq(sbd, &m->irq[1]); /* dsp irq */
         sysbus_init_irq(sbd, &m->wkup);
-        memory_region_init_io(&m->iomem, OBJECT(s), &omap2_gpio_module_ops, m,
+        memory_region_init_io(&m->iomem, OBJECT(dev), &omap2_gpio_module_ops, m,
                               "omap.gpio-module", 0x1000);
         sysbus_init_mmio(sbd, &m->iomem);
     }
-
-    return 0;
 }
 
 /* Using qdev pointer properties for the clocks is not ideal.
@@ -766,9 +768,8 @@ static Property omap_gpio_properties[] = {
 static void omap_gpio_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = omap_gpio_init;
+    dc->realize = omap_gpio_realize;
     dc->reset = omap_gpif_reset;
     dc->props = omap_gpio_properties;
     /* Reason: pointer property "clk" */
@@ -779,6 +780,7 @@ static const TypeInfo omap_gpio_info = {
     .name          = TYPE_OMAP1_GPIO,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(struct omap_gpif_s),
+    .instance_init = omap_gpio_init,
     .class_init    = omap_gpio_class_init,
 };
 
@@ -797,9 +799,8 @@ static Property omap2_gpio_properties[] = {
 static void omap2_gpio_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = omap2_gpio_init;
+    dc->realize = omap2_gpio_realize;
     dc->reset = omap2_gpif_reset;
     dc->props = omap2_gpio_properties;
     /* Reason: pointer properties "iclk", "fclk0", ..., "fclk5" */
-- 
1.9.1

  parent reply	other threads:[~2016-06-14 14:14 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 14:13 [Qemu-devel] [PULL 00/30] target-arm queue Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 01/30] target-arm: kvm64: set guest PMUv3 feature bit if supported Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 02/30] hw/arm/virt: Add PMU node for virt machine Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 03/30] hw/arm/virt-acpi-build: Add PMU IRQ number in ACPI table Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 04/30] target-arm: Fix reset and migration of TTBCR(S) Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 05/30] hw/arm/virt: separate versioned type-init code Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 06/30] hw/arm/virt: introduce DEFINE_VIRT_MACHINE Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 07/30] hw/arm/virt: introduce DEFINE_VIRT_MACHINE_AS_LATEST Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 08/30] hw/arm/virt: create the 2.7 machine type Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 09/30] hw/i2c: QOM'ify bitbang_i2c.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 10/30] hw/i2c: QOM'ify exynos4210_i2c.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 11/30] hw/i2c: QOM'ify omap_i2c.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 12/30] hw/i2c: QOM'ify versatile_i2c.c Peter Maydell
2016-06-14 14:13 ` Peter Maydell [this message]
2016-06-14 14:13 ` [Qemu-devel] [PULL 14/30] hw/gpio: QOM'ify pl061.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 15/30] hw/gpio: QOM'ify zaurus.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 16/30] hw/misc: QOM'ify arm_l2x0.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 17/30] hw/misc: QOM'ify exynos4210_pmu.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 18/30] hw/misc: QOM'ify mst_fpga.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 19/30] hw/dma: QOM'ify pxa2xx_dma.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 20/30] hw/sd: QOM'ify pl181.c Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 21/30] i2cbus: remove unused dev field Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 22/30] i2c: implement broadcast write Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 23/30] i2c: Factor our send() and recv() common logic Peter Maydell
2016-06-14 14:13 ` [Qemu-devel] [PULL 24/30] introduce aux-bus Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 25/30] introduce dpcd module Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 26/30] hw/i2c-ddc.c: Implement DDC I2C slave Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 27/30] introduce xlnx-dpdma Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 28/30] introduce xlnx-dp Peter Maydell
2022-04-07 10:32   ` Peter Maydell
2022-04-07 11:28     ` Frederic Konrad
2022-04-07 12:26       ` Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 29/30] arm: xlnx-zynqmp: Add xlnx-dp and xlnx-dpdma Peter Maydell
2016-06-14 14:14 ` [Qemu-devel] [PULL 30/30] target-arm: Don't permit ARMv8-only Neon insns on ARMv7 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465913645-19346-14-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.