From patchwork Mon Feb 13 18:43:25 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: 1741848 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=LjekvQ6J; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtbV6F0rz23h0 for ; Tue, 14 Feb 2023 05:46:30 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdo1-0000tW-VB; Mon, 13 Feb 2023 13:44:01 -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 1pRdnq-0000r2-2d for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:43:51 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdnn-0008No-Kv for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:43:49 -0500 Received: by mail-wm1-x333.google.com with SMTP id he5so1531754wmb.3 for ; Mon, 13 Feb 2023 10:43:47 -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=Nx8Xgm2tW9Gq4Bio8ruD+Zbqqbx7fjg7obd5raLzp9c=; b=LjekvQ6JXpGK9dEvBMxMKFxxhnOcCFNY+4jwJOIDh0fLNC0AtqqzbU6VQ1lpfEzSSH wlsQsqXnZCz6btSBwVjnYOLogTpKPuHGFiT8IuD07rdmelaZvUrjFbW2yFe4Ubn0PCOl UQWm2tAE90R9PJY0yCVLMMl0IdUR8VB7rhsdKMGMNhl4DMYMhDTadDyLkWWhG9q9PkgO sc+VNF4y0IWpWhaCLxlr9kcuC5u9z8FAvcmtx4Z5J+RkHpZowPapme2Aes2i9wqOjJzK k6EdP16Tj4kEWXDftea8cXGm0x7+Fm2enUun1Csa8T6LIILLHH8k788jfy9ADFqzKrbA 7dew== 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=Nx8Xgm2tW9Gq4Bio8ruD+Zbqqbx7fjg7obd5raLzp9c=; b=T9xoR4dLYjlA9OUem8Z6QV2PUOC3qhfaiIQ+AmHxJLKjRzpYgTCce2w+FlPISXAHDa hHbpDSiAMZTT7B8Tr2q0t3/DrhGYbOY6G+m8JszS7ejtgwfnhWkek8guKfnyw+Fj5V4L mHrY7vL82xVDxpymzVGvd4ich1ZiDsO6G89X0odFDdpjsZT+ebZk11bzyswb9lG60bVw J+AfnYt6rrJ5F5BE7mLozzi4TiUyJ4zeJ8uWR5WYd4n7DrFjHdjBuBhFhFQuvgXWy7oE nHT/e10fZ3W+MDTEd7eJv896XgVGYvkI+NLzQx4S8uluFOw1qeH7KDTbohsXArfSsgY3 3QnA== X-Gm-Message-State: AO0yUKUQKsxSEQ3vj8z1iD1mwOzB/vmnJt5F+4pPWwdO91zw5V0+l9Ok AdjlbdbbZ+3he+moL+P4sO6sBQX9GQ3GrmFI X-Google-Smtp-Source: AK7set+FwJGFsSXEfvfUL0CgboLVrU25L6brOiePRnxkdixl5y2FZ1krjxLy5QYdix4Uc7Pd2AOopA== X-Received: by 2002:a05:600c:1608:b0:3df:dc0d:f0b3 with SMTP id m8-20020a05600c160800b003dfdc0df0b3mr19706716wmn.9.1676313825971; Mon, 13 Feb 2023 10:43:45 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id j6-20020a05600c42c600b003df245cd853sm13850313wme.44.2023.02.13.10.43.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:43:45 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH v3 01/14] hw/char/serial-pci: Replace DO_UPCAST(PCISerialState) by PCI_SERIAL() Date: Mon, 13 Feb 2023 19:43:25 +0100 Message-Id: <20230213184338.46712-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the PCI_SERIAL() QOM type-checking macro to avoid DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé --- hw/char/serial-pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c index 801b769aba..9689645cac 100644 --- a/hw/char/serial-pci.c +++ b/hw/char/serial-pci.c @@ -36,7 +36,10 @@ #include "qom/object.h" struct PCISerialState { + /*< private >*/ PCIDevice dev; + /*< public >*/ + SerialState state; uint8_t prog_if; }; @@ -46,7 +49,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(PCISerialState, PCI_SERIAL) static void serial_pci_realize(PCIDevice *dev, Error **errp) { - PCISerialState *pci = DO_UPCAST(PCISerialState, dev, dev); + PCISerialState *pci = PCI_SERIAL(dev); SerialState *s = &pci->state; if (!qdev_realize(DEVICE(s), NULL, errp)) { @@ -63,7 +66,7 @@ static void serial_pci_realize(PCIDevice *dev, Error **errp) static void serial_pci_exit(PCIDevice *dev) { - PCISerialState *pci = DO_UPCAST(PCISerialState, dev, dev); + PCISerialState *pci = PCI_SERIAL(dev); SerialState *s = &pci->state; qdev_unrealize(DEVICE(s)); From patchwork Mon Feb 13 18:43:26 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: 1741843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hxWM/Hal; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtZQ5rtxz23h0 for ; Tue, 14 Feb 2023 05:45:34 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdo8-0000xo-NW; Mon, 13 Feb 2023 13:44:08 -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 1pRdnv-0000sJ-2R for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:43:56 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdnt-0008OX-9t for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:43:54 -0500 Received: by mail-wm1-x331.google.com with SMTP id k8-20020a05600c1c8800b003dc57ea0dfeso11991136wms.0 for ; Mon, 13 Feb 2023 10:43:52 -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=iJ+QRHFZYIqXqYbl7DIdWxHc+GN5ZGRCj3hAlbpC3f0=; b=hxWM/HalDBWkWTKXW8PAyZ7JCyWlypLHbOkZE+hvCtdPG3AH3ab/kBkDGMzf3r5GIB EUJMistvc/Fd7tiDDmng0a2+iab8eed8zx7PvJNIchVZbcj40U246C+ypoY+8dR6TKdP Vc3rvmvfvvqtNJk/2yAbdEOjYss4cSOhg0bpvb0dBrUfW3hT3WpunMxoqICJc+P7x1+B 2AGnXITbPFx4UD1fQ/w770OGmRYY/7QWwYDQqaOIk2vOY4Rb08hZzc43+pNftyJ4zd17 ZMLmVI12hfYgwWZCvRUoHGlAl1d0lMB5TU+bNA2QS39bxPLMI2aVr86Bx0hptSo8m1Xe ihZw== 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=iJ+QRHFZYIqXqYbl7DIdWxHc+GN5ZGRCj3hAlbpC3f0=; b=lno/aEKqjIzwuw82sqFgT+zs+HPiC3EJrXRgMhh9gQKC8Y1dKn03WddAhLM6hKULR7 m0QM0lweJ6TEcDY1Q7QdUhxn/ZuGvG5TYAnGvYnnRp6CPgyaeCqqpOVRqz4haLYU0htH N/VKwoKSY3mKQ81qE/MOa01IvEOimnEepmXw53xlDumAcmjTjCEbgosNZA4XJkSCSAq0 d3A6Y7etzWIy2o1iQa1xJvb+ZjJ+0O6wkakRoOrZOuWZpkYX/zdW8Ufv942u6NMkPB/6 jOddXy0WxXUAMzGlVsiMtB6m+r2BGHi8JBGKNHHfPAT4OwuM/frakRhuHFJBoyLXfNtP 4J3A== X-Gm-Message-State: AO0yUKWcPx/Q1tOXA8Uv0cz0zZcA7rpz5DSH35tBlyhmFsoRG7asPZhB OB3m+ZG7DE93T47vRAyGtaVMD6VLpkr2qjIE X-Google-Smtp-Source: AK7set82QTwQEsZquQpE/eYBLM4wg+rjrgrMgkFJsfZWh4VYNtOHMZT1VvEN4FICp37eoZQbCvJTpQ== X-Received: by 2002:a05:600c:4b1c:b0:3df:eb5d:c583 with SMTP id i28-20020a05600c4b1c00b003dfeb5dc583mr19498820wmp.17.1676313831607; Mon, 13 Feb 2023 10:43:51 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id k21-20020a05600c1c9500b003e01493b136sm18406084wms.43.2023.02.13.10.43.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:43:51 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH v3 02/14] hw/char/serial-pci-multi: Batch register types using DEFINE_TYPES macro Date: Mon, 13 Feb 2023 19:43:26 +0100 Message-Id: <20230213184338.46712-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org See rationale in commit 38b5d79b2e ("qom: add helper macro DEFINE_TYPES()"). Signed-off-by: Philippe Mathieu-Daudé --- hw/char/serial-pci-multi.c | 52 +++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c index f18b8dcce5..54768d3d53 100644 --- a/hw/char/serial-pci-multi.c +++ b/hw/char/serial-pci-multi.c @@ -189,34 +189,28 @@ static void multi_serial_init(Object *o) } } -static const TypeInfo multi_2x_serial_pci_info = { - .name = "pci-serial-2x", - .parent = TYPE_PCI_DEVICE, - .instance_size = sizeof(PCIMultiSerialState), - .instance_init = multi_serial_init, - .class_init = multi_2x_serial_pci_class_initfn, - .interfaces = (InterfaceInfo[]) { - { INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, - }, +static const TypeInfo multi_serial_pci_types[] = { + { + .name = "pci-serial-2x", + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(PCIMultiSerialState), + .instance_init = multi_serial_init, + .class_init = multi_2x_serial_pci_class_initfn, + .interfaces = (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, + }, { + .name = "pci-serial-4x", + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(PCIMultiSerialState), + .instance_init = multi_serial_init, + .class_init = multi_4x_serial_pci_class_initfn, + .interfaces = (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, + } }; -static const TypeInfo multi_4x_serial_pci_info = { - .name = "pci-serial-4x", - .parent = TYPE_PCI_DEVICE, - .instance_size = sizeof(PCIMultiSerialState), - .instance_init = multi_serial_init, - .class_init = multi_4x_serial_pci_class_initfn, - .interfaces = (InterfaceInfo[]) { - { INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, - }, -}; - -static void multi_serial_pci_register_types(void) -{ - type_register_static(&multi_2x_serial_pci_info); - type_register_static(&multi_4x_serial_pci_info); -} - -type_init(multi_serial_pci_register_types) +DEFINE_TYPES(multi_serial_pci_types) From patchwork Mon Feb 13 18:43:27 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: 1741840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=M21viOpH; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtYb1XhWz23hX for ; Tue, 14 Feb 2023 05:44:49 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdo9-0000y6-Bl; Mon, 13 Feb 2023 13:44:09 -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 1pRdo0-0000tq-U8 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:01 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdny-0008P1-BW for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:00 -0500 Received: by mail-wm1-x331.google.com with SMTP id m20-20020a05600c3b1400b003e1e754657aso3520756wms.2 for ; Mon, 13 Feb 2023 10:43:57 -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=xzELhgE3er5tMNQ9I7jJncHCuwtWilKXAa2ONw84yPk=; b=M21viOpHSiCy0/ZKOZq0RXEE4xTGLz5+ydd2Mf8zV77TFadu504ztwdREBGwdgwnW4 IG2/RbyCPcw3K1584adJg5/nAAGdzwFdJaiCkiWZwOa4dsxGNB2VALCKOPOfk27B3gSk xMq7LPElYcQXPGw3OmT9fcGKYUBh1Oj9aKzck7gTMDsfXrTsNW6vUTAizeXs4v+sud1r t+UtepaqnAQb+TFDieh3v6WO2kjv+EV0hiq7wVPQLDEpIKpxzIyZT0IiP6ip9K1s0bbI J9B3jcryhcBHPV1NKkW3oHbPyAqS+BiayDap5beGM984GTWvjI87jn9+9FNw3Vb3Ry9U J2ZA== 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=xzELhgE3er5tMNQ9I7jJncHCuwtWilKXAa2ONw84yPk=; b=zEzBg93nwUgBJIOGLC9/W2+BN7bFT9sML9SKkk2CXMd0R4NBedV4DnErHXxJ+w622c EnwFlaQ9M/VwFZ654t8olpCISmBZL8dYURT01RyrZYxAZTVh8Yy9NzlJ9pxp1aAGHeGM Rqqs3fEXd/rSiaE+IrKAOa9odRn8J/1Plg2vfekOwL3tOCPJfXX4ozp+kxNTVl/OQfwj 4dAaLB+2qmfeO6Ejx7bPWySukLjhh1MICcDs94A7+9brAZqd92AICFKxy6uAPl9WzMsp M3amgqI1VBCrMl5KbGekFxfBnVcnwZxU8hux6MZWUhCjzlWwrbrX0PfVcGUQT01fBgKv F3Uw== X-Gm-Message-State: AO0yUKUM43684r7VGgMe1laKHdUdSqRNRfhtHfpGT0ouqZVQNdml3Bvf Wz8d2UQipShiwQtdcJSX4T8EO2kOgODMolil X-Google-Smtp-Source: AK7set869JzSwWbaUjraUvTkfaSo6qECxTObZB+u5E4mKPQzEdZIX8MnxlsoRG65zs23nQV6woe2tA== X-Received: by 2002:a05:600c:4d0a:b0:3dc:50c1:5fd4 with SMTP id u10-20020a05600c4d0a00b003dc50c15fd4mr24174441wmp.15.1676313836939; Mon, 13 Feb 2023 10:43:56 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id j37-20020a05600c1c2500b003daf6e3bc2fsm25423793wms.1.2023.02.13.10.43.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:43:56 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH v3 03/14] hw/char/serial-pci-multi: Introduce PCI_MULTISERIAL QOM abstract parent Date: Mon, 13 Feb 2023 19:43:27 +0100 Message-Id: <20230213184338.46712-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Introduce PCI_MULTISERIAL ("pci-serial"), QOM abstract parent of "pci-serial-2x" and "pci-serial-4x". Signed-off-by: Philippe Mathieu-Daudé --- hw/char/serial-pci-multi.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c index 54768d3d53..e56c0bc841 100644 --- a/hw/char/serial-pci-multi.c +++ b/hw/char/serial-pci-multi.c @@ -38,8 +38,15 @@ #define PCI_SERIAL_MAX_PORTS 4 -typedef struct PCIMultiSerialState { +#define TYPE_PCI_MULTISERIAL "pci-serial-multi" + +OBJECT_DECLARE_SIMPLE_TYPE(PCIMultiSerialState, PCI_MULTISERIAL) + +struct PCIMultiSerialState { + /*< private >*/ PCIDevice dev; + /*< public >*/ + MemoryRegion iobar; uint32_t ports; char *name[PCI_SERIAL_MAX_PORTS]; @@ -47,7 +54,7 @@ typedef struct PCIMultiSerialState { uint32_t level[PCI_SERIAL_MAX_PORTS]; qemu_irq *irqs; uint8_t prog_if; -} PCIMultiSerialState; +}; static void multi_serial_pci_exit(PCIDevice *dev) { @@ -191,25 +198,23 @@ static void multi_serial_init(Object *o) static const TypeInfo multi_serial_pci_types[] = { { - .name = "pci-serial-2x", - .parent = TYPE_PCI_DEVICE, - .instance_size = sizeof(PCIMultiSerialState), - .instance_init = multi_serial_init, - .class_init = multi_2x_serial_pci_class_initfn, - .interfaces = (InterfaceInfo[]) { + .name = TYPE_PCI_MULTISERIAL, + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(PCIMultiSerialState), + .instance_init = multi_serial_init, + .abstract = true, + .interfaces = (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, { }, }, + }, { + .name = "pci-serial-2x", + .parent = TYPE_PCI_MULTISERIAL, + .class_init = multi_2x_serial_pci_class_initfn, }, { .name = "pci-serial-4x", - .parent = TYPE_PCI_DEVICE, - .instance_size = sizeof(PCIMultiSerialState), - .instance_init = multi_serial_init, + .parent = TYPE_PCI_MULTISERIAL, .class_init = multi_4x_serial_pci_class_initfn, - .interfaces = (InterfaceInfo[]) { - { INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, - }, } }; From patchwork Mon Feb 13 18:43:28 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: 1741841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hhFsKwfl; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtYh6m4jz23hX for ; Tue, 14 Feb 2023 05:44:56 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdoD-0000zX-Hg; Mon, 13 Feb 2023 13:44:13 -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 1pRdo7-0000wl-HN for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:07 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdo3-0008R1-Si for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:06 -0500 Received: by mail-wm1-x331.google.com with SMTP id n33so3340959wms.0 for ; Mon, 13 Feb 2023 10:44:03 -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=fmzU+qV6CluU3J1xGV1AbokblN6ppa6B541b+KpiIv4=; b=hhFsKwfl8RPPanqxZ1cHxyJlC3FJrQVRW+AtRh0s31aXN+MrVZi8uM1elzp0JpPIBf ExkFH45g/sDVuilF3PL5MUfJKHSQIa3tuzzVCryMyJG2a5u+075Zv1nFk7f3Dan5J4K6 9ZYANehzrjXAtor9E8q8U0jWkZJs5QflJi+zt/5qwfxpy4d0UASXh9daQgzwR4Fn1nqN Nfzbtfb+16vcuZWJXJ43P+1ZcsF1AOlajBuQGEkXjWPvnZpSt3N+J4exbUfGDjpsz7Ac AW9oaDeoDPjV6aIK24MgonzHL/vFvBRICQxegVy1F0IYpK9HPLdDcj5KN2JFeK4cXre+ vQ5w== 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=fmzU+qV6CluU3J1xGV1AbokblN6ppa6B541b+KpiIv4=; b=BaHcKSBx6dc8tKMukrgwW7frYtGd7o1rOLFgndmD6Lwrh5gm9MjKYGrSrCO5FG/Vhd GCOW0JwFN9P9CHbUUZHu2laZvaJv1lKe2hoJky59ytvzHS0H/pf1y88dS16xqcPDy+Od 5fLIRnxblB4bcx7YTYv+xDkrJI4d9tNvXX6Y7qs8O53noil9RwXHT7A7qEk0IeETxRkq oVq4h3wygUOD5HdJ3lMks979f3PBC1GBgjO9ASZkuppb4XjHg5nWljb8TcE2jE2yeYKb AznnE1VWc7iB+gLbAHmYSdbQzb8de210H9fUcMyGYFxFjaF1GK+xvOZxrst4yeQSSfzg /x7g== X-Gm-Message-State: AO0yUKWcAnAkC2iyFXt/+8F3BlwOvcW5/DEmGRxL2HQW5BYVSktD5McW 0CKejcMeDkbZDwGO3t/sdSWrJSyDjCOGZTez X-Google-Smtp-Source: AK7set/eEHjVShMKK0yCQbKzE0CZnaPeQ8T3wPxbneoVn1Bv/s9YaSEmz2GFwRn+FU6eCx/180Zpug== X-Received: by 2002:a05:600c:3299:b0:3dc:496f:ad56 with SMTP id t25-20020a05600c329900b003dc496fad56mr18699541wmp.14.1676313842212; Mon, 13 Feb 2023 10:44:02 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id hg8-20020a05600c538800b003e1202744f2sm11839097wmb.31.2023.02.13.10.44.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:01 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH v3 04/14] hw/char/serial-pci-multi: Factor multi_serial_class_initfn() out Date: Mon, 13 Feb 2023 19:43:28 +0100 Message-Id: <20230213184338.46712-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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 e56c0bc841..704be5c294 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 }, From patchwork Mon Feb 13 18:43: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: 1741844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=jI1P/tOj; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtZz5mpcz23h0 for ; Tue, 14 Feb 2023 05:46:03 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdoE-00014i-OW; Mon, 13 Feb 2023 13:44: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 1pRdoA-0000zA-FK for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:10 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdo8-0008P1-KE for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:10 -0500 Received: by mail-wm1-x331.google.com with SMTP id m20-20020a05600c3b1400b003e1e754657aso3521092wms.2 for ; Mon, 13 Feb 2023 10:44:08 -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=yz6IoxjWNiku5kCSpBghWuT3DdtWubTdcdH43JCupO0=; b=jI1P/tOjW9ruO26diB/wqKvoc4LbkvFcbqid/SNBffoSTAE8C5sMngFDii/eXeDXID 8Gg+AOi/4iEjqTyKkMG11hVagnBMxrLKPpVhoQk74yTap6wcWbjZX3D5oMZJACT2RnnV aQOFMecmRpsqqgDCMneXD2h7zJJFeDXCP4nwMVWwxhogdUpG63yIwW+rx/Crgrq0r08p Kdn48Oq5VVJ7BysstFHyujnqIOrP+p57y4ia5GPkxoOkeSn67E1CHt3Ucy5WTq3DA8Ud xb0iPbPDsjdBG6apMN1Ddj0zzYbq80DGcOmgrBVQVOrrdrevY3w7mHc+yXIeOcgstu+H CVtg== 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=yz6IoxjWNiku5kCSpBghWuT3DdtWubTdcdH43JCupO0=; b=MigPJRKL7bvGU3gquy7TlVMTbp5TRwIY7Tq0/hshd/UDe7VJ/Cft/4k5P6fuOezqBV CUSE4Pzu5/BLb3hmJQFBDAFaebQGn/LBB4atGg4jJVlBYH4r6mlknNYpUSaPpWkXC/qx yN0dHkkTkS/774/GANZC4Bo7LIct6bFz70ZfCX+PY3/F7uFA0u/cqWYCpYsBGHuCxC5B LPtjqTJzRiwqZgdaErDtjSNiwoqFl/DfykIFR+EeDmLhBWfzRQrV3mOiMQk4/h7DKQav PMIiNn2ZUDMsP5heJTberdCK2FABJNZFFE4Wo+9J6Peb6zSMX68EWVd9C2F2Rvztv3dM rVIg== X-Gm-Message-State: AO0yUKX8e3LzYkyxhVK1/vuKboxtErqLGZQxuXRlgffrw6J4+MlSwgJE xo7NQ/VkUSixDzNytrXG9fXDugeaCF6A1Ila X-Google-Smtp-Source: AK7set+0Pp4E918vOEyEA7jUtXVkZeCMxMXElateD+1e4UJKmouCtmYWmVAPEdGnwUbpYe14OHoEjg== X-Received: by 2002:a05:600c:1895:b0:3dc:4aa6:a8a9 with SMTP id x21-20020a05600c189500b003dc4aa6a8a9mr19187855wmp.7.1676313847532; Mon, 13 Feb 2023 10:44:07 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id v18-20020a05600c445200b003de77597f16sm16157583wmn.21.2023.02.13.10.44.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:07 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH v3 05/14] hw/char/serial-pci-multi: Replace DO_UPCAST() by PCI_MULTISERIAL() Date: Mon, 13 Feb 2023 19:43:29 +0100 Message-Id: <20230213184338.46712-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the PCI_MULTISERIAL() QOM type-checking macro to avoid the few DO_UPCAST(PCIMultiSerialState) calls. Signed-off-by: Philippe Mathieu-Daudé --- hw/char/serial-pci-multi.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c index 704be5c294..d660b6fa97 100644 --- a/hw/char/serial-pci-multi.c +++ b/hw/char/serial-pci-multi.c @@ -58,7 +58,7 @@ struct PCIMultiSerialState { static void multi_serial_pci_exit(PCIDevice *dev) { - PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev); + PCIMultiSerialState *pci = PCI_MULTISERIAL(dev); SerialState *s; int i; @@ -97,11 +97,10 @@ static size_t multi_serial_get_port_count(PCIDeviceClass *pc) g_assert_not_reached(); } - static void multi_serial_pci_realize(PCIDevice *dev, Error **errp) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); - PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev); + PCIMultiSerialState *pci = PCI_MULTISERIAL(dev); SerialState *s; size_t i, nports = multi_serial_get_port_count(pc); @@ -190,9 +189,8 @@ static void multi_4x_serial_pci_class_initfn(ObjectClass *klass, void *data) static void multi_serial_init(Object *o) { - PCIDevice *dev = PCI_DEVICE(o); - PCIMultiSerialState *pms = DO_UPCAST(PCIMultiSerialState, dev, dev); - size_t i, nports = multi_serial_get_port_count(PCI_DEVICE_GET_CLASS(dev)); + PCIMultiSerialState *pms = PCI_MULTISERIAL(o); + size_t i, nports = multi_serial_get_port_count(PCI_DEVICE_GET_CLASS(o)); for (i = 0; i < nports; i++) { object_initialize_child(o, "serial[*]", &pms->state[i], TYPE_SERIAL); From patchwork Mon Feb 13 18:43:30 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: 1741846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=wyGNJ1e9; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtb22H2gz23h0 for ; Tue, 14 Feb 2023 05:46:06 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdoI-00018c-2h; Mon, 13 Feb 2023 13:44:18 -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 1pRdoG-00017e-G1 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:16 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdoE-0008S7-FA for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:16 -0500 Received: by mail-wr1-x42b.google.com with SMTP id bu23so13250387wrb.8 for ; Mon, 13 Feb 2023 10:44:14 -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=JeDWNjpVkKdLbShBUyGUp3JADBIyaux21T6WZ6Gmeuk=; b=wyGNJ1e9rn/cDhznCSVxUi9QrvUJeeLe8uPIVaQFHCRyHTpKxt2Ypmp10tI6tUxfB0 sRoKpqNXV7RKip9Zc4kvT8+TygwQdjYtYghtf+HCqxiYCo41uqy5VuWVd4IJaE0LFjao E0mbxveHTg9HG2TAjcMMZVRKAivzx/2x9wDzJJgE+YhRsm5baDHC6JBA5I1cuQvgh/zj 3mlprAZ9z/U0phbuPrcs8ylB2nhWVEyHQ9jQEHR1eCu3/3AMAm54xj1XDz+Z0krnMl3H EkrRuQ8Kx+o9+VFy0QP5L8SQf0Gxz3lzHBa0iHHVSR3mzhyraF5058ynu7rE8/5/LX6C iSfw== 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=JeDWNjpVkKdLbShBUyGUp3JADBIyaux21T6WZ6Gmeuk=; b=uZwcHTgMk0oCtF39RATeBZCX4o0DegQk2tYJP7eYTI1fVycdBfDhJu0tgLk/QVI98P dKAkITN8bMuB2Cjnbriane2JQBxGtW+zUfVrDLBfgwEnOp5aiXlpJfAuERYGopFgq1N4 ABBymGicJeB7WValiCf/eRJI5DgMzwgo/VaiuBrQUE3MwFNrL8trFiKQDHnr0BAPUvVa bsOH71TvCrBku6820huRW40RKhwFrlrLa6aMnWyheArfjrk9M1oVdLN+tqtspUz915Dn Jq1iG9ZQr3s8ziX5FJe65EFSZ5CWdeHIWKB8fEiKzqaXw3K0nGN7NEay8B1nviVSvv7S 39Aw== X-Gm-Message-State: AO0yUKVUL/0/sWoY5km7enjKA5kwr5PWOLwAbgNb9cjwkIL/raCC3rbW cbpVZxzs6M2OVyh4SMyvkTuJ3ykS6Wt+NDPZ X-Google-Smtp-Source: AK7set/MQgoBNoqrrPeAqBp71FtJAW50sAiDiEq9GDKq+W4U1A3FYyyT6lXdSuXvj8jhF1TXO0W77w== X-Received: by 2002:adf:e7d0:0:b0:2c5:586b:f53d with SMTP id e16-20020adfe7d0000000b002c5586bf53dmr4442166wrn.48.1676313852972; Mon, 13 Feb 2023 10:44:12 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id d7-20020adfe887000000b002c551f7d452sm5849414wrm.98.2023.02.13.10.44.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:12 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow Subject: [PATCH v3 06/14] hw/ide/qdev: Replace DO_UPCAST(IDEDevice) by IDE_DEVICE() Date: Mon, 13 Feb 2023 19:43:30 +0100 Message-Id: <20230213184338.46712-7-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the IDE_DEVICE() QOM type-checking macro to avoid DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/qdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 6ae2627a56..1ead62fd18 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -133,7 +133,7 @@ IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive) qdev_prop_set_drive_err(dev, "drive", blk_by_legacy_dinfo(drive), &error_fatal); qdev_realize_and_unref(dev, &bus->qbus, &error_fatal); - return DO_UPCAST(IDEDevice, qdev, dev); + return IDE_DEVICE(dev); } int ide_get_geometry(BusState *bus, int unit, From patchwork Mon Feb 13 18:43:31 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: 1741850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=IX9uVrlK; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtcH1Mzsz23h0 for ; Tue, 14 Feb 2023 05:47:11 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdoO-0001At-Gr; Mon, 13 Feb 2023 13:44:24 -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 1pRdoL-00019i-Mq for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:21 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdoJ-0008TB-PA for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:21 -0500 Received: by mail-wr1-x42d.google.com with SMTP id k3so5634959wrv.5 for ; Mon, 13 Feb 2023 10:44:19 -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=/hnCzjPfxFE+jbV/pOTQTvC2sGuBuierxSlf21esNXo=; b=IX9uVrlK4z4v5wHmT/ms9nRTa9td+Wtl2M9zlza8++IaYw7ZXYjHQ2VrFrHfN7KwFl FnxP9XhB7nBrp9qunnp67yNoGbX736q7NpdRXv3exJluCAnHZCx5UuHqDKJegR5GI/Cd d8ojIQYm/E+aiuHTRFEV+RUh39hLJ+ZlD5eSJsmxrhwGKpRsp2vu3f0R0+J1ZQoE+c3p vsVk8Y148lADz+/LkloHBZWHSqwXRqNqbLTl35a3ArLXs0hKZgNbItcbRGAHltbc94Cm tQ396zmUAOvHv9imYwrxaD3hg02o080qMYD/rZ4IF4NxqKt9PgLzk4Clg4ACaPcnQRfp kbTQ== 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=/hnCzjPfxFE+jbV/pOTQTvC2sGuBuierxSlf21esNXo=; b=qxittwVlHPlGGaMJOLbWiR84Z5gOcaRfzpCytU+H39WqTbzjpCQAJlceJUCD6zEp8H PtagJr+wFZSRwOXu2fKmNJBt1m8HW5N+/VZnjKruFoasb12LymKKqIozG0qVT0oxIala 6tlxc2Hg1b7G7yw85aKuhELRcZBcYsdzFw2T/UpDLbCGd6DfPI6r55ZVve0prK/oPFZK JQGEY13oYFhddSmgCuAgz+FfYOnMHrh8ByT3zLxizi/WsWieOaw8nUu0Kd0VfOIlhjHM GtWt1LY9RD1Guxvf+VmJr8NZDNzwEK0fUoVdTnqA3RyB5iqDeGDS7sts3fvWgesjonjd OxGw== X-Gm-Message-State: AO0yUKVVhwzi2lWwwC2Ad+GD80I2JnR4Nxw8FfJM8/mL0gvx54L9J2e4 GyE1mA/0sExhw+N/im86FYU2FRqC/pVO6FGZ X-Google-Smtp-Source: AK7set/fPAAMQj/95nERDCqSiBR95w+sxR1I7ZgkvFM3+BKM5OtHu/dLh8JCdg6fNgKtjRRMFcBq2A== X-Received: by 2002:a5d:4ec6:0:b0:2c5:587e:75ba with SMTP id s6-20020a5d4ec6000000b002c5587e75bamr4147313wrv.55.1676313858144; Mon, 13 Feb 2023 10:44:18 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id v18-20020a05600c445200b003de77597f16sm16158016wmn.21.2023.02.13.10.44.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:17 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow Subject: [PATCH v3 07/14] hw/ide/qdev: Replace DO_UPCAST(IDEBus) by IDE_BUS() Date: Mon, 13 Feb 2023 19:43:31 +0100 Message-Id: <20230213184338.46712-8-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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=ham 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the IDE_BUS() QOM type-checking macro to avoid DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/qdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 1ead62fd18..a168643266 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -90,7 +90,7 @@ static void ide_qdev_realize(DeviceState *qdev, Error **errp) { IDEDevice *dev = IDE_DEVICE(qdev); IDEDeviceClass *dc = IDE_DEVICE_GET_CLASS(dev); - IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev_get_parent_bus(qdev)); + IDEBus *bus = IDE_BUS(qdev_get_parent_bus(qdev)); if (dev->unit == -1) { dev->unit = bus->master ? 1 : 0; @@ -139,7 +139,7 @@ IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive) int ide_get_geometry(BusState *bus, int unit, int16_t *cyls, int8_t *heads, int8_t *secs) { - IDEState *s = &DO_UPCAST(IDEBus, qbus, bus)->ifs[unit]; + IDEState *s = &IDE_BUS(bus)->ifs[unit]; if (s->drive_kind != IDE_HD || !s->blk) { return -1; @@ -153,7 +153,7 @@ int ide_get_geometry(BusState *bus, int unit, int ide_get_bios_chs_trans(BusState *bus, int unit) { - return DO_UPCAST(IDEBus, qbus, bus)->ifs[unit].chs_trans; + return IDE_BUS(bus)->ifs[unit].chs_trans; } /* --------------------------------- */ @@ -164,7 +164,7 @@ typedef struct IDEDrive { static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp) { - IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev_get_parent_bus(DEVICE(dev))); + IDEBus *bus = IDE_BUS(qdev_get_parent_bus(DEVICE(dev))); IDEState *s = bus->ifs + dev->unit; int ret; From patchwork Mon Feb 13 18:43:32 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: 1741854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=gP9ewFH4; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtcX0Y9Rz23h0 for ; Tue, 14 Feb 2023 05:47:24 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdoV-0001Nh-LM; Mon, 13 Feb 2023 13:44:31 -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 1pRdoR-0001Hj-SC for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:27 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdoP-0008Tc-Jn for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:27 -0500 Received: by mail-wm1-x334.google.com with SMTP id f47-20020a05600c492f00b003dc584a7b7eso11954767wmp.3 for ; Mon, 13 Feb 2023 10:44:25 -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=VotmsYo6EZx1VvqMFkr1+QDMy3wRb1XAiA9w0UCQyq8=; b=gP9ewFH4awNxF2vi0b8jkzWKJ0I8idDoCPVWlFgHGp/VCPiDRsWJZEo/czC6DNh9wv iAZnHPe7ZusDLdDCCjbTBoUhmqMmzfGNK/m6/KPRttR6zVV7zbcqSUlq+674DTqlzQsr uTW6xLj/x220CydgFWuPc/YqthaVbmaQMIa7lMg6z1opRP86nPA7zDXhZ7pXc+sSdnLa FiLFiFUG1gm+rlqYjtxGHI+305ZxxY6CSGN1hTmGCgrYT5h7nMo0S1zmzjTa8MOrKUN2 ClSOO+Ly2qWes3kWcTbRUoUg70BZs7WWeR0X+fzE3vaJ1qEJN+pLBi/3mYhT6i8JiH2S 26yg== 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=VotmsYo6EZx1VvqMFkr1+QDMy3wRb1XAiA9w0UCQyq8=; b=2oKIaAx8GyuikKGHzkzr5nOmR5ykhI24OaxDnU+UTCXn78sTQUpbhTzxDJ62D3spJL /o+l29FCVfKglbnFE1ue10hZ4I46kwAmunvWTk60VQo6lTwNVItRMyfXqgV/AH3Qb+oG iRF1zDNge+IuEnJ+HMjfWjlWBzf8nqEF7jRsUOpmxKPH7qWVBF2liOP/MfGVnEd5pMXR acBVHn62CZnFRIDeFM3rng9/s9rgkRthmqKwHDeQHEhnJpj1WKo5MXEaApymnVm8x3rf ewYdRlhqyYSAKE1Hy6ZccpmgMaE4cD7E6OH+VHtMyZsFOr9Z4HnCvsf5kascPnDXheK9 pwhQ== X-Gm-Message-State: AO0yUKWAkCZ/enuGqAaujqw9PlAW15IurQf9i5oGzyCoM1TUTU/t153n OYKJPjkSvScQ6bdHQ49lrNIQhXoQFp1aI5S8 X-Google-Smtp-Source: AK7set+ttktzTE0funo+iFA5a2T8gBjUoqvrzkcZ/Ca8lK9NiXCf5sXy+/grsVOUzSNomaTkYfeJ5Q== X-Received: by 2002:a05:600c:491d:b0:3da:2a78:d7a4 with SMTP id f29-20020a05600c491d00b003da2a78d7a4mr19705810wmp.21.1676313863858; Mon, 13 Feb 2023 10:44:23 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id d5-20020a1c7305000000b003dc4baaedd3sm17223550wmb.37.2023.02.13.10.44.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:23 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PATCH v3 08/14] hw/net/ne2000-pci: Replace DO_UPCAST(PCINE2000State) by PCI_NE2000() Date: Mon, 13 Feb 2023 19:43:32 +0100 Message-Id: <20230213184338.46712-9-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Define TYPE_PCI_NE2000 and the QOM PCI_NE2000() macro. Use PCI_NE2000() instead of DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé --- hw/net/ne2000-pci.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/net/ne2000-pci.c b/hw/net/ne2000-pci.c index edc6689d33..0332e7f616 100644 --- a/hw/net/ne2000-pci.c +++ b/hw/net/ne2000-pci.c @@ -30,10 +30,16 @@ #include "ne2000.h" #include "sysemu/sysemu.h" -typedef struct PCINE2000State { +#define TYPE_PCI_NE2000 "ne2k_pci" +OBJECT_DECLARE_SIMPLE_TYPE(PCINE2000State, PCI_NE2000) + +struct PCINE2000State { + /*< private >*/ PCIDevice dev; + /*< public >*/ + NE2000State ne2000; -} PCINE2000State; +}; static const VMStateDescription vmstate_pci_ne2000 = { .name = "ne2000", @@ -54,7 +60,7 @@ static NetClientInfo net_ne2000_info = { static void pci_ne2000_realize(PCIDevice *pci_dev, Error **errp) { - PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev); + PCINE2000State *d = PCI_NE2000(pci_dev); NE2000State *s; uint8_t *pci_conf; @@ -77,7 +83,7 @@ static void pci_ne2000_realize(PCIDevice *pci_dev, Error **errp) static void pci_ne2000_exit(PCIDevice *pci_dev) { - PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev); + PCINE2000State *d = PCI_NE2000(pci_dev); NE2000State *s = &d->ne2000; qemu_del_nic(s->nic); @@ -87,7 +93,7 @@ static void pci_ne2000_exit(PCIDevice *pci_dev) static void ne2000_instance_init(Object *obj) { PCIDevice *pci_dev = PCI_DEVICE(obj); - PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev); + PCINE2000State *d = PCI_NE2000(pci_dev); NE2000State *s = &d->ne2000; device_add_bootindex_property(obj, &s->c.bootindex, @@ -117,7 +123,7 @@ static void ne2000_class_init(ObjectClass *klass, void *data) } static const TypeInfo ne2000_info = { - .name = "ne2k_pci", + .name = TYPE_PCI_NE2000, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(PCINE2000State), .class_init = ne2000_class_init, From patchwork Mon Feb 13 18:43:33 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: 1741847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=JclyZ9/U; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtbS3mWmz23h0 for ; Tue, 14 Feb 2023 05:46:28 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdoW-0001Sd-WF; Mon, 13 Feb 2023 13:44:33 -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 1pRdoW-0001Nx-2N for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:32 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdoU-0008S7-JE for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:31 -0500 Received: by mail-wr1-x42b.google.com with SMTP id bu23so13251067wrb.8 for ; Mon, 13 Feb 2023 10:44:30 -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=fD8XsrjHaA7eijBs8OwmQ3XFemQ30TcP+DXj6h7knEg=; b=JclyZ9/UqBA9BGGqA55SoSo+LpL1ZYdxe3PslvYu0+Yxk9KVvZ9IAaUZaDBkNXcQGO Iir74BDi18LUqcAmsy0C6cWDzj1wTIhCbQt6E1iZG7JN2uoyRDBlh4FG7cdGXPGQNgwe qQSkeYZeigYr4Wq+SCC6Wmb8hzuTPSFS+B0toflyI8TiFIYuTQ5OJS4t9q02HFVEVpW1 vZ16spJxrCwlh6KhD5iGgrir1VcX3GE+/e5FXFIA6j7zecRrS4froZyBhb01JANmQCci AhmEqrixRAzaIeb3/kjzNuMfHJ7VHo38IYbBkWyBk0rKgusieKEatRh0wDn2yw03EFpW f4bA== 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=fD8XsrjHaA7eijBs8OwmQ3XFemQ30TcP+DXj6h7knEg=; b=k+Rv//Ub0ixjtp5q1oWbrdazRhMFirlhLjyHcmhg54Z1XcPqW5A5wAGImNUggICISE oLgHIOxHFRb11Fmv3c96J8/kno6KeRtzGjQ9rjz+rbU1ZW+6y0E8jAes04jLQh+Xp8MD X9GhitLxBTMcN4GtULOzN1uAjr1EF1EWux3mcY4n4W81gZeEuFxhua5qpMH+phdkrnCs OqZHE4UzGWAjIlmqThtL0vAGARWwazEV66cyklh39ntoe7Z2bYhkqKIwAHQcX7PX/qNL 1ghIxP1K9BpTUkq7d1O2oarUUFUeFZwVfDeHNniN8Fi/t50AV5+rRJRfawf4hBjULdo+ BrGg== X-Gm-Message-State: AO0yUKV+kveJsITDY7S3Bd8ejwGS+XbUtYomiyF1w5QKn1nDN+JY8a0K vUkE3Adzat4oBp+fGng9V5ct1AVqTuLQWz4x X-Google-Smtp-Source: AK7set+0F/IC3ACw97foscAd1Yh3dEJIa8CBVY8UR2vjeghYtXwz20EDRQqvYdIH121r17pg40+1Hw== X-Received: by 2002:a5d:4577:0:b0:2c5:4ec7:a466 with SMTP id a23-20020a5d4577000000b002c54ec7a466mr6889035wrc.31.1676313869723; Mon, 13 Feb 2023 10:44:29 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id z6-20020a1c4c06000000b003d1d5a83b2esm17393991wmf.35.2023.02.13.10.44.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:29 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sven Schnelle , Jason Wang Subject: [PATCH v3 09/14] hw/net/tulip: Finish QOM conversion Date: Mon, 13 Feb 2023 19:43:33 +0100 Message-Id: <20230213184338.46712-10-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the TULIP() and DEVICE() QOM type-checking macros. Remove uses of DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé Acked-by: Jason Wang --- hw/net/tulip.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/hw/net/tulip.c b/hw/net/tulip.c index 915e5fb595..990507859d 100644 --- a/hw/net/tulip.c +++ b/hw/net/tulip.c @@ -19,7 +19,10 @@ #include "net/eth.h" struct TULIPState { + /*< private >*/ PCIDevice dev; + /*< public >*/ + MemoryRegion io; MemoryRegion memory; NICConf c; @@ -959,7 +962,7 @@ static void tulip_fill_eeprom(TULIPState *s) static void pci_tulip_realize(PCIDevice *pci_dev, Error **errp) { - TULIPState *s = DO_UPCAST(TULIPState, dev, pci_dev); + TULIPState *s = TULIP(pci_dev); uint8_t *pci_conf; pci_conf = s->dev.config; @@ -967,7 +970,7 @@ static void pci_tulip_realize(PCIDevice *pci_dev, Error **errp) qemu_macaddr_default_if_unset(&s->c.macaddr); - s->eeprom = eeprom93xx_new(&pci_dev->qdev, 64); + s->eeprom = eeprom93xx_new(DEVICE(pci_dev), 64); tulip_fill_eeprom(s); memory_region_init_io(&s->io, OBJECT(&s->dev), &tulip_ops, s, @@ -983,27 +986,26 @@ static void pci_tulip_realize(PCIDevice *pci_dev, Error **errp) s->nic = qemu_new_nic(&net_tulip_info, &s->c, object_get_typename(OBJECT(pci_dev)), - pci_dev->qdev.id, s); + DEVICE(pci_dev)->id, s); qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a); } static void pci_tulip_exit(PCIDevice *pci_dev) { - TULIPState *s = DO_UPCAST(TULIPState, dev, pci_dev); + TULIPState *s = TULIP(pci_dev); qemu_del_nic(s->nic); qemu_free_irq(s->irq); - eeprom93xx_free(&pci_dev->qdev, s->eeprom); + eeprom93xx_free(DEVICE(s), s->eeprom); } static void tulip_instance_init(Object *obj) { - PCIDevice *pci_dev = PCI_DEVICE(obj); - TULIPState *d = DO_UPCAST(TULIPState, dev, pci_dev); + TULIPState *s = TULIP(obj); - device_add_bootindex_property(obj, &d->c.bootindex, + device_add_bootindex_property(obj, &s->c.bootindex, "bootindex", "/ethernet-phy@0", - &pci_dev->qdev); + DEVICE(obj)); } static Property tulip_properties[] = { From patchwork Mon Feb 13 18:43:34 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: 1741845 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=BfsZ/BP4; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtZz5xtDz23yT for ; Tue, 14 Feb 2023 05:46:03 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdoe-0001nB-6I; Mon, 13 Feb 2023 13:44:40 -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 1pRdoc-0001hf-Bp for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:38 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdoa-0008T9-Fz for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:37 -0500 Received: by mail-wr1-x42d.google.com with SMTP id m14so13242538wrg.13 for ; Mon, 13 Feb 2023 10:44:35 -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=3YnlWYrFQuWXt1rppNJud8kwI6R078rMYORIY8x9Pr4=; b=BfsZ/BP4Bj77HitzpAxlAgqnSThR1vBBm4ORMLX3gPBBk+Yt9lLoiFO5JNcCQ/CrTQ 5ZLRYeMaTkKUIZpiCo5h6WzLQwUf1UOFFiyIGdFE+FaRHVruAZFaQ1il4/10R0jz/yhR DunoSIYVsXnAXXQ+Uhl89HK6YJDbaKCdLR9emwlSoObFYTL9YvtSetyVVcK82f9C/FVU TzX8A7LPSwPlSWSg3JVfGUJMIPdq+X1VaftsTe3iGjOdTYDLkvGQNgTN0QFsNi9pEOv7 ORjPr3HuW8kpgqHhaAa7KokUtEmdl0RDdSBp5W2DdLpBVAAzX5dUeUulpq23wNdmpjJE XVeA== 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=3YnlWYrFQuWXt1rppNJud8kwI6R078rMYORIY8x9Pr4=; b=nmw52/FNX6uSzEhb+kbb2a3avtTs6j1Zj5EQxsZRuXIYAkR4QrdEL6onFXPT5XxJKB W+Uq/0x1YIKvhuuRakgy+wUYO9//sHYwzxQx6ubMx/EdsdLWHgXRDm8pzEOSSJ20QfEk vfj6XoCKdUOtk/IPflBk9EItotDH2UJaqeeOhX6BNAaxsi3GOFUbnHZL2Cd/AJuJUDmn HDiLHxk8Vboa0ccav2+7Zuy1ht0xQnjrV5AcUuK9LX6mo6BKAHtZFqbCgrf54xlluwP4 9O8QfuqsFMcl8Hdvh4Lv9Tkatakow0gc2vqV6hsUT4eO+Ele1eINxBKS0TdJH3MT/iIb lRjg== X-Gm-Message-State: AO0yUKW6JU1teBBO80QXzEyOShs1686c326ZA4mtJ5W5sCOOP5NrhfMm r1+KQKycKSaFitTOwPp8FfHgJ7RtOQME+QJt X-Google-Smtp-Source: AK7set+SNr4ZuTEvP/gd8VtjCUM0EEHTi7QjIKQsOuz3b7ITdDO+q7mpfZMBrbPVemy/B9OjZYrzFA== X-Received: by 2002:a5d:5044:0:b0:2c3:eaff:aae9 with SMTP id h4-20020a5d5044000000b002c3eaffaae9mr21611803wrt.19.1676313875408; Mon, 13 Feb 2023 10:44:35 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id m17-20020a05600c3b1100b003df5be8987esm19080586wms.20.2023.02.13.10.44.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:35 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum Subject: [PATCH v3 10/14] hw/pci/pci: Replace DO_UPCAST(PCIBus) by PCI_BUS() Date: Mon, 13 Feb 2023 19:43:34 +0100 Message-Id: <20230213184338.46712-11-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the PCI_BUS() QOM type-checking macro to avoid DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé --- hw/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2e785e3aef..ae5c33adb6 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -391,7 +391,7 @@ void pci_device_reset(PCIDevice *dev) */ static void pcibus_reset(BusState *qbus) { - PCIBus *bus = DO_UPCAST(PCIBus, qbus, qbus); + PCIBus *bus = PCI_BUS(qbus); int i; for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) { From patchwork Mon Feb 13 18:43:35 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: 1741851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=IrXHoLjJ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtcS739rz23h0 for ; Tue, 14 Feb 2023 05:47:20 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdon-0001tb-Gu; Mon, 13 Feb 2023 13:44:49 -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 1pRdoi-0001qI-RV for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:45 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdoh-0008Vz-6A for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:44 -0500 Received: by mail-wm1-x32b.google.com with SMTP id n33so3342179wms.0 for ; Mon, 13 Feb 2023 10:44:42 -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=lbFFSEwuPaiVjYWiGHnO40wk80nlXCVErHPDaxFN7V8=; b=IrXHoLjJvRO9HbHPw2U4rArVJbApZYzgT816Q/pq4Jyd2LDWRJAuEVdwriT218Lzn7 ye/qO2wqhc68fUyeCPd7xThRwUqnuN2T3yCFCnwa6gsOaR9IEufcrVOiWnnen96v6EFc e9ZV+oqDtSmMP9lb/+t9Ficg3RCWoRLrXwEPgfBwNLuZZzgxFHkmJJwAh7nylUCsm+IW 7+QpvroKmoYkNWfaNE8jRpLod7LclueYvIyp93PG6fv+YWkiPYF1OtWtJHrMUG1W1m6G 6N6sIlvxhh+kQiWM5xtP1EEB/3Pwlzme8VjPXAnjdo6crbpn3Hsd0nGOazZzVF99lVpF XKaw== 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=lbFFSEwuPaiVjYWiGHnO40wk80nlXCVErHPDaxFN7V8=; b=XNTVfTbjaKl2YBzchxQIbi11DbFJ8kYANzu3bvb6rqUhRbGbKXjHrSvE3rEh+LijNR IoxacG5Rl8aifVhUpWX/M/eYnNhmmLy9O/Q8HICR6XEg5AnQGmTU5wycjU4X1AENrywT p2XQdfGTvVJyJONQ4TVBg4HaRU9d/hMoRc0blqQfFH/P01enakdjMRA8atP+HlAaREYi oHolf3CLqWUahLfX0u6CSgPc4BKZUh+NkrOqYbMHoOX0ufyu1z0vfJf3P9nTkolyBapH EbLTsNUS4M4kkNgby4m2ZWkJH2NgB7XKNMfzXHdjWkCc3729hIYYYFjBELD/9FLX7N4x iZxw== X-Gm-Message-State: AO0yUKXexTDu4rVbXnf6/MwY5ffIbzgKRgBzlSjbAk6lwTzCzJPj+eRQ Vv4MTvn6TFN8yoOqgNbRjCCJtuY1A4TELHte X-Google-Smtp-Source: AK7set8nIPN91DREOFKQvt+K55Z1k2Vl3+XAisCdkJ3vPKfF34AlyUm6jCwAeeVdey0Kjm76r8etMw== X-Received: by 2002:a05:600c:3403:b0:3dc:572f:edb7 with SMTP id y3-20020a05600c340300b003dc572fedb7mr5131983wmp.1.1676313881348; Mon, 13 Feb 2023 10:44:41 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id w19-20020a05600c475300b003e11f280b8bsm12751880wmo.44.2023.02.13.10.44.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:41 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Fam Zheng Subject: [PATCH v3 11/14] hw/scsi/scsi-bus: Replace DO_UPCAST(SCSIBus) by SCSI_BUS() Date: Mon, 13 Feb 2023 19:43:35 +0100 Message-Id: <20230213184338.46712-12-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the SCSI_BUS() QOM type-checking macro to avoid DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé --- hw/scsi/scsi-bus.c | 12 ++++++------ include/hw/scsi/scsi.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 7b2a82b335..c4525515ab 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -104,7 +104,7 @@ static void scsi_device_unrealize(SCSIDevice *s) int scsi_bus_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf, size_t buf_len, void *hba_private) { - SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, qdev_get_parent_bus(DEVICE(dev))); + SCSIBus *bus = SCSI_BUS(qdev_get_parent_bus(DEVICE(dev))); int rc; assert(cmd->len == 0); @@ -250,7 +250,7 @@ static bool scsi_bus_check_address(BusState *qbus, DeviceState *qdev, Error **er static void scsi_qdev_realize(DeviceState *qdev, Error **errp) { SCSIDevice *dev = SCSI_DEVICE(qdev); - SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, qdev_get_parent_bus(DEVICE(dev))); + SCSIBus *bus = SCSI_BUS(qdev_get_parent_bus(qdev)); bool is_free; Error *local_err = NULL; @@ -705,7 +705,7 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d, SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun, uint8_t *buf, size_t buf_len, void *hba_private) { - SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, qdev_get_parent_bus(DEVICE(d))); + SCSIBus *bus = SCSI_BUS(qdev_get_parent_bus(DEVICE(d))); const SCSIReqOps *ops; SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(d); SCSIRequest *req; @@ -1353,7 +1353,7 @@ int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf, void scsi_device_report_change(SCSIDevice *dev, SCSISense sense) { - SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, qdev_get_parent_bus(DEVICE(dev))); + SCSIBus *bus = SCSI_BUS(qdev_get_parent_bus(DEVICE(dev))); scsi_device_set_ua(dev, sense); if (bus->info->change) { @@ -1698,7 +1698,7 @@ static int put_scsi_requests(QEMUFile *f, void *pv, size_t size, const VMStateField *field, JSONWriter *vmdesc) { SCSIDevice *s = pv; - SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, qdev_get_parent_bus(DEVICE(s))); + SCSIBus *bus = SCSI_BUS(qdev_get_parent_bus(DEVICE(s))); SCSIRequest *req; QTAILQ_FOREACH(req, &s->requests, next) { @@ -1726,7 +1726,7 @@ static int get_scsi_requests(QEMUFile *f, void *pv, size_t size, const VMStateField *field) { SCSIDevice *s = pv; - SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, qdev_get_parent_bus(DEVICE(s))); + SCSIBus *bus = SCSI_BUS(qdev_get_parent_bus(DEVICE(s))); int8_t sbyte; while ((sbyte = qemu_get_sbyte(f)) > 0) { diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 843dde8851..eb558c145a 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -177,7 +177,7 @@ static inline void scsi_bus_init(SCSIBus *bus, size_t bus_size, static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d) { - return DO_UPCAST(SCSIBus, qbus, qdev_get_parent_bus(DEVICE(d))); + return SCSI_BUS(qdev_get_parent_bus(DEVICE(d))); } SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk, From patchwork Mon Feb 13 18:43:36 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: 1741849 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Y8Ti4Nsi; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtc126lrz23h0 for ; Tue, 14 Feb 2023 05:46:57 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdot-0002BT-BA; Mon, 13 Feb 2023 13:44:55 -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 1pRdon-0001uI-T2 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:50 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdom-00005y-Ap for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:49 -0500 Received: by mail-wr1-x42d.google.com with SMTP id o15so9957003wrc.9 for ; Mon, 13 Feb 2023 10:44:47 -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=tUBrGbpKKV7VXqQbLaZwgKrboQidPjnhwuwd1SCLF+8=; b=Y8Ti4NsiohEQUAwGn4nIW2vrzmlzBdyveHD0R2pymv7YcsEdcJH37KbcbKCHjxyi1c 5eCCOHQ8SJKZs9KJT0qWswgVIHttpgaMVc47pTxTa9+BnYx8ZXLi8UZcOnCGGtOZClsr sbvA+kP/7kN/CqLOCvsulEYrCEGktlO19cwXU2vK+z5F4zlsQletWkRSb5S1IDS5zHni MX7DpJcpW9cNlKZRIjiZ1lQigU8fXOkIitpLssFx+ZaQ8L/2bXJmG2oQU6jqUPDEJTAk 6IY6EUcK66jaoSkkjh5qZLhoEYVLPOqRdimD+To3BbYqHIDJp6p15SjS2H25lz76PD0y p8pA== 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=tUBrGbpKKV7VXqQbLaZwgKrboQidPjnhwuwd1SCLF+8=; b=xjMw/4FiUS/HU9wjotVjM79QtEkXB7B5eMw8y1NqfR2OR+o3CnU9GACFZWpHGaqd0G TQy2HspMhEDsShVBgiUaxnoVI5PR11CEBApmTPsY595hOxtskWyebPS9u04EqNWICp2/ 7MJz/qe9ZF0JuxnyJ5eP8eRryuquteLHrrlh4oh2EphUVUnPh4jT1LJW289HONBJGr4Q 5Jqjk2JgreHViG7Fg+ZM6ATZRm1z2qIHs8t0elpcx02lAot7JoeT3BDR7A0JVrkahiXG n40sPP4OX02apt+RipK/ZRvrTZOj/+EupiwjuxVD6n/+Gog2CjUqlnsuZrfiE9IjaoWL Tp4g== X-Gm-Message-State: AO0yUKVlHYQSg68XEimmgtaD7BxREnZjRvaF3vHgTRwj/Lzg73Sth6qw kC1FWuND9WT8TlvKUtgdQnb1YWqOlBypMywa X-Google-Smtp-Source: AK7set+kskLHDiP1Hyxq0fWbGVLWSLlCDYkSDl9OY7AR7MAuc1Luisy8En31AtlcFlkA3wdTZKt1+Q== X-Received: by 2002:a5d:4bc3:0:b0:2c5:5184:abc with SMTP id l3-20020a5d4bc3000000b002c551840abcmr5918859wrt.59.1676313886940; Mon, 13 Feb 2023 10:44:46 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id u10-20020a5d514a000000b002c3e28d0343sm10858412wrt.85.2023.02.13.10.44.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:46 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eric Farman , Christian Borntraeger , Halil Pasic , David Hildenbrand , Ilya Leoshkevich , Paolo Bonzini , Fam Zheng , qemu-s390x@nongnu.org Subject: [PATCH v3 12/14] hw/scsi/scsi-bus: Inline two uses of scsi_bus_from_device() Date: Mon, 13 Feb 2023 19:43:36 +0100 Message-Id: <20230213184338.46712-13-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Acked-by: Eric Farman --- hw/s390x/ipl.c | 7 ++----- hw/scsi/scsi-bus.c | 2 +- include/hw/scsi/scsi.h | 5 ----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 8612684d48..4f7f4e60d6 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -366,11 +366,8 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) ccw_dev = CCW_DEVICE(vfio_ccw_dev); tmp_dt = CCW_DEVTYPE_VFIO; } else { - SCSIDevice *sd = (SCSIDevice *) - object_dynamic_cast(OBJECT(dev_st), - TYPE_SCSI_DEVICE); - if (sd) { - SCSIBus *sbus = scsi_bus_from_device(sd); + if (object_dynamic_cast(OBJECT(dev_st), TYPE_SCSI_DEVICE)) { + SCSIBus *sbus = SCSI_BUS(qdev_get_parent_bus(dev_st)); VirtIODevice *vdev = (VirtIODevice *) object_dynamic_cast(OBJECT(sbus->qbus.parent), TYPE_VIRTIO_DEVICE); diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index c4525515ab..ee72b86b13 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -679,7 +679,7 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d, uint32_t tag, uint32_t lun, void *hba_private) { SCSIRequest *req; - SCSIBus *bus = scsi_bus_from_device(d); + SCSIBus *bus = SCSI_BUS(qdev_get_parent_bus(DEVICE(d))); BusState *qbus = BUS(bus); const int memset_off = offsetof(SCSIRequest, sense) + sizeof(req->sense); diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index eb558c145a..e3263dec0d 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -175,11 +175,6 @@ static inline void scsi_bus_init(SCSIBus *bus, size_t bus_size, scsi_bus_init_named(bus, bus_size, host, info, NULL); } -static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d) -{ - return SCSI_BUS(qdev_get_parent_bus(DEVICE(d))); -} - SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk, int unit, bool removable, int bootindex, bool share_rw, From patchwork Mon Feb 13 18:43:37 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: 1741842 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Ao75rupK; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtYz1v4xz23h0 for ; Tue, 14 Feb 2023 05:45:11 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdow-0002LY-RG; Mon, 13 Feb 2023 13:44:58 -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 1pRdot-0002DO-3x for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:55 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdor-00008M-I6 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:44:54 -0500 Received: by mail-wm1-x32a.google.com with SMTP id m16-20020a05600c3b1000b003dc4050c94aso9767055wms.4 for ; Mon, 13 Feb 2023 10:44:53 -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=yI1y6XZsaobmGFW1lR+eKSaDWZj5kiLu704LCMt3Xc4=; b=Ao75rupKEQ4AuOjLz8TKCzWe+lCHyAzKJ9Zo+E2WZlexKnJPUXtKTuKxpEhjQtEo1X 3mQ7Xk4mKQC0OJpigD9sNKdmrn/w8rNPXbAvLyy1G2kyWpYk9TMTo37Nec2CjxbxcEeE Q4fvP7+JphzgaCCFotnT4Y0yN0sU9gUQPIaqwu/PUbvKvPq4cvMVc+u+pM7TR1211pQp Wuges9BAp8uoVN9KBoQgbO7H6x3MN4Nk7wLTBSTyoxXWXDdS43zAH+sPh4lsBwr+W1dn /FNqiW7iuFsfZLALh9+KM1XJ7N0U/Lc3PBBnR3XUdLULeWa8wShtwRjBfXfkjX9py9fH K1rw== 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=yI1y6XZsaobmGFW1lR+eKSaDWZj5kiLu704LCMt3Xc4=; b=I6x4uTylShE0zgbpMna18iyW3exjKJT++jfqNkLGMcGGtrMbDZlIe9c89MmvqAoPNl i6EBIXgAanOFyamifeU9bKKi5BeK5uJsxrEof9DT9UUFhq7TNaW3scNbUmhQyAwLpOJP gXj1JKDHyT0JW6Qrt5sAvxP8E7G8hnpLm0itlBPsJlz/yY9UZEmCtUENK3eHBpxsWQb6 jO5VOUvbDb9wBqLP4P5VuBd8aS1rz3Rs84/Ku3CKtm+YRXcBBvryCAdPTPlD+1rms2z3 CacIXfxCGKjOXyr0Io4jFPryq9cfT2AEXBWGUQ+bgm3SJvcQK93QRDtS+j0QsjlTzhxl 0Npw== X-Gm-Message-State: AO0yUKWugJTHm0Xv63yCoNCCaDLZwh7sDC/QBop2pVtc9rZWsjDsNkqa ZO7xygJn5qrZYys2PM46jGZ/cNJw8BSBuItE X-Google-Smtp-Source: AK7set9QvfSbow01BVrgJj2aIxonOsZTWw57MP899TCBnpozRmCwdtwh4NSxr4J3XOtYa3x83YrFEw== X-Received: by 2002:a05:600c:3510:b0:3dc:42d2:aeee with SMTP id h16-20020a05600c351000b003dc42d2aeeemr20043513wmq.25.1676313892145; Mon, 13 Feb 2023 10:44:52 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id y6-20020a05600c364600b003df7b40f99fsm17139595wmq.11.2023.02.13.10.44.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:51 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann Subject: [PATCH v3 13/14] hw/usb/dev-hub: Use QOM USB_HUB() macro instead of casting Date: Mon, 13 Feb 2023 19:43:37 +0100 Message-Id: <20230213184338.46712-14-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the safer USB_HUB() QOM type-checking macro instead of casts. Signed-off-by: Philippe Mathieu-Daudé --- hw/usb/dev-hub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c index a6b50dbc8d..4734700e3e 100644 --- a/hw/usb/dev-hub.c +++ b/hw/usb/dev-hub.c @@ -350,7 +350,7 @@ static const char *feature_name(int feature) static void usb_hub_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { - USBHubState *s = (USBHubState *)dev; + USBHubState *s = USB_HUB(dev); int ret; trace_usb_hub_control(s->dev.addr, request, value, index, length); @@ -523,7 +523,7 @@ static void usb_hub_handle_control(USBDevice *dev, USBPacket *p, static void usb_hub_handle_data(USBDevice *dev, USBPacket *p) { - USBHubState *s = (USBHubState *)dev; + USBHubState *s = USB_HUB(dev); switch(p->pid) { case USB_TOKEN_IN: @@ -568,7 +568,7 @@ static void usb_hub_handle_data(USBDevice *dev, USBPacket *p) static void usb_hub_unrealize(USBDevice *dev) { - USBHubState *s = (USBHubState *)dev; + USBHubState *s = USB_HUB(dev); int i; for (i = 0; i < s->num_ports; i++) { From patchwork Mon Feb 13 18:43:38 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: 1741852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=H8Jzcy26; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFtcV080rz23yT for ; Tue, 14 Feb 2023 05:47:22 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRdp0-0002gm-G0; Mon, 13 Feb 2023 13:45:02 -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 1pRdoy-0002al-Qq for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:45:00 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRdow-0000Am-Ty for qemu-devel@nongnu.org; Mon, 13 Feb 2023 13:45:00 -0500 Received: by mail-wr1-x42a.google.com with SMTP id co8so9513364wrb.1 for ; Mon, 13 Feb 2023 10:44:58 -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=BCofvFRozrpBRIR6kzkyhIQPbWbeiNV/KXSS7SVLec8=; b=H8Jzcy26pGsu1nLmy1m7SaZmtNpDEoeb1Q+k9YDdSc8habOWsCapzngown3yprPtis Sf0OXtLkXRnZYh+de5+UzPr2MzXDtdzc63AhZFZ5xu7ni0QFww/NN3xBD/E3Xx0L03pA nw4gq0pmkg/66RsJ6HxpzzCjSW3szBEGPCk8D4Ks4B4mugByqXs0OGb5wRe6Yh/ndADb lV7bCubTP8EvZ7+7Vxo5dOOPQcFh2gZFQRf0YGcghLJDVv534BUemr4s/75JPOAsiZwA xUYetQp8R5SDt+Q1yzbhE5YGTqhS52qPLyvjnuROukRWMyMP7KNh05o9cGN9DUmNhtim hlOw== 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=BCofvFRozrpBRIR6kzkyhIQPbWbeiNV/KXSS7SVLec8=; b=EPKPZODjwgeBMbMftHn/Z8ONviFuNh+u3Vs4aMc7XXHiRd3WmAuSL+r6LHhPyu116R eGrQ5QYJ7KVdF0Dw7ueybLZnh8VcvEEzj9YoSyCFxYsIyURVh6cKoS4Jeqw7Sqjs3rh0 KGQ8pZ3USuyjV4xCvm3tV1bJwPv2b/fq7mbusYFW+7QThOSq9w/5dR/O+7mtKXwLjEeJ gMXTAXPybrfQ1WudPcWBVrcUWyW9NBXVGEyXRULfuixEpeM63zbXT3HgDxrQ1Zu0xYF4 ms6KZxid76rn8/mZZRnnF742eT2BU7x4iYndP5LPb/A805+3hUtt5GRPpfEmdOaIT8LF u0+A== X-Gm-Message-State: AO0yUKW0flCkAJVBbfJdlgP9N59D4LjgeT9SgKvH0QLv9y9lTj78JgK7 mZmDOOctLfkaAx+01kHmC9jhAGUw6N+FkXJW X-Google-Smtp-Source: AK7set9iO04TRNbFszaXuMnkby4d2ldMBGfb02J/veA7yT949CLIwZdMnESjOK0n2axtwPhVQLzkFw== X-Received: by 2002:a05:6000:1816:b0:2c5:5a63:ae07 with SMTP id m22-20020a056000181600b002c55a63ae07mr2561832wrh.23.1676313897398; Mon, 13 Feb 2023 10:44:57 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id u14-20020adff88e000000b002c56046a3b5sm1165934wrp.53.2023.02.13.10.44.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 10:44:57 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Hu Tao , Gonglei Arei , Richard Henderson , Li Qiang , Thomas Huth , Cao jin , xiaoqiang zhao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann Subject: [PATCH v3 14/14] hw/usb: Replace DO_UPCAST(USBBus) by USB_BUS() Date: Mon, 13 Feb 2023 19:43:38 +0100 Message-Id: <20230213184338.46712-15-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213184338.46712-1-philmd@linaro.org> References: <20230213184338.46712-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the USB_BUS() QOM type-checking macro to avoid DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé --- include/hw/usb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/usb.h b/include/hw/usb.h index b2111bb1c7..f743a5e945 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -520,7 +520,7 @@ void usb_check_attach(USBDevice *dev, Error **errp); static inline USBBus *usb_bus_from_device(USBDevice *d) { - return DO_UPCAST(USBBus, qbus, qdev_get_parent_bus(DEVICE(d))); + return USB_BUS(qdev_get_parent_bus(DEVICE(d))); } extern const VMStateDescription vmstate_usb_device;