[PATCH 10/21] hw/usb: Inline usb_new()

Philippe Mathieu-Daudé posted 21 patches 8 months, 2 weeks ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Jan Kiszka <jan.kiszka@web.de>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Alistair Francis <alistair@alistair23.me>, Richard Henderson <richard.henderson@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Pavel Pisa <pisa@cmp.felk.cvut.cz>, Vikram Garhwal <fnu.vikram@xilinx.com>, Francisco Iglesias <francisco.iglesias@amd.com>, Jason Wang <jasowang@redhat.com>, Chris Wulff <crwulff@gmail.com>, Marek Vasut <marex@denx.de>, "Hervé Poussineau" <hpoussin@reactos.org>, "Cédric Le Goater" <clg@kaod.org>, Nicholas Piggin <npiggin@gmail.com>, "Frédéric Barrat" <fbarrat@linux.ibm.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Gerd Hoffmann <kraxel@redhat.com>, Samuel Thibault <samuel.thibault@ens-lyon.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Max Filippov <jcmvbkbc@gmail.com>
[PATCH 10/21] hw/usb: Inline usb_new()
Posted by Philippe Mathieu-Daudé 8 months, 2 weeks ago
Inline the 2 uses of usb_new().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/usb.h    | 1 -
 hw/usb/bus.c        | 9 ++-------
 hw/usb/dev-serial.c | 2 +-
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/include/hw/usb.h b/include/hw/usb.h
index 32c23a5ca2..2d820685cc 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -500,7 +500,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);
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 148224f06a..a599e2552b 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -329,11 +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));
-}
-
 bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
 {
     return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp);
@@ -341,7 +336,7 @@ bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
 
 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);
     return dev;
@@ -693,7 +688,7 @@ USBDevice *usbdevice_create(const char *driver)
         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) {
         error_report("Failed to create USB device '%s'", f->name);
         return NULL;
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 63047d79cf..6e79c46d53 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -624,7 +624,7 @@ static USBDevice *usb_braille_init(void)
         return NULL;
     }
 
-    dev = usb_new("usb-braille");
+    dev = USB_DEVICE(qdev_new("usb-braille"));
     qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
     return dev;
 }
-- 
2.41.0


Re: [PATCH 10/21] hw/usb: Inline usb_new()
Posted by Zhao Liu 8 months, 1 week ago
On Fri, Feb 16, 2024 at 12:03:01PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Fri, 16 Feb 2024 12:03:01 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH 10/21] hw/usb: Inline usb_new()
> X-Mailer: git-send-email 2.41.0
> 
> Inline the 2 uses of usb_new().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  include/hw/usb.h    | 1 -
>  hw/usb/bus.c        | 9 ++-------
>  hw/usb/dev-serial.c | 2 +-
>  3 files changed, 3 insertions(+), 9 deletions(-)

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>

> 
> diff --git a/include/hw/usb.h b/include/hw/usb.h
> index 32c23a5ca2..2d820685cc 100644
> --- a/include/hw/usb.h
> +++ b/include/hw/usb.h
> @@ -500,7 +500,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);
> diff --git a/hw/usb/bus.c b/hw/usb/bus.c
> index 148224f06a..a599e2552b 100644
> --- a/hw/usb/bus.c
> +++ b/hw/usb/bus.c
> @@ -329,11 +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));
> -}
> -
>  bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
>  {
>      return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp);
> @@ -341,7 +336,7 @@ bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
>  
>  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);
>      return dev;
> @@ -693,7 +688,7 @@ USBDevice *usbdevice_create(const char *driver)
>          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) {
>          error_report("Failed to create USB device '%s'", f->name);
>          return NULL;
> diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
> index 63047d79cf..6e79c46d53 100644
> --- a/hw/usb/dev-serial.c
> +++ b/hw/usb/dev-serial.c
> @@ -624,7 +624,7 @@ static USBDevice *usb_braille_init(void)
>          return NULL;
>      }
>  
> -    dev = usb_new("usb-braille");
> +    dev = USB_DEVICE(qdev_new("usb-braille"));
>      qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
>      return dev;
>  }
> -- 
> 2.41.0
> 
>