From patchwork Thu Nov 29 04:52:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10703907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C598B1057 for ; Thu, 29 Nov 2018 04:57:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACA1A28CCF for ; Thu, 29 Nov 2018 04:57:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BF802E6B7; Thu, 29 Nov 2018 04:57:33 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,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 3DE3928CCF for ; Thu, 29 Nov 2018 04:57:33 +0000 (UTC) Received: from localhost ([::1]:52289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSEOK-00089Z-5W for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Nov 2018 23:57:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSEK9-0005HI-PJ for qemu-devel@nongnu.org; Wed, 28 Nov 2018 23:53:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSEK8-0007Pq-R6 for qemu-devel@nongnu.org; Wed, 28 Nov 2018 23:53:13 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:43395) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSEK8-0007OQ-IC for qemu-devel@nongnu.org; Wed, 28 Nov 2018 23:53:12 -0500 Received: by mail-pg1-x542.google.com with SMTP id v28so347774pgk.10 for ; Wed, 28 Nov 2018 20:53:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=luZPC7/DqLcA2RZca3xoTMrfHx2Ra0jsPVrKhHeVmBs=; b=jtHPS4+Xm+qc0K2kzbSKYER/gC51fiLZ8G91DbVTPwEsar+IJfA5gOYES+zAzoiYTT aVohuda0Rn2b+avgycogCy1HLcvjzfvUVOObB2d2857Dswg9DrJvT1K2bQXcqSD7b2Ze KW6mIfdPXY3jJoXKrzSH1YHXN7jJ2vO2y/hyk1D3Xo0wTKGiK0eITd5fkHxL6EX96RBd JmiCHGxLTayHm7b7RZZ6myi2DsI+ogwrmGDp9LFDUWwp+fComfcxpfk3SkqBORj0KhuX EphFELIF54wZG7cEi1c/42BkqGVV2IiT58rsULUaQ/hD1B1KxWCFiW+p4+qrsbXKbvR1 sgvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=luZPC7/DqLcA2RZca3xoTMrfHx2Ra0jsPVrKhHeVmBs=; b=mBMce/Gm5xRVzhBSw+jFBbgPOjJQPovnioa0N8tCgdKpUoHhOiGjOQ9HfArQQQif53 OSh6yWgMaO2CGqmd2NWBZm+Varqo233MgGP/7FnBTbP9BP35BVHOQhwsE7EayXZg0UQz TOk2BxUQOdBQkd/JaeFisqFOOlXQKIgwQl/f0LMVd2cDX1TcLjX/eyl9dy8dNIBI/Rq/ IDCTvhrWPdfuOLd5891ixrIhONJX5ZdqlxsLrnF/CZnyZWAnVXqYQUwu2XcqfZeod1VW c7NCTdTxW0SUZluGkTmahJqlDlbwG6LFiUsQnIGO/jHAfVc7a/3T+FB4TZyuQ8mNYMhc nTdg== X-Gm-Message-State: AA+aEWZfB/vF3/UW6mAlDR6cjLR/FD8JS32u9ubZjBfKrtkopgcYIvUG Ax65tbppQHN4ukYDQn7l07APkmBp X-Google-Smtp-Source: AFSGD/XiRcc32mZBQgVaSNKZKbori9BotN4nE34BiY3xSJuvgylV/Wke1O6U78R466bMwq6Kw8hrIg== X-Received: by 2002:a62:7504:: with SMTP id q4mr44961pfc.180.1543467191615; Wed, 28 Nov 2018 20:53:11 -0800 (PST) Received: from localhost.localdomain.localdomain ([103.129.255.252]) by smtp.gmail.com with ESMTPSA id k26sm576747pgf.65.2018.11.28.20.53.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 20:53:11 -0800 (PST) From: Li Qiang To: mst@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com Date: Wed, 28 Nov 2018 20:52:11 -0800 Message-Id: <1543467132-2873-2-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543467132-2873-1-git-send-email-liq3ea@gmail.com> References: <1543467132-2873-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v3 1/2] hw: pc: use TYPE_XXX instead of constant strings 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: darren.kenny@oracle.com, Li Qiang , armbru@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP TYPE_VMMOUSE is defined in vmmouse.c currently, move it to pc.h in order to use it in pc.c. Reviewed-by: Darren Kenny Reviewed-by: Markus Armbruster Signed-off-by: Li Qiang Reviewed-by: Philippe Mathieu-Daudé --- hw/i386/pc.c | 6 +++--- hw/i386/vmmouse.c | 1 - include/hw/i386/pc.h | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f095725dba..73c7b777a0 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1543,10 +1543,10 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport) fdctrl_init_isa(isa_bus, fd); } - i8042 = isa_create_simple(isa_bus, "i8042"); + i8042 = isa_create_simple(isa_bus, TYPE_I8042); if (!no_vmport) { vmport_init(isa_bus); - vmmouse = isa_try_create(isa_bus, "vmmouse"); + vmmouse = isa_try_create(isa_bus, TYPE_VMMOUSE); } else { vmmouse = NULL; } @@ -1555,7 +1555,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport) qdev_prop_set_ptr(dev, "ps2_mouse", i8042); qdev_init_nofail(dev); } - port92 = isa_create_simple(isa_bus, "port92"); + port92 = isa_create_simple(isa_bus, TYPE_PORT92); a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2); i8042_setup_a20_line(i8042, a20_line[0]); diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index 5d2d278be4..4412eaf604 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -52,7 +52,6 @@ #define DPRINTF(fmt, ...) do { } while (0) #endif -#define TYPE_VMMOUSE "vmmouse" #define VMMOUSE(obj) OBJECT_CHECK(VMMouseState, (obj), TYPE_VMMOUSE) typedef struct VMMouseState diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 136fe497b6..c708ac9265 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -169,6 +169,9 @@ void gsi_handler(void *opaque, int n, int level); #define TYPE_VMPORT "vmport" typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); +/* vmmouse.c */ +#define TYPE_VMMOUSE "vmmouse" + static inline void vmport_init(ISABus *bus) { isa_create_simple(bus, TYPE_VMPORT); From patchwork Thu Nov 29 04:52:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10703909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 69F721057 for ; Thu, 29 Nov 2018 04:57:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EC3828CCF for ; Thu, 29 Nov 2018 04:57:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52EDE2E6B7; Thu, 29 Nov 2018 04:57:52 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,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 E9F5028CCF for ; Thu, 29 Nov 2018 04:57:51 +0000 (UTC) Received: from localhost ([::1]:52290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSEOd-00006M-7t for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Nov 2018 23:57:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSEKG-0005L9-KO for qemu-devel@nongnu.org; Wed, 28 Nov 2018 23:53:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSEKC-0007ZC-Bl for qemu-devel@nongnu.org; Wed, 28 Nov 2018 23:53:18 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:44232) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSEKC-0007Wf-2W for qemu-devel@nongnu.org; Wed, 28 Nov 2018 23:53:16 -0500 Received: by mail-pl1-x641.google.com with SMTP id k8so383705pls.11 for ; Wed, 28 Nov 2018 20:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gQPpANLNaqyCmSXEKVN0kAvcy+UqvaLP2xzGCSjaCT4=; b=KIvawS+YrpXlc7L2ej7qOKikKKd+23RcjZVPZl/Sv/vt62nu18hoas/d0YZdc7gIsg VV+zSfvcNH+de23I7QJZJSSUZXnxe0IjMBQVulBHfAP5M7TWssuqsU3+Ti08g9tkCFKo FgB4XU3+Iw2BX86uz90ZnaFemCVgrIzZiU/krxsR4ppzKN/a3SFfFenX1k2j3n71V/Qx SikXIg5UbvUC19CNJbERwzAjczDJT2uvxTPE1YA+MSMRNkM0TMfim+TfdZqG2cVkXD/I TsUZKfcXOTA+4aPbZYWJXcc3W+17FuG6dL41b5tbJADhOsi7BiJFuv5kWr42n3KSI8Mh rclg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gQPpANLNaqyCmSXEKVN0kAvcy+UqvaLP2xzGCSjaCT4=; b=dc9ocXIdJBJtEp6+w8RA6aMelVDDQ7wwC1cY9DihSyUyMGuFR5unPlVap7UORYVRQu 2N1YDfaxgymVnoSP5AUFSH66SFGWnTAcfwkUdoCLZkqlP9+tDdsDZdyo65tv9tcwJIDP 4IrRwJzkuBp6gogKpMOftfpwABb4ZP3Ef0daI51HNU6mjESZZljZ6/ciDL20Sf17pbCR 57Dv0agH4nOeJPof9E1+yy+YUBm9/YxCxENhUIEVKMCuj64/BM2KpBibBpbJnAY05VJ5 AhBY++9Ki8OnlQlY3DU7JIhpTXLmJGUZfGL+0o1sHDqdQEy7QmWRHUTtg2yxvyBHOv+j 5mGQ== X-Gm-Message-State: AA+aEWbnwMZkcUh/tCsU4xQ6+dlXoyTDlYlro2BrSOCYgcEEw3SNKnh9 h0P+alHBUQlP5mGXQT2XBx8= X-Google-Smtp-Source: AFSGD/VrTebMly9oPNzFwPRbOQ046R6sGD3V3bUen4mmV2pv/JGv+dzjX/JRI/23U5gGSw4Md7vljQ== X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr63195plo.50.1543467195063; Wed, 28 Nov 2018 20:53:15 -0800 (PST) Received: from localhost.localdomain.localdomain ([103.129.255.252]) by smtp.gmail.com with ESMTPSA id k26sm576747pgf.65.2018.11.28.20.53.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 20:53:14 -0800 (PST) From: Li Qiang To: mst@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com Date: Wed, 28 Nov 2018 20:52:12 -0800 Message-Id: <1543467132-2873-3-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543467132-2873-1-git-send-email-liq3ea@gmail.com> References: <1543467132-2873-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v3 2/2] hw: vmmouse: Use link instead of pointer property 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: darren.kenny@oracle.com, Li Qiang , armbru@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP According to qdev-properties.h, properties of pointer type should be avoided. Turn "ps2_mouse" into a link. Reviewed-by: Markus Armbruster Reviewed-by: Darren Kenny Signed-off-by: Li Qiang Reviewed-by: Philippe Mathieu-Daudé --- Change since v2: detailed commit message Change since v1: use error_abort in object_property_set_link() hw/i386/pc.c | 3 ++- hw/i386/vmmouse.c | 17 +++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 73c7b777a0..64f0f233b8 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1552,7 +1552,8 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport) } if (vmmouse) { DeviceState *dev = DEVICE(vmmouse); - qdev_prop_set_ptr(dev, "ps2_mouse", i8042); + object_property_set_link(OBJECT(dev), OBJECT(i8042), + "ps2_mouse", &error_abort); qdev_init_nofail(dev); } port92 = isa_create_simple(isa_bus, TYPE_PORT92); diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index 4412eaf604..f63aac6673 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -27,6 +27,7 @@ #include "hw/i386/pc.h" #include "hw/input/i8042.h" #include "hw/qdev.h" +#include "qapi/error.h" /* debug only vmmouse */ //#define DEBUG_VMMOUSE @@ -271,10 +272,15 @@ static void vmmouse_realizefn(DeviceState *dev, Error **errp) vmport_register(VMMOUSE_DATA, vmmouse_ioport_read, s); } -static Property vmmouse_properties[] = { - DEFINE_PROP_PTR("ps2_mouse", VMMouseState, ps2_mouse), - DEFINE_PROP_END_OF_LIST(), -}; +static void vmmouse_instance_initfn(Object *obj) +{ + VMMouseState *s = VMMOUSE(obj); + + object_property_add_link(obj, "ps2_mouse", TYPE_I8042, + (Object **)&s->ps2_mouse, + qdev_prop_allow_set_link_before_realize, + 0, &error_abort); +} static void vmmouse_class_initfn(ObjectClass *klass, void *data) { @@ -283,8 +289,6 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data) dc->realize = vmmouse_realizefn; dc->reset = vmmouse_reset; dc->vmsd = &vmstate_vmmouse; - dc->props = vmmouse_properties; - /* Reason: pointer property "ps2_mouse" */ dc->user_creatable = false; } @@ -292,6 +296,7 @@ static const TypeInfo vmmouse_info = { .name = TYPE_VMMOUSE, .parent = TYPE_ISA_DEVICE, .instance_size = sizeof(VMMouseState), + .instance_init = vmmouse_instance_initfn, .class_init = vmmouse_class_initfn, };