usb: inline device creation functions
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>
This commit is contained in:
parent
99d0dcd7f1
commit
726c609936
23
hw/usb/bus.c
23
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)
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user