From nobody Fri May 17 09:18:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1676285829; cv=none; d=zohomail.com; s=zohoarc; b=n2pqpTrWiifbr+JLt3FJJtbEuSqu2jlvR2T+DKTVJBQHy0aUzHbB9x7T3+CZhxRrcAoKHJvZmFVA3frkxcRUQsN0SESWM7Q8A3bFZLN57t7dsBFcHWmsUL2W07taxiUehVsH4JN9nYMShGoo30dLP4ydK8smjgEKsSKHJuse/Zs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676285829; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FUJ+c15GRYrgsdfojyKynY0o/0XkUeheI9scGjw2Thg=; b=KzgN15PV6yvE1a45w6BBbBFs1V1/dw4ahK4j22dxKw5+PKtUB1mx2nYNSwRp9cSsSAWEhYe+SoW+pLyhAE5vXJ/yud3T+hfU0uPCpmB/uddfsPK46Qhu4bZIEFT/87DxiXSMkvdHiJpyyB0AoVN+jUnQRYgwyTvrcuj6J+bblBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676285829123884.1730932114331; Mon, 13 Feb 2023 02:57:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRWVi-0006ie-1H; Mon, 13 Feb 2023 05:56:39 -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 1pRWVe-0006eN-GJ for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:56:34 -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 1pRWVa-0003dG-PE for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:56:34 -0500 Received: by mail-wm1-x32b.google.com with SMTP id m20-20020a05600c3b1400b003e1e754657aso2510094wms.2 for ; Mon, 13 Feb 2023 02:56:18 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id i16-20020a05600c4b1000b003dc4fd6e624sm13068169wmp.19.2023.02.13.02.56.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:56:16 -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=FUJ+c15GRYrgsdfojyKynY0o/0XkUeheI9scGjw2Thg=; b=jkrVZq1m+qlc3A3KsZyDmeVxEWW2VyLqp1uspE0MPIj/QfqdfY5FwYxVsbKTuhUNAV Kume/BDzH6tg0HPCN1uEpnXBjVinYRGbUm5ygy+YiiHHMwdTR5BosdyXM3dEv6Jycvbx y1AA96LRiKNXhrWKdPMFM9lBUstEHNH/71HjFK3Tkmf0ogrXfMcgCPnL4FYNLX6tlA+Y pa9Nd1qsnCRVZXv/S9j01I/1pVnsCO84UzFd2eL53Dm6nuWFTv8hCF6Y8YeqigwDdKjc nJ1wh1ttfhYo3mdeIVJxSiyWXgIC5UvZ5UlSkqrtpZzU9s8S9EeR+qXIfFL5S4GVaude rL6w== 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=FUJ+c15GRYrgsdfojyKynY0o/0XkUeheI9scGjw2Thg=; b=JN3BQpt+F8/yMVmh/9lSJpuir2TmiQ8qHqSoRs02IGaKg4/MS+3VKW7+gfRq0e/t6a 0yAEH93NgW+ZykXV4mqQ3tQ2aOauUnjjSUhIMKcAQ4TasIuc9U5tqVN5VLfanyLpWD07 +4PYXaa9akWd+iqZe3u7586fjq5VDjszBJq282nYMRNWC6HTt2pG9kZBEBnZWw4I/Ja/ myEQmaAN2CsiUWIYqWYNkcrA7VwcvdQdSrB/5xNjDCr0sYs+tdZie1oohgR/SaAO3oN5 Kwc2DpdnOTXEINTgWzHYFbm1pWQrO2UTcYQNy8LvEiBoYNBVgT77IJ99muCZQIdEiQZK 99RA== X-Gm-Message-State: AO0yUKWiiVKkZsKsOJl+nec5GYiHSQ6zp6CREDz/nKqolAInAfgCCUlr V5BnUy2V8siseyEse4/MKEsexurXuvxXn44c X-Google-Smtp-Source: AK7set9MZm2fJvGWR3QMZ3tX3GtojfIvY51q9nwH5wMw5ZZIZCKwVWxJf5879T92IVUD8JRkvUjztg== X-Received: by 2002:a05:600c:4a9c:b0:3dd:1b6f:4f30 with SMTP id b28-20020a05600c4a9c00b003dd1b6f4f30mr23290416wmp.3.1676285777223; Mon, 13 Feb 2023 02:56:17 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: Peter Maydell , Gerd Hoffmann , "Edgar E . Iglesias" , Igor Mammedov , Samuel Thibault , Paolo Bonzini , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Mark Cave-Ayland , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 1/3] hw/qdev: Introduce QDEV_DECLARE_DEV_BUS_TYPES() macro Date: Mon, 13 Feb 2023 11:56:07 +0100 Message-Id: <20230213105609.6173-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213105609.6173-1-philmd@linaro.org> References: <20230213105609.6173-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1676285831178100005 Similarly to QOM OBJECT_DECLARE_TYPE() equivalent, introduce a QDev macro to declare common helpers for device sitting on a bus. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/qdev-core.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 93718be156..dc9909a2e7 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -717,6 +717,34 @@ void qdev_pass_gpios(DeviceState *dev, DeviceState *co= ntainer, =20 BusState *qdev_get_parent_bus(const DeviceState *dev); =20 +/** + * QDEV_DECLARE_DEV_BUS_TYPES: + * @DeviceInstanceType: device instance struct name + * @DeviceClassType: device class struct name + * @DEVICE_OBJ_NAME: the device name in uppercase with underscore separato= rs + * @BusInstanceType: bus instance struct name + * @DeviceClassType: bus class struct name + * @BUS_OBJ_NAME: the bus name in uppercase with underscore separators + * + * This macro is typically used in a header file, and will: + * + * - create the typedefs for the object and class structs + * - register the type for use with g_autoptr + * - provide four standard type cast functions + * + * The device state struct, device class struct, bus state struct need + * to be declared manually. + */ +#define QDEV_DECLARE_DEV_BUS_TYPES(DeviceInstanceType, DeviceClassType, \ + DEVICE_OBJ_NAME, \ + BusInstanceType, BUS_OBJ_NAME) \ + OBJECT_DECLARE_TYPE(DeviceInstanceType, DeviceClassType, DEVICE_OBJ_NA= ME) \ + OBJECT_DECLARE_SIMPLE_TYPE(BusInstanceType, BUS_OBJ_NAME) \ + \ + static inline G_GNUC_UNUSED BusInstanceType * \ + DEVICE_OBJ_NAME##_GET_BUS(const DeviceInstanceType *dev) \ + { return BUS_OBJ_NAME(qdev_get_parent_bus(DEVICE(dev))); } + /*** BUS API. ***/ =20 DeviceState *qdev_find_recursive(BusState *bus, const char *id); --=20 2.38.1 From nobody Fri May 17 09:18:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1676285827; cv=none; d=zohomail.com; s=zohoarc; b=GfZ9eGUA4OqF7jdeqNZPGwclPSUaxr4LA4uDlZjq82ErxFFvzKYaCmdHnoKuot2ZJp6b/49/NkmIoU6EqT/oFBD0Mpw01xTMcYNJMp8YUha+m5eNOoYdRvJPn20jrTXOM8TyExiHbVwCvgGFRdCrZwjhDyA+pnA0YkbD8cGRuf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676285827; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uAtLXsDM0eQOunnCiOEWBVbTBBIpljWj1BX7nIfwmRU=; b=C8Sg6cdlV8fs7UnHWntNnVknDD3mM2whGSY6WLblrg1DFMsm6DX4CKQoaaBw4A7o6p0Og4NDc34yOCmx3H/owwNu/RrF1kMxQqRbCftmh3kHAFkd7raVvHEZzg/0x61HHksqW76jkSXBDir4cU9FWZrWcDLsQ+N8g9Iy347UkZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676285827016249.6710612684618; Mon, 13 Feb 2023 02:57:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRWVh-0006iB-Ts; Mon, 13 Feb 2023 05:56:37 -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 1pRWVd-0006cL-R1 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:56:33 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRWVa-0003f6-T4 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:56:33 -0500 Received: by mail-wm1-x329.google.com with SMTP id f23-20020a05600c491700b003dff4480a17so8123646wmp.1 for ; Mon, 13 Feb 2023 02:56:23 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id g10-20020a05600c310a00b003e1e8d794e1sm4701271wmo.13.2023.02.13.02.56.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:56:22 -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=uAtLXsDM0eQOunnCiOEWBVbTBBIpljWj1BX7nIfwmRU=; b=SS/VznyyIjHBEiUz97tGxnbtKdCEXne3mDgS9XIVuN7pzGlhBKTatAsHSzXg/KlhMq CuzjzUyrDmrrz3BGoBTbKb28+wya5v5VWIQza8x3erB5fS8oBK9OwpX4hEwYAX2NDF0X ojCqve8ppauv7ldZikt1psDpu4A/rj5qyDplgDr+T95Ge08/rcbjmWptVbmfiEThmbeO MmWLoW0XTtpf0ng/eSY0TqP537qPJA1JeSH1EO0rYgGntEZkZPRnxWaN0UKnhe+edURp UyOw2/890Jp46cE2TDpWKpPsSn16Gx+zbEAnilYVefAdZEL0AVD6mIG8aET+HNB8HlFP Gc3w== 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=uAtLXsDM0eQOunnCiOEWBVbTBBIpljWj1BX7nIfwmRU=; b=xhe/UlovH7xxgUQ9JMXSGjHtDmcr+thQpWWONeTZC/XbwsXZeqn9Flw8I9xKh/zDJh kN47AmHXrH1SzFVh+Wao7c/iG9PFRP1WW11lTB+TUPU+qykqVfegMSQhN9y2GSkb6/Kg tPiMRlutC4b29ySEGjuXnzTvYA2lGVLwEc/6VW12IUo077+8cjjf+LGREeTx9XCr6a/6 60XrtP/nWl6Gu0l3QkKNqJHHqDuB53axoKV1Z28UI+EyFAeNAaBxfvUrMpopwOt8GawK vRAOtrWFXC7bqnnm6uoiSK9PuqIvaxHGcWMOb3z3mE84x7EH56Pp24DfyhBD+F6iDksc 2QoQ== X-Gm-Message-State: AO0yUKUiOqJHUuJwpSqx+Eb/zBhX3afe9Vkq0fVq5+CLutxVYPNsj1Gk 2WOLiOXhk+jhY7wdaldBX3YTP9sogzC4RqCT X-Google-Smtp-Source: AK7set9R4JyccDdWz+k0xA6GuvW4It5nJcJDr+pMPLIxgaG/E0e/iVb8G9PupIK/SyMQfEr20e1mTg== X-Received: by 2002:a05:600c:2ac8:b0:3c6:e61e:ae71 with SMTP id t8-20020a05600c2ac800b003c6e61eae71mr20812793wme.1.1676285782520; Mon, 13 Feb 2023 02:56:22 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: Peter Maydell , Gerd Hoffmann , "Edgar E . Iglesias" , Igor Mammedov , Samuel Thibault , Paolo Bonzini , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Mark Cave-Ayland , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 2/3] hw/usb: Declare QOM macros using QDEV_DECLARE_DEV_BUS_TYPES() Date: Mon, 13 Feb 2023 11:56:08 +0100 Message-Id: <20230213105609.6173-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213105609.6173-1-philmd@linaro.org> References: <20230213105609.6173-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1676285829160100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/usb.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hw/usb.h b/include/hw/usb.h index b2111bb1c7..09f345f5c5 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -266,8 +266,11 @@ struct USBDevice { const USBDescIface *ifaces[USB_MAX_INTERFACES]; }; =20 +#define TYPE_USB_BUS "usb-bus" #define TYPE_USB_DEVICE "usb-device" -OBJECT_DECLARE_TYPE(USBDevice, USBDeviceClass, USB_DEVICE) + +QDEV_DECLARE_DEV_BUS_TYPES(USBDevice, USBDeviceClass, USB_DEVICE, + USBBus, USB_BUS) =20 typedef void (*USBDeviceRealize)(USBDevice *dev, Error **errp); typedef void (*USBDeviceUnrealize)(USBDevice *dev); @@ -473,9 +476,6 @@ void hmp_info_usbhost(Monitor *mon, const QDict *qdict); =20 /* usb-bus.c */ =20 -#define TYPE_USB_BUS "usb-bus" -OBJECT_DECLARE_SIMPLE_TYPE(USBBus, USB_BUS) - struct USBBus { BusState qbus; USBBusOps *ops; --=20 2.38.1 From nobody Fri May 17 09:18:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1676285816; cv=none; d=zohomail.com; s=zohoarc; b=GpRzUf4og6+YG5KwTYPBo/tcW9nyq59ajG8fx4avQnJ5YfR72eFXH5lg9JJGlFYofVxkl+4FM09HUv22LxCpr4+EVkQmJ6KP7n4o0pCnHbLfhv8qiWEF43bzVq0gTZBNyJBFLHIVVkoYNGkQsTUSXDcAA7n3ROm0JNO1RQQaU/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676285816; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aF98Ma9RkPF/Vf1N+Mxitvw+ZUTQ0aa8j86PfGUlqco=; b=R/Gy/w8EsrWKlNub7eBjo4+Np21Rp1f1ucX2947JscQ1YaiIvjxkptRtmKirvfDQ90UfcoqNuvfqckpvZpU/cUSlV9zcXTmGa+yWPHrZP+ew1eWsEqc78PJX3h5Tkh9hV+eK6aQNWMq/1XPCeMNjZW5lV+WLK1jZqh9I2s83obA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167628581658961.48940598137699; Mon, 13 Feb 2023 02:56:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRWVh-0006hz-SU; Mon, 13 Feb 2023 05:56:37 -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 1pRWVe-0006eR-GQ for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:56:34 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRWVa-0003fL-T1 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:56:33 -0500 Received: by mail-wr1-x433.google.com with SMTP id bk16so11693143wrb.11 for ; Mon, 13 Feb 2023 02:56:29 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id g9-20020a5d5409000000b002c558228b6dsm2866827wrv.12.2023.02.13.02.56.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:56:27 -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=aF98Ma9RkPF/Vf1N+Mxitvw+ZUTQ0aa8j86PfGUlqco=; b=tyI42UepU6YR1dfVpVjzyz+FOViUjOCXASljJk/gExyr30grL6ajWokHe8e7rqKEFT 0BdGH3zFcRA9oRjtzzyBFgJdZp5/r9X1brHqSZm0PSfXijIeFj3fl9J5Lx3uNxfJXnVi DwrlxJysuB2hoUQWezOwBFV6EXZDhRFCtESDf8jk9zgsFPiurCUD2S15suI7CHjyYJ3X 7HoV4wttVed0Fxl5+2dCtpBu7ZIP3ks+dPT3ZMDxk5R/kwv9HWjNoO8Mzja1XE1TMmK+ A1sBEuNhHh//7VRlGKrJWILHRmXcDrbcLUW0kzF0JF29XT6m8YmqPmc3Gq7TaUgpylzd rhyQ== 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=aF98Ma9RkPF/Vf1N+Mxitvw+ZUTQ0aa8j86PfGUlqco=; b=tzfLJ51CAdlmHqAqghsRBkdt3RhaLo1vkkQSlUD3Hj1ui8KQnf7mjsYVm6Nj+q4g8n 71ih3khnfopiVh00/CdDLNXXOTsz7eZMkaX3iw8FmTnxWmOQQwT7CRdJAsxGF61xT6/f 26xWKnQKuEOl08neWP8YzXovhhdpUK0wmhFB0KLYLXhO54Dys1WrC40t1SGl14bGOemG 8VSZDuxENI4+q0kQ2pe+GbTEGXPIJi8SCvuvYgUmRq5gx2zbx5nAjMqG62yKrPWDVU4J 8VjQZ5N8qoXwsN0xMjCLkycq3yFy6EltbaxPFAK8jHN4VQVAoIAfAPLFIQ8Hfn8SCmLG QiSA== X-Gm-Message-State: AO0yUKWrkh0a2vnS+rYAAKoMt+AKSFO1HrC69BoliUb3oKHf4DDP2ht+ QRCQvu81KyoE4xUUuR+l9PwIw/aYOZPOZY4b X-Google-Smtp-Source: AK7set+vzrWSSQpAMDpuFOIvEAWU6HForGVCe5lFTCzbG5yArUOKdqEWHH9hVjBmWGWdUr/8/hby3Q== X-Received: by 2002:a05:6000:1249:b0:2c5:5d1d:b244 with SMTP id j9-20020a056000124900b002c55d1db244mr1110571wrx.29.1676285788012; Mon, 13 Feb 2023 02:56:28 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: Peter Maydell , Gerd Hoffmann , "Edgar E . Iglesias" , Igor Mammedov , Samuel Thibault , Paolo Bonzini , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Mark Cave-Ayland , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 3/3] hw/usb: Use USB_DEVICE_GET_BUS() macro Date: Mon, 13 Feb 2023 11:56:09 +0100 Message-Id: <20230213105609.6173-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213105609.6173-1-philmd@linaro.org> References: <20230213105609.6173-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1676285817158100002 Automatic conversion running: $ sed -i -e s/usb_bus_from_device/USB_DEVICE_GET_BUS/g \ $(git grep -wl usb_bus_from_device) then removing the usb_bus_from_device() function declaration. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/usb/bus.c | 10 +++++----- hw/usb/core.c | 6 +++--- hw/usb/dev-hub.c | 4 ++-- hw/usb/dev-serial.c | 10 +++++----- hw/usb/hcd-xhci.c | 2 +- include/hw/usb.h | 5 ----- 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index d7c3c71435..fa154e1e79 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -427,7 +427,7 @@ void usb_unregister_port(USBBus *bus, USBPort *port) =20 void usb_claim_port(USBDevice *dev, Error **errp) { - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); USBPort *port; USBDevice *hub; =20 @@ -473,7 +473,7 @@ void usb_claim_port(USBDevice *dev, Error **errp) =20 void usb_release_port(USBDevice *dev) { - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); USBPort *port =3D dev->port; =20 assert(port !=3D NULL); @@ -517,7 +517,7 @@ static void usb_mask_to_str(char *dest, size_t size, =20 void usb_check_attach(USBDevice *dev, Error **errp) { - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); USBPort *port =3D dev->port; char devspeed[32], portspeed[32]; =20 @@ -555,7 +555,7 @@ void usb_device_attach(USBDevice *dev, Error **errp) =20 int usb_device_detach(USBDevice *dev) { - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); USBPort *port =3D dev->port; =20 assert(port !=3D NULL); @@ -583,7 +583,7 @@ static const char *usb_speed(unsigned int speed) static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent) { USBDevice *dev =3D USB_DEVICE(qdev); - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); =20 monitor_printf(mon, "%*saddr %d.%d, port %s, speed %s, name %s%s\n", indent, "", bus->busnr, dev->addr, diff --git a/hw/usb/core.c b/hw/usb/core.c index 975f76250a..849e95b9e2 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -95,7 +95,7 @@ void usb_device_reset(USBDevice *dev) void usb_wakeup(USBEndpoint *ep, unsigned int stream) { USBDevice *dev =3D ep->dev; - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); =20 if (!phase_check(PHASE_MACHINE_READY)) { /* @@ -556,7 +556,7 @@ void usb_packet_check_state(USBPacket *p, USBPacketStat= e expected) return; } dev =3D p->ep->dev; - bus =3D usb_bus_from_device(dev); + bus =3D USB_DEVICE_GET_BUS(dev); trace_usb_packet_state_fault(bus->busnr, dev->port->path, p->ep->nr, p, usb_packet_state_name(p->state), usb_packet_state_name(expected)); @@ -567,7 +567,7 @@ void usb_packet_set_state(USBPacket *p, USBPacketState = state) { if (p->ep) { USBDevice *dev =3D p->ep->dev; - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); trace_usb_packet_state_change(bus->busnr, dev->port->path, p->ep->= nr, p, usb_packet_state_name(p->state), usb_packet_state_name(state)); diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c index a6b50dbc8d..fa094ec9bd 100644 --- a/hw/usb/dev-hub.c +++ b/hw/usb/dev-hub.c @@ -572,7 +572,7 @@ static void usb_hub_unrealize(USBDevice *dev) int i; =20 for (i =3D 0; i < s->num_ports; i++) { - usb_unregister_port(usb_bus_from_device(dev), + usb_unregister_port(USB_DEVICE_GET_BUS(dev), &s->ports[i].port); } =20 @@ -611,7 +611,7 @@ static void usb_hub_realize(USBDevice *dev, Error **err= p) s->intr =3D usb_ep_get(dev, USB_TOKEN_IN, 1); for (i =3D 0; i < s->num_ports; i++) { port =3D &s->ports[i]; - usb_register_port(usb_bus_from_device(dev), + usb_register_port(USB_DEVICE_GET_BUS(dev), &port->port, s, i, &usb_hub_port_ops, USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); usb_port_location(&port->port, dev->port, i+1); diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index 63047d79cf..4cfe27818b 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -190,7 +190,7 @@ static void usb_serial_set_flow_control(USBSerialState = *s, uint8_t flow_control) { USBDevice *dev =3D USB_DEVICE(s); - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); =20 /* TODO: ioctl */ s->flow_control =3D flow_control; @@ -200,7 +200,7 @@ static void usb_serial_set_flow_control(USBSerialState = *s, static void usb_serial_set_xonxoff(USBSerialState *s, int xonxoff) { USBDevice *dev =3D USB_DEVICE(s); - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); =20 s->xon =3D xonxoff & 0xff; s->xoff =3D (xonxoff >> 8) & 0xff; @@ -221,7 +221,7 @@ static void usb_serial_reset(USBSerialState *s) static void usb_serial_handle_reset(USBDevice *dev) { USBSerialState *s =3D USB_SERIAL(dev); - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); =20 trace_usb_serial_reset(bus->busnr, dev->addr); =20 @@ -261,7 +261,7 @@ static void usb_serial_handle_control(USBDevice *dev, U= SBPacket *p, int length, uint8_t *data) { USBSerialState *s =3D USB_SERIAL(dev); - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); int ret; =20 trace_usb_serial_handle_control(bus->busnr, dev->addr, request, value); @@ -479,7 +479,7 @@ static void usb_serial_token_in(USBSerialState *s, USBP= acket *p) static void usb_serial_handle_data(USBDevice *dev, USBPacket *p) { USBSerialState *s =3D USB_SERIAL(dev); - USBBus *bus =3D usb_bus_from_device(dev); + USBBus *bus =3D USB_DEVICE_GET_BUS(dev); uint8_t devep =3D p->ep->nr; struct iovec *iov; int i; diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index b89b618ec2..7d2ff9d46a 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3268,7 +3268,7 @@ static void xhci_complete(USBPort *port, USBPacket *p= acket) =20 static void xhci_child_detach(USBPort *uport, USBDevice *child) { - USBBus *bus =3D usb_bus_from_device(child); + USBBus *bus =3D USB_DEVICE_GET_BUS(child); XHCIState *xhci =3D container_of(bus, XHCIState, bus); =20 xhci_detach_slot(xhci, child->port); diff --git a/include/hw/usb.h b/include/hw/usb.h index 09f345f5c5..d859cdc11c 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -518,11 +518,6 @@ void usb_device_attach(USBDevice *dev, Error **errp); int usb_device_detach(USBDevice *dev); void usb_check_attach(USBDevice *dev, Error **errp); =20 -static inline USBBus *usb_bus_from_device(USBDevice *d) -{ - return DO_UPCAST(USBBus, qbus, qdev_get_parent_bus(DEVICE(d))); -} - extern const VMStateDescription vmstate_usb_device; =20 #define VMSTATE_USB_DEVICE(_field, _state) { \ --=20 2.38.1