From patchwork Fri Jun 17 13:10:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efimov Vasily X-Patchwork-Id: 9183947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B8A1601C0 for ; Fri, 17 Jun 2016 13:25:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4977A2835E for ; Fri, 17 Jun 2016 13:25:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D34428396; Fri, 17 Jun 2016 13:25:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D2D2B2835E for ; Fri, 17 Jun 2016 13:25:09 +0000 (UTC) Received: from localhost ([::1]:57469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDtlk-0001Zh-Ui for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 Jun 2016 09:25:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDtZ1-0004It-KH for qemu-devel@nongnu.org; Fri, 17 Jun 2016 09:12:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDtYt-0000q9-4H for qemu-devel@nongnu.org; Fri, 17 Jun 2016 09:11:58 -0400 Received: from smtp.ispras.ru ([83.149.199.79]:53666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDtYX-0000fX-N7; Fri, 17 Jun 2016 09:11:29 -0400 Received: from real.intra.ispras.ru (unknown [83.149.199.91]) by smtp.ispras.ru (Postfix) with ESMTP id C829F2041A; Fri, 17 Jun 2016 16:11:12 +0300 (MSK) From: Efimov Vasily To: qemu-devel@nongnu.org Date: Fri, 17 Jun 2016 16:10:58 +0300 Message-Id: <1466169069-29375-3-git-send-email-real@ispras.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466169069-29375-1-git-send-email-real@ispras.ru> References: <1466169069-29375-1-git-send-email-real@ispras.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.79 Subject: [Qemu-devel] [PATCH 02/13] pcspk: convert "pit" property type from ptr to link X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Efimov Vasily , Max Reitz , Gerd Hoffmann , Paolo Bonzini , Kirill Batuzov , John Snow , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The speaker device needs pointer to ISA PIT device to operate. But according to qdev-properties.h, properties of pointer type should be avoided. It seems a link type property is a good substitution. Signed-off-by: Efimov Vasily Reviewed-by: Paolo Bonzini --- hw/audio/pcspk.c | 7 +++++-- include/hw/audio/pcspk.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index d259960..aa198d6 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -31,6 +31,7 @@ #include "qemu/timer.h" #include "hw/timer/i8254.h" #include "hw/audio/pcspk.h" +#include "qapi/error.h" #define PCSPK_BUF_LEN 1792 #define PCSPK_SAMPLE_RATE 32000 @@ -169,6 +170,9 @@ static void pcspk_initfn(Object *obj) PCSpkState *s = PC_SPEAKER(obj); memory_region_init_io(&s->ioport, OBJECT(s), &pcspk_io_ops, s, "pcspk", 1); + + object_property_add_link(obj, "pit", TYPE_I8254, + (Object **)&s->pit, object_property_allow_set_link, 0, &error_abort); } static void pcspk_realizefn(DeviceState *dev, Error **errp) @@ -183,7 +187,6 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp) static Property pcspk_properties[] = { DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, -1), - DEFINE_PROP_PTR("pit", PCSpkState, pit), DEFINE_PROP_END_OF_LIST(), }; @@ -194,7 +197,7 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data) dc->realize = pcspk_realizefn; set_bit(DEVICE_CATEGORY_SOUND, dc->categories); dc->props = pcspk_properties; - /* Reason: pointer property "pit", realize sets global pcspk_state */ + /* Reason: realize sets global pcspk_state */ dc->cannot_instantiate_with_device_add_yet = true; } diff --git a/include/hw/audio/pcspk.h b/include/hw/audio/pcspk.h index ef95dd1..33e46a5 100644 --- a/include/hw/audio/pcspk.h +++ b/include/hw/audio/pcspk.h @@ -38,7 +38,7 @@ static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit) isadev = isa_create(bus, TYPE_PC_SPEAKER); dev = DEVICE(isadev); qdev_prop_set_uint32(dev, "iobase", 0x61); - qdev_prop_set_ptr(dev, "pit", pit); + object_property_set_link(OBJECT(dev), OBJECT(pit), "pit", NULL); qdev_init_nofail(dev); return isadev;