From nobody Thu Nov 14 17:46:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1708416545; cv=none; d=zohomail.com; s=zohoarc; b=M1Meb1dYOcTtiC24D3EbkCIaRZ7bFK7DqwetKOI+A4oPu/GekbuywUNgoFmzmPfoRYWS9nfywK+2bruSWljU6+dli6j2yhSgiAcns/0kyDvTY9U7mw9rnGGE7NrnL8b7UuvOCIU5bekigRQJBeM6j2sgtDWF4CiAsEuKAiGf7tw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708416545; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0Egdkh5QoX3O/dzVIy8K+U7p2KokwdNAc13mHN8rwZY=; b=CcOG/BVd8X8nFIKz4x5IFQ6adwF9uQe83Nlj3Qc4auODhardj3MGdTKBOijjBFq63SVU/qYXfoIbMI3Hyep+K6vbFHOBWYIyESlGE/BPsNSpbhwjd+NZjSBoOoxrruXkuDJk8mzxEirXaIVMYucLI2rm2vamPJVCYKQCWHrY8mM= 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 1708416545301730.7141572268307; Tue, 20 Feb 2024 00:09:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcLBL-0000fa-JO; Tue, 20 Feb 2024 03:08:51 -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 1rcLBB-0000AQ-UH for qemu-devel@nongnu.org; Tue, 20 Feb 2024 03:08:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcLBA-0000fx-B0 for qemu-devel@nongnu.org; Tue, 20 Feb 2024 03:08:41 -0500 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-94-qXZp9xpcPNGT4petVV1I_A-1; Tue, 20 Feb 2024 03:08:38 -0500 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a2bffe437b5so424042366b.1 for ; Tue, 20 Feb 2024 00:08:37 -0800 (PST) Received: from [192.168.10.118] ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id r18-20020a1709060d5200b00a3d12d84cffsm3686645ejh.167.2024.02.20.00.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 00:08:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708416519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Egdkh5QoX3O/dzVIy8K+U7p2KokwdNAc13mHN8rwZY=; b=Ui7fKpinFA1nnD9pjqKkNE6e0SWCiKo+J+21PhAbcZN5b2Pv6K8K8djpnx08oKGm+m9qOC 1eRsZJK2rlbCUjKVPp6Hx02O2gZv9D3xkJsoZsmJy1S2N8rVK3nPU4sE+yJOtOAZV9qlOp 8qZSh5ZHqlZ6jcuyot17gE6SL4WnDcY= X-MC-Unique: qXZp9xpcPNGT4petVV1I_A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708416516; x=1709021316; 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=0Egdkh5QoX3O/dzVIy8K+U7p2KokwdNAc13mHN8rwZY=; b=lbtTsIE2zoq9juWy7StzJYr1fLqE3xjH3CDDXgh4/6ShIAfPj9yShNiVyqDhns9jfR f7tgMwtshaxtIKXRe637q0IUBynzWC/QbZCk4QTZFzk5SNWEHOzBYR+jJB0xyRLk6KhW fmiBobrGNMwPzAQMyK5cvS0l4kaze6fc5RcBgBBMkqxJQJiOST6Id8t7ANBexnrrU1ZM 00gSlTKz4z8s3CX7k4gJ9feKNApT2ijvcGzKdfN0J7T/5vAWTS5vp+bzktNwzbtLgMhZ fs6W7qv6/5rfdl0NevFKHHtxDA1WNsZKYrtg9MT7HgQMu2s6wEircCY+fjcqw7pWsxfb TK7g== X-Gm-Message-State: AOJu0YxlbjqQTcZ4W+TG/wValLT31GcsGHPOovUWfT0ncDWpkPpZToys WozGxOXKWWIJwpu93Rggr78/eraIc9i5khSu/M6ZcaBqxLGmAGlTmAIVe3nlz9R3RDeE/EKTpMf 2CNHuJQN+T2ItsgyKZqZu8XmtLVCNdW4n6ZcWtrvM3qYtXGrd5+zac9Sb6XZBWvOT1ElsQ7rre/ aOeR/bMAImEZk+5Qb7PGhF0EZjRe16Q4x0mV/F X-Received: by 2002:a17:906:2491:b0:a3e:48f2:19c2 with SMTP id e17-20020a170906249100b00a3e48f219c2mr4533926ejb.76.1708416515814; Tue, 20 Feb 2024 00:08:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHocq4fFF+9LWI+m8y74WnxLbta8MbPcEfG0bfcX2AHxTzQ3nL/uqPgjrH6YkEtbgE4Tfbv3Q== X-Received: by 2002:a17:906:2491:b0:a3e:48f2:19c2 with SMTP id e17-20020a170906249100b00a3e48f219c2mr4533914ejb.76.1708416515414; Tue, 20 Feb 2024 00:08:35 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 16/17] usb: inline device creation functions Date: Tue, 20 Feb 2024 09:05:57 +0100 Message-ID: <20240220080558.365903-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220080558.365903-1-pbonzini@redhat.com> References: <20240220080558.365903-1-pbonzini@redhat.com> MIME-Version: 1.0 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.072, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1708416546477100003 Content-Type: text/plain; charset="utf-8" Allow boards to use the device creation functions even if USB itself is not available; of course the functions will fail inexorably, but this can be okay if the calls are conditional on the existence of some USB host controller device. This is for example the case for hw/mips/loongson3_virt.c. Acked-by: Richard Henderson Signed-off-by: Paolo Bonzini --- include/hw/usb.h | 27 ++++++++++++++++++++++++--- hw/usb/bus.c | 23 ----------------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/include/hw/usb.h b/include/hw/usb.h index 32c23a5ca2a..cfeead28403 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -30,6 +30,7 @@ #include "qemu/iov.h" #include "qemu/queue.h" #include "qom/object.h" +#include "qapi/error.h" =20 /* Constants related to the USB / PCI interaction */ #define USB_SBRN 0x60 /* Serial Bus Release Number Register */ @@ -500,9 +501,6 @@ void usb_bus_release(USBBus *bus); USBBus *usb_bus_find(int busnr); void usb_legacy_register(const char *typename, const char *usbdevice_name, USBDevice *(*usbdevice_init)(void)); -USBDevice *usb_new(const char *name); -bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp); -USBDevice *usb_create_simple(USBBus *bus, const char *name); USBDevice *usbdevice_create(const char *cmdline); void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index, USBPortOps *ops, int speedmask); @@ -582,4 +580,27 @@ void usb_pcap_init(FILE *fp); void usb_pcap_ctrl(USBPacket *p, bool setup); void usb_pcap_data(USBPacket *p, bool setup); =20 +static inline USBDevice *usb_new(const char *name) +{ + return USB_DEVICE(qdev_new(name)); +} + +static inline USBDevice *usb_try_new(const char *name) +{ + return USB_DEVICE(qdev_try_new(name)); +} + +static inline bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Erro= r **errp) +{ + return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp); +} + +static inline USBDevice *usb_create_simple(USBBus *bus, const char *name) +{ + USBDevice *dev =3D usb_new(name); + + usb_realize_and_unref(dev, bus, &error_abort); + return dev; +} + #endif diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 59c39945ddd..76fda41b7ec 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -329,29 +329,6 @@ void usb_legacy_register(const char *typename, const c= har *usbdevice_name, } } =20 -USBDevice *usb_new(const char *name) -{ - return USB_DEVICE(qdev_new(name)); -} - -static USBDevice *usb_try_new(const char *name) -{ - return USB_DEVICE(qdev_try_new(name)); -} - -bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp) -{ - return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp); -} - -USBDevice *usb_create_simple(USBBus *bus, const char *name) -{ - USBDevice *dev =3D usb_new(name); - - usb_realize_and_unref(dev, bus, &error_abort); - return dev; -} - static void usb_fill_port(USBPort *port, void *opaque, int index, USBPortOps *ops, int speedmask) { --=20 2.43.0