From patchwork Sun Feb 12 22:51:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 652835 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp2124286wrr; Sun, 12 Feb 2023 14:52:41 -0800 (PST) X-Google-Smtp-Source: AK7set8RVwYfmyVR6ya3L5w5WxaGEdXo8fG2LrZNhcwz3o87dJUxQ43bEcOYsjIl2m3SCCpnpL8P X-Received: by 2002:a05:622a:1982:b0:3b6:8b52:1359 with SMTP id u2-20020a05622a198200b003b68b521359mr26360938qtc.0.1676242361436; Sun, 12 Feb 2023 14:52:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676242361; cv=none; d=google.com; s=arc-20160816; b=SRSAfZetK9cba+T4pDV4L3d1RTfDJ11Biu7mEtKDValnaNBaqEAM5FwrSwvWIUYte3 bbZdBXmFqs/I3idd13iAcmHkC36Vwa0qpk9x5PKH50NFcy5cPR1phABlWFwCfGRZ2J7i /d6QN7cGjdyyHxQ06o1DlXQPXTr+ExAGd1+Sb2xRRMK4QL7MgYRHUhnisWIf45nGLM9t 98Q/lDw4aqK7bmlLdJlWlitFI9SkaVxeIMSRd6V7B1ab8UzbL9dyJKTJidErUSq6KlKz KncRlB7rtFGE6hlcATwPrQzd1UTtSugdPuQWkXKxXRM7w7QgTFQkgmz1cm7VQcxmCZzF aC1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kdvTBIlDDxD/zp1XWppgssK6e1Eedl76M1G0yZJNLN8=; b=bgzjPeC2TdTtbEFFckQ/MBRCiIz5sMcUQ0OT8ShoOHATYyf6Psmkgdo1Q0lAfoQbgh yuNCCO7EtEhJMISQxeUr1ZHknNxic7OQlBUS2QTlJo1d5I8mcXBn7QnvmZt9PNPX+tgA 7FE5Uc9w4S1Rt/ZCBqig5lkVaUWtQskz9npjpYhbo+xBMIUVkK5sj3oq+2p0m3KiIcbE uZKqCJH0iMmrxCZEp78RX1qavnOo6zSWc0GgVgpDSf5FMTLJU+ZKhnKZkp86NXEttAJN 5AjNHDinBuRalxd5opIAh+E4l9hhQ0fGCUHmkf4inESgu/NDlNYnF4sjGSqITGwSQRpw pchw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EJRxRY3h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n7-20020a05622a040700b003ba1149aa28si8538777qtx.211.2023.02.12.14.52.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Feb 2023 14:52:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EJRxRY3h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRLCg-0005K3-Ez; Sun, 12 Feb 2023 17:52:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRLCe-0005Io-Qq for qemu-devel@nongnu.org; Sun, 12 Feb 2023 17:52:12 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRLCd-00041D-1b for qemu-devel@nongnu.org; Sun, 12 Feb 2023 17:52:12 -0500 Received: by mail-wr1-x430.google.com with SMTP id co8so6695713wrb.1 for ; Sun, 12 Feb 2023 14:52:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kdvTBIlDDxD/zp1XWppgssK6e1Eedl76M1G0yZJNLN8=; b=EJRxRY3hKHa/rfUJGZCoJCOVgu23RJ/r3/Y057Zb8/O4CMg83atUO9tLTnLclreGV9 ZRR0kPasfIFz86dStzCOuzartlgwXN/FmIUGsSvMKKGymnNzQWuEunrSW5NtNgrjXWfu eR+/mZHBiZ7pnZ+BmMnlnHCKnmyKkoRZuSCBwHyJR58o+6UGG3MZkmVC+IkYkvb+gITj BS6gDQ/8He8DskDgAkoT1/xiPo0uKqs4iUo7gTE3Iz5kaIjoGdp+veoIK+jjUITTS9cO 7fVD+YQRYc8cDSox1VVgKUMz2Baot4mL4FV390r9ADoQp+ozENWRfkW0v+xdebgct8Es OM2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kdvTBIlDDxD/zp1XWppgssK6e1Eedl76M1G0yZJNLN8=; b=2DxsInK2ohvE8Nv2dyTCo+MoeFzzGCMB8IC5xv4J7DahjMAE4n2P27HMVnZXxguNaU 5dZcH+7D29rWOAYRNGa3FmvC4SXlPbVwSxsH8tSEBsq7zK9H8DAL7OHccquDwrZ3H4nf Qh2SEGXsvrGmr1ZLj6LbR3uvqow4gy3DbjZyFnH8wOd4ld2Ce7cN/McnCVjDawXj5WcC AJ2/aH/Oo4QfnkS/HPiVdc1NwfaAJrnIY3c6J++p64aImf1KnEeyx5gNxktRDHdRX897 89JiG6+4Nc44aUdDNQAlZZmLZE0v4J+JqT9ieIkatOfaeWtF9+VCKmeXvdP3540ZLeRn C21Q== X-Gm-Message-State: AO0yUKUCY3iQH7R7AHTaK7jnyxSSfcp2CS4L1Na4coz04wndxR3IM43j X2reQ1wc3icdgld3umy6Z85kzw== X-Received: by 2002:a5d:6108:0:b0:2c4:3d5:46dc with SMTP id v8-20020a5d6108000000b002c403d546dcmr13444357wrt.37.1676242329773; Sun, 12 Feb 2023 14:52:09 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id f15-20020adff98f000000b002c5583ab017sm1630002wrr.15.2023.02.12.14.52.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 12 Feb 2023 14:52:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Eduardo Habkost , qemu-devel@nongnu.org Cc: Richard Henderson , xiaoqiang zhao , Hu Tao , Thomas Huth , qemu-block@nongnu.org, qemu-s390x@nongnu.org, Gonglei Arei , Cao jin , Li Qiang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH 04/19] hw/char/serial-pci-multi: Factor multi_serial_class_initfn() out Date: Sun, 12 Feb 2023 23:51:29 +0100 Message-Id: <20230212225144.58660-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230212225144.58660-1-philmd@linaro.org> References: <20230212225144.58660-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Extract code common to multi_2x_serial_pci_class_initfn() and multi_4x_serial_pci_class_initfn() to multi_serial_class_initfn(). Signed-off-by: Philippe Mathieu-Daudé --- hw/char/serial-pci-multi.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c index faeb0a9476..cd5af24bd2 100644 --- a/hw/char/serial-pci-multi.c +++ b/hw/char/serial-pci-multi.c @@ -155,14 +155,14 @@ static Property multi_4x_serial_pci_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static void multi_2x_serial_pci_class_initfn(ObjectClass *klass, void *data) +static void multi_serial_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass); + pc->realize = multi_serial_pci_realize; pc->exit = multi_serial_pci_exit; pc->vendor_id = PCI_VENDOR_ID_REDHAT; - pc->device_id = PCI_DEVICE_ID_REDHAT_SERIAL2; pc->revision = 1; pc->class_id = PCI_CLASS_COMMUNICATION_SERIAL; dc->vmsd = &vmstate_pci_multi_serial; @@ -170,19 +170,22 @@ static void multi_2x_serial_pci_class_initfn(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } +static void multi_2x_serial_pci_class_initfn(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass); + + pc->device_id = PCI_DEVICE_ID_REDHAT_SERIAL2; + device_class_set_props(dc, multi_2x_serial_pci_properties); +} + static void multi_4x_serial_pci_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass); - pc->realize = multi_serial_pci_realize; - pc->exit = multi_serial_pci_exit; - pc->vendor_id = PCI_VENDOR_ID_REDHAT; + pc->device_id = PCI_DEVICE_ID_REDHAT_SERIAL4; - pc->revision = 1; - pc->class_id = PCI_CLASS_COMMUNICATION_SERIAL; - dc->vmsd = &vmstate_pci_multi_serial; device_class_set_props(dc, multi_4x_serial_pci_properties); - set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } static void multi_serial_init(Object *o) @@ -202,6 +205,7 @@ static const TypeInfo multi_serial_pci_types[] = { .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(PCIMultiSerialState), .instance_init = multi_serial_init, + .class_init = multi_serial_class_initfn, .abstract = true, .interfaces = (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE },