[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/17] usb: inline device creation functions
From: |
Paolo Bonzini |
Subject: |
[PULL 16/17] usb: inline device creation functions |
Date: |
Tue, 20 Feb 2024 09:05:57 +0100 |
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
- [PULL 04/17] i386/pc: Drop pc_machine_kvm_type(), (continued)
- [PULL 04/17] i386/pc: Drop pc_machine_kvm_type(), Paolo Bonzini, 2024/02/20
- [PULL 05/17] physmem: replace function name with __func__ in ram_block_discard_range(), Paolo Bonzini, 2024/02/20
- [PULL 06/17] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F, Paolo Bonzini, 2024/02/20
- [PULL 08/17] i386/cpuid: Move leaf 7 to correct group, Paolo Bonzini, 2024/02/20
- [PULL 09/17] mips: remove unnecessary "select PTIMER", Paolo Bonzini, 2024/02/20
- [PULL 10/17] isa-superio: validate floppy.count value, Paolo Bonzini, 2024/02/20
- [PULL 11/17] smc37c669: remove useless is_enabled functions, Paolo Bonzini, 2024/02/20
- [PULL 12/17] configure: do not create legacy symlinks, Paolo Bonzini, 2024/02/20
- [PULL 14/17] i386: xen: fix compilation --without-default-devices, Paolo Bonzini, 2024/02/20
- [PULL 13/17] configure: put all symlink creation together, Paolo Bonzini, 2024/02/20
- [PULL 16/17] usb: inline device creation functions,
Paolo Bonzini <=
- [PULL 15/17] target/i386: Generate an illegal opcode exception on cmp instructions with lock prefix, Paolo Bonzini, 2024/02/20
- [PULL 17/17] ci: Fix again build-previous-qemu, Paolo Bonzini, 2024/02/20
- [PULL 07/17] i386/cpuid: Remove subleaf constraint on CPUID leaf 1F, Paolo Bonzini, 2024/02/20
- Re: [PULL 00/17] Build, x86 patches for 2024-02-16, Peter Maydell, 2024/02/20