From patchwork Sat Feb 4 08:02:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 139556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2A514104792 for ; Sat, 4 Feb 2012 20:09:15 +1100 (EST) Received: from localhost ([::1]:37601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtbcP-00069s-LM for incoming@patchwork.ozlabs.org; Sat, 04 Feb 2012 04:09:13 -0500 Received: from eggs.gnu.org ([140.186.70.92]:35012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rtaax-0002EV-2R for qemu-devel@nongnu.org; Sat, 04 Feb 2012 03:03:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rtaao-0005LE-2K for qemu-devel@nongnu.org; Sat, 04 Feb 2012 03:03:38 -0500 Received: from mail-wi0-f173.google.com ([209.85.212.173]:47720) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rtaam-0005Ep-VL for qemu-devel@nongnu.org; Sat, 04 Feb 2012 03:03:29 -0500 Received: by mail-wi0-f173.google.com with SMTP id hi20so3684814wib.4 for ; Sat, 04 Feb 2012 00:03:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=ewaSLLio6vh0Pyw3CCYnYJpQbaZisaypEAiR5cpy4nw=; b=Dmin0AfLWc1L1BKPht75Ad5MwD6tITsQRjYfF6nagYVB00rzcsV+G03lWns8rBup9d m+vSf8HxU2oAp+95pzgoBAyLuiN6KUalP+uAGNay4kvcYiA6A2n9kfEwcHXo7gHBvF3p 9qDaFOjb97cwo6IqMPtF7hQZx2tODnuL87Q4M= Received: by 10.180.87.8 with SMTP id t8mr1866983wiz.15.1328342608321; Sat, 04 Feb 2012 00:03:28 -0800 (PST) Received: from yakj.usersys.redhat.com.ACCOR.COM (218.104-246-81.adsl-static.isp.belgacom.be. [81.246.104.218]) by mx.google.com with ESMTPS id m8sm24963019wia.11.2012.02.04.00.03.27 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 04 Feb 2012 00:03:27 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 4 Feb 2012 09:02:57 +0100 Message-Id: <1328342577-25732-28-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1328342577-25732-1-git-send-email-pbonzini@redhat.com> References: <1328342577-25732-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.173 Cc: Peter Maydell Subject: [Qemu-devel] [PATCH v2 27/27] omap: remove PROP_PTR properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Everything is already in place to turn the clock properties into links. Cc: Peter Maydell Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori --- 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)