From patchwork Tue Nov 27 10:02:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10700019 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 08DF013BF for ; Tue, 27 Nov 2018 10:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC88529356 for ; Tue, 27 Nov 2018 10:06:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDFFE2AC15; Tue, 27 Nov 2018 10:06:22 +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 7C1B829356 for ; Tue, 27 Nov 2018 10:06:22 +0000 (UTC) Received: from localhost ([::1]:41120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRaG5-0004ut-Ad for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 05:06:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRaCC-0007mM-ML for qemu-devel@nongnu.org; Tue, 27 Nov 2018 05:02:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRaCB-0007Zr-Nc for qemu-devel@nongnu.org; Tue, 27 Nov 2018 05:02:20 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:43490) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRaCB-0007YW-Ie for qemu-devel@nongnu.org; Tue, 27 Nov 2018 05:02:19 -0500 Received: by mail-pf1-x442.google.com with SMTP id w73so8099812pfk.10 for ; Tue, 27 Nov 2018 02:02:17 -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=NoVVbdi5+QfxOTYeRWUfCsTdbq799DtthvNk6tThID8=; b=F9PIOwIEZJwNNGiRF5sIRAXF7OEp0GEaozyE5R1o94V02RsfX0yQAoiD57wKYbMWVu OfMOeIVUYlorTaFXvp8EsiNA05c2jaCMRVR2XHMtsBAGiJzHPDMC+hroRk1eJcSB4j1L dOQO1bsII7+DtFKWz86yZUi6V6ksxBSSfsCYypQRgGyNyyOApnV3vU5HvwbA84zTtCUM XwTVZ5s7ygS50VyH05mFNhqoCx1+tKvyfCjYvpouCGVkEL3JA7hLiMcubdQMirCmkKbY n1BPJSl2NnhgtI2dUvYsEMNXcl/njX3SSXJRosk8zhNqlHcm6MJrWeqR/MR5Q4EtnDuy bHnQ== 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=NoVVbdi5+QfxOTYeRWUfCsTdbq799DtthvNk6tThID8=; b=ubmaZYHicdoZ+QPX935M8sM8mcGL+iWZfVuZW1LZomwHavH3dimDkkeIZaa8niPwKA mG8mubmZ54LU7XajhZEghQ/SCJcM0x3OCHKJBx5TJld0zrNIt4kkZU9tLQca31u/7Dka t3S3Ds8N364crEt1pxVzvCZ/vLhnsbxJiQVXnv5C52ZpPSKGVQHD1LGXwXBikUKgysTR gkxDJ1MgmovT06b4/k2d+liT5K+Iw3JlfccEQAjdurw4WHA9njharvK7Iga/OghAbYeI vyg17AtX3dBBth/wv1f1YaIzSfJvxcSXX8fu4oeBpr8ygpBopvFvxP4QRMZ+Gc8KciqC 9SiA== X-Gm-Message-State: AGRZ1gK6zvfhO0a6glmT6rhJCWTSsULJhjii1Joi0/ENkfe9Lx+1Ikxc EgaELUk0c24hj2RS7qZjCMZOUFuf8OM= X-Google-Smtp-Source: AJdET5esD94Q1/ODkRdMmVCQmY6Ck0MgWNkXClGMNMjjQ2ZxI1QaRN1mk0BJaUpphQ5/z5zpbE3ESg== X-Received: by 2002:a62:8096:: with SMTP id j144mr32591016pfd.140.1543312936702; Tue, 27 Nov 2018 02:02:16 -0800 (PST) Received: from localhost.localdomain.localdomain ([103.129.255.252]) by smtp.gmail.com with ESMTPSA id u78sm5499330pfi.2.2018.11.27.02.02.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 02:02:16 -0800 (PST) From: Li Qiang To: pbonzini@redhat.com, rth@twiddle.net, armbru@redhat.com, ehabkost@redhat.com, mst@redhat.com, marcel.apfelbaum@gmail.com, mark.cave-ayland@ilande.co.uk Date: Tue, 27 Nov 2018 02:02:02 -0800 Message-Id: <1543312923-3074-2-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543312923-3074-1-git-send-email-liq3ea@gmail.com> References: <1543312923-3074-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::442 Subject: [Qemu-devel] [PATCH v2 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: Li Qiang , 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. Signed-off-by: Li Qiang Reviewed-by: Darren Kenny Reviewed-by: Markus Armbruster --- Change since v1: remove the unnecessary change 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 Tue Nov 27 10:02:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10700023 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 9CAEC15A8 for ; Tue, 27 Nov 2018 10:06:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 859EF29356 for ; Tue, 27 Nov 2018 10:06:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7595E2AC15; Tue, 27 Nov 2018 10:06:55 +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 0B22929356 for ; Tue, 27 Nov 2018 10:06:55 +0000 (UTC) Received: from localhost ([::1]:41121 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRaGc-0005HI-7M for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 05:06:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRaCL-0007tK-2m for qemu-devel@nongnu.org; Tue, 27 Nov 2018 05:02:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRaCF-0007bE-EE for qemu-devel@nongnu.org; Tue, 27 Nov 2018 05:02:29 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:44195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRaCE-0007aa-MN for qemu-devel@nongnu.org; Tue, 27 Nov 2018 05:02:23 -0500 Received: by mail-pl1-x644.google.com with SMTP id k8so4712675pls.11 for ; Tue, 27 Nov 2018 02:02:22 -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=oFu6uQitCFR8pd+3CbaOrNcvd+ZfspXLbGXS3yVhGEQ=; b=MSpiBPoPYT1V4Xnc9b22mZo2Wg3pbZTfWu53x4vX5AIrLyXsrRCIHbAVPd23ZKDc7h 9CFiBXKaylm8GG9ro4OchZSiIxVZFAAxr81H1qlDs4EDWnFWKTijsrsdckUDA9mr9Jqp Xyo8ti1lFKDio2rRjIk+goY7Vg27BQhLx3SAyPX/BG3dpuZf7+zudMd6NbVxcuCrDUU4 H5IHby3mN0AhkgHQ8zs39hxHgqBcwFVzxVjFThxnB3tQ8S/vbsBY7P+YmwP050wn3stS BVcKD5fZTnEK9R+xMPafohTqhimIUQAyZKBwpX3vN1FUCq0Qq9drCRCOTHzILNn4Amme oUNg== 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=oFu6uQitCFR8pd+3CbaOrNcvd+ZfspXLbGXS3yVhGEQ=; b=KJeA8vqo4VJOgvRntTQOJ9D145xoTdSYX5jq11SgtcidtcMk+HFvCnm/cSOF7Xt1IN H+BtBBR/Vu9Ipdp+z9F+6fzwjNxYuzLhwwCbC2Miaj7rrHOZl787i5ZeuMNlyeCiZHPB enmvscxbtxFO2vBQC8g/ypxjC7H+0+4Hlf801V6I/EE24zzxbKDooAXq7pl+Z/gByalA 1sUhKzBxB4LFKHfMr/FFUp1uNPMlXjAfxrI6YRb+Qkok+TxYojKW3EMjgaTpCm3qkw0K BqSQTFUQzql5e8lV/2EpmSQnv1ksW56E6QhOZ8BiSyGeD0rb673g/FDov5oCbsClvbSd yfvQ== X-Gm-Message-State: AA+aEWbzSZqqIRNrhS6Y+V0I7Kbc2VQW0A6P6mGYFrxoJmTZyfq2XcBX 0BkA1TRT0nAcNpMDtOpI694= X-Google-Smtp-Source: AFSGD/UPSrhu6Mcj4Nf9AxgCqxOZqDHZIFkesjjfv9E9m8PEJ1ddSabg/uqIJ29b2+ReEM/OHfq06Q== X-Received: by 2002:a17:902:34a:: with SMTP id 68mr23516158pld.268.1543312941860; Tue, 27 Nov 2018 02:02:21 -0800 (PST) Received: from localhost.localdomain.localdomain ([103.129.255.252]) by smtp.gmail.com with ESMTPSA id u78sm5499330pfi.2.2018.11.27.02.02.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 02:02:21 -0800 (PST) From: Li Qiang To: pbonzini@redhat.com, rth@twiddle.net, armbru@redhat.com, ehabkost@redhat.com, mst@redhat.com, marcel.apfelbaum@gmail.com, mark.cave-ayland@ilande.co.uk Date: Tue, 27 Nov 2018 02:02:03 -0800 Message-Id: <1543312923-3074-3-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543312923-3074-1-git-send-email-liq3ea@gmail.com> References: <1543312923-3074-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::644 Subject: [Qemu-devel] [PATCH v2 2/2] hw: vmmouse: drop DEFINE_PROP_PTR() 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: Li Qiang , 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 Use link property instead. Signed-off-by: Li Qiang Reviewed-by: Markus Armbruster Reviewed-by: Darren Kenny --- 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, };