From patchwork Mon Feb 13 10:56:06 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: 653197 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp2340670wrr; Mon, 13 Feb 2023 02:56:55 -0800 (PST) X-Google-Smtp-Source: AK7set8x9KBddO6mEXgdU6s9aOUURcAAFke2CuxQsbtMpQAtSP478pyYcM+wKJfFlYuUkGu3U2WF X-Received: by 2002:a05:622a:a009:b0:3b9:bc8c:c1fb with SMTP id jt9-20020a05622aa00900b003b9bc8cc1fbmr19551630qtb.6.1676285814866; Mon, 13 Feb 2023 02:56:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676285814; cv=none; d=google.com; s=arc-20160816; b=iTL7+Eas7B4m+Qw5bHAsrHkU7FRDVTS/ralr2Z8PhDbJxfCR378Eoksa9XmBjJ6tmK lNDJtiKXJ7BXCpFkuRb58r8vgjK0GXYjmbBRDFSVuI/TE99F/LJVP5XpoJ+LxjkXdCXj Of5pkuyb2MP4yN5xKzPPYvaIk91P5N/bNDdm3VinSyulOLQIw4zxDa2cd7VIUZV2uAm/ huB5XnTd1UyMZwKsJM09Woio8ncvw+B7R+obx3ajRY9JAn6EL2HLdFtid0HMxdCnryys XWbSzbtHP3sBMjsUzc1OVniTTtvVAZFiUGMT0HP+uuAO11xHzHBti7Et1ztvJac89I2c WXaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=raV0KiEdUxZP0ur5EgHPSdYoubiTbJ4MlXHagjDERa8=; b=h3sk5kd/+6SsK5NSnhuOnArVtsCQQHdi1Vyg11vjq2VAW/rSyNesuqJJ0be/VNUkdk R6YBt3Poigel2q2peOcOsHc6wgTapMefXTqEosNR8tf5rUoxRTjvt+E1a11Nl0zbG0Aj NTRIuETnHV7/6Sks0sixTVqwwSCIGqFmXYqL5inXoK9AFLMxoSCOqcn1kCKkTehdNID8 j0PDp61p5MnjESQbduKadbo0vrkpjQ/9Di2f4dJuvb6QOF0HQ6+HD7dzUJr0mEuseo3u lUeLejCnsBH2xMRxDbM7jiCnwf56/iF7LWYsFfukBWSjiHIqLXxw+niZEzhQBGW/6aOa ueRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zLs3DYU6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h9-20020a05620a244900b00705de7c6879si10066737qkn.321.2023.02.13.02.56.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Feb 2023 02:56:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zLs3DYU6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRWVR-0006U8-La; Mon, 13 Feb 2023 05:56:21 -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 1pRWVN-0006Sl-Ts for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:56:17 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRWVK-0003aA-48 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:56:15 -0500 Received: by mail-wm1-x32e.google.com with SMTP id j29-20020a05600c1c1d00b003dc52fed235so8679415wms.1 for ; Mon, 13 Feb 2023 02:56:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=raV0KiEdUxZP0ur5EgHPSdYoubiTbJ4MlXHagjDERa8=; b=zLs3DYU6IGMJMlChZB36agCw+oJVZbMergcdYIhKwqc1CSdH6KXt0pe1EwT1763wgB ox1aZRo8mXo2yKxVQaSK9prWzM7YXvzRH3WAA2yEXjek1Kb+FZPGjhYo7EjDpqijw+3/ VWfSF+oXfSeIWcdjL1Ii2QBpccY/5F1fV/J9ULqR7jevSfUf1MdT7TvfKzgijAYXUBVz ZKVEYdP9KGRHzhvUiJTFEvShss4em6nIVTirX6V7kJC0RFCL6RzCImR2Vu7hkqpbDD7T R9jW8d6R/mwUysrAu/22Si2cBShpGcGI5AAkpqX0mvu70fkHFOpqI4iSonZlEiFzuf7N KqRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=raV0KiEdUxZP0ur5EgHPSdYoubiTbJ4MlXHagjDERa8=; b=kp7eaKR9g9aklbm+xet2PqJmCLJ6/aoRMsBUttBwwrcMJyeNXqVuhNioV1ncQy0Y+C N3rTXgMjOZi+33fl+p0JhRZfMHHkvm0MdmrgizMhFmw+b46wpcQuXLgWPMgUW/H2Fwib CpRUM56PP3Ul5SAqu315qFd1ZtckGwYxuOZsm2IL+2KfB4HR7iU6toQKQwAo+TeTUJ1X 4YSWZRaHXci5PXcPCYfWpZbev1oerWS/DJvMhmKH855gEmufHmTVPiZldHmTH1ZjoJ3W on6IpYyNDL2jL263orjYYTgl80ZUEVQciWiEVbOFDoLvRAxuW30EJJIIPWdTGP5FZu3h zOXg== X-Gm-Message-State: AO0yUKUpoUTQnNcCO86DX1QTYZFsJr3PJLhiv+yH8WlEymd9MmHiqkVs eo2NCP9EDvQEkHhYZahR74c2bqu58rWirbJR X-Received: by 2002:a05:600c:3088:b0:3df:f860:3089 with SMTP id g8-20020a05600c308800b003dff8603089mr20936578wmn.32.1676285771988; Mon, 13 Feb 2023 02:56:11 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id p14-20020a1c544e000000b003db06493ee7sm17516726wmi.47.2023.02.13.02.56.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:56:11 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-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_P=2E_Berrang=C3=A9?= , Mark Cave-Ayland , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 0/3] qdev: Introduce QDEV_DECLARE_DEV_BUS_TYPES() macro Date: Mon, 13 Feb 2023 11:56:06 +0100 Message-Id: <20230213105609.6173-1-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Experiment after discussing with Thomas around qdev_get_parent_bus: https://lore.kernel.org/qemu-devel/ad356f64-dca0-8117-d22a-a530e620ddb0@redhat.com/ When a QDev plug on a QBus, we'll always use qdev_get_parent_bus() at least once with this type. Why not provide a consistent defined macro instead of: 1/ adding an inlined helper such usb_bus_from_device() or scsi_bus_from_device() with different type checks, 2/ open-code calls to qdev_get_parent_bus() with unsafe casts ? This RFC series introduce a QDev-equivalent of QOM DECLARE_TYPES macro, to be used with a (device, bus) tuple, and declaring the equivalent device_GET_BUS() macro. hw/usb/ is converted as an example. Philippe Mathieu-Daudé (3): hw/qdev: Introduce QDEV_DECLARE_DEV_BUS_TYPES() macro hw/usb: Declare QOM macros using QDEV_DECLARE_DEV_BUS_TYPES() hw/usb: Use USB_DEVICE_GET_BUS() macro 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/qdev-core.h | 28 ++++++++++++++++++++++++++++ include/hw/usb.h | 13 ++++--------- 7 files changed, 48 insertions(+), 25 deletions(-)