From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: philmd@linaro.org, shentey@gmail.com, balaton@eik.bme.hu,
Richard Henderson <richard.henderson@linaro.org>
Subject: [PATCH v3 1/9] usb: inline device creation functions
Date: Tue, 13 Feb 2024 16:49:56 +0100 [thread overview]
Message-ID: <20240213155005.109954-2-pbonzini@redhat.com> (raw)
In-Reply-To: <20240213155005.109954-1-pbonzini@redhat.com>
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 <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
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"
/* 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);
+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, Error **errp)
+{
+ return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp);
+}
+
+static inline USBDevice *usb_create_simple(USBBus *bus, const char *name)
+{
+ USBDevice *dev = 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 char *usbdevice_name,
}
}
-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 = 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)
{
--
2.43.0
next prev parent reply other threads:[~2024-02-13 15:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
2024-02-13 15:49 ` Paolo Bonzini [this message]
2024-02-16 11:14 ` [PATCH v3 1/9] usb: inline device creation functions Philippe Mathieu-Daudé
2024-02-17 9:49 ` Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 2/9] isa: clean up Kconfig selections for ISA_SUPERIO Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 3/9] hw/mips/Kconfig: Remove ISA dependencies from MIPSsim board Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 4/9] isa: fix ISA_SUPERIO dependencies Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 5/9] isa: specify instance_size in isa_superio_type_info Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 6/9] isa: extract FDC37M81X to a separate file Paolo Bonzini
2024-02-13 19:07 ` Bernhard Beschow
2024-02-13 15:50 ` [PATCH v3 7/9] mips: allow compiling out CONFIG_MIPS_ITU Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB Paolo Bonzini
2024-02-15 7:55 ` Philippe Mathieu-Daudé
2024-02-15 11:12 ` Paolo Bonzini
2024-02-15 14:27 ` BALATON Zoltan
2024-02-15 17:31 ` Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 9/9] mips: do not list individual devices from configs/ Paolo Bonzini
2024-02-15 17:51 ` [PATCH v3 0/9] " Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240213155005.109954-2-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=balaton@eik.bme.hu \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=shentey@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).