hw/usb: Inline usb_new()

Inline the 3 uses of usb_new().

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20240216110313.17039-11-philmd@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé 2023-12-16 18:24:11 +01:00
parent 8bf6275f7e
commit 8d2701072e
3 changed files with 4 additions and 8 deletions

View File

@ -662,7 +662,8 @@ USBDevice *usbdevice_create(const char *driver)
return NULL; return NULL;
} }
dev = f->usbdevice_init ? f->usbdevice_init() : usb_new(f->name); dev = f->usbdevice_init ? f->usbdevice_init()
: USB_DEVICE(qdev_new(f->name));
if (!dev) { if (!dev) {
error_report("Failed to create USB device '%s'", f->name); error_report("Failed to create USB device '%s'", f->name);
return NULL; return NULL;

View File

@ -624,7 +624,7 @@ static USBDevice *usb_braille_init(void)
return NULL; return NULL;
} }
dev = usb_new("usb-braille"); dev = USB_DEVICE(qdev_new("usb-braille"));
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv); qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
return dev; return dev;
} }

View File

@ -579,11 +579,6 @@ void usb_pcap_init(FILE *fp);
void usb_pcap_ctrl(USBPacket *p, bool setup); void usb_pcap_ctrl(USBPacket *p, bool setup);
void usb_pcap_data(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 bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp) static inline bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
{ {
return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp); return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp);
@ -591,7 +586,7 @@ static inline bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **er
static inline USBDevice *usb_create_simple(USBBus *bus, const char *name) static inline USBDevice *usb_create_simple(USBBus *bus, const char *name)
{ {
USBDevice *dev = usb_new(name); USBDevice *dev = USB_DEVICE(qdev_new(name));
usb_realize_and_unref(dev, bus, &error_abort); usb_realize_and_unref(dev, bus, &error_abort);
return dev; return dev;