qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 26/58] usb: New usb_new(), usb_realize_and_unref()


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 26/58] usb: New usb_new(), usb_realize_and_unref()
Date: Tue, 9 Jun 2020 10:21:59 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 5/29/20 3:44 PM, Markus Armbruster wrote:
> I'm converting from qdev_create()/qdev_init_nofail() to
> qdev_new()/qdev_realize_and_unref(); recent commit "qdev: New
> qdev_new(), qdev_realize(), etc." explains why.
> 
> USB devices use qdev_create() through usb_create().
> 
> Provide usb_new() and usb_realize_and_unref() for converting USB
> devices.
> 
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  include/hw/usb.h |  2 ++
>  hw/usb/bus.c     | 10 ++++++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/include/hw/usb.h b/include/hw/usb.h
> index 1cf1cd9584..2d2730f161 100644
> --- a/include/hw/usb.h
> +++ b/include/hw/usb.h
> @@ -534,6 +534,8 @@ USBBus *usb_bus_find(int busnr);
>  void usb_legacy_register(const char *typename, const char *usbdevice_name,
>                           USBDevice *(*usbdevice_init)(USBBus *bus,
>                                                        const char *params));
> +USBDevice *usb_new(const char *name);
> +bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
>  USBDevice *usb_create(USBBus *bus, const char *name);
>  USBDevice *usb_create_simple(USBBus *bus, const char *name);
>  USBDevice *usbdevice_create(const char *cmdline);
> diff --git a/hw/usb/bus.c b/hw/usb/bus.c
> index d28eff1b5c..6b0d9f9e4d 100644
> --- a/hw/usb/bus.c
> +++ b/hw/usb/bus.c
> @@ -314,6 +314,16 @@ void usb_legacy_register(const char *typename, const 
> char *usbdevice_name,
>      }
>  }
>  
> +USBDevice *usb_new(const char *name)
> +{
> +    return USB_DEVICE(qdev_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(USBBus *bus, const char *name)
>  {
>      DeviceState *dev;
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]