diff mbox series

[v2,09/37] system: squash usb_parse into a single function

Message ID 20250114113821.768750-10-alex.bennee@linaro.org
State New
Headers show
Series maintainer updates for jan '25 (semihosting, gdb, plugins, docs) pre-PR | expand

Commit Message

Alex Bennée Jan. 14, 2025, 11:37 a.m. UTC
We don't need to wrap usb_device_add as usb_parse is already gated
with an if (machine_usb(current_machine)) check. Instead just assert
and directly fail if usbdevice_create returns NULL.

Message-Id: <20250109170619.2271193-10-alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 system/vl.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/system/vl.c b/system/vl.c
index 7e3e6fb353..e769132ba3 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -811,31 +811,17 @@  static void configure_msg(QemuOpts *opts)
 /***********************************************************/
 /* USB devices */
 
-static int usb_device_add(const char *devname)
+static int usb_parse(const char *cmdline)
 {
-    USBDevice *dev = NULL;
+    g_assert(machine_usb(current_machine));
 
-    if (!machine_usb(current_machine)) {
+    if (!usbdevice_create(cmdline)) {
+        error_report("could not add USB device '%s'", cmdline);
         return -1;
     }
-
-    dev = usbdevice_create(devname);
-    if (!dev)
-        return -1;
-
     return 0;
 }
 
-static int usb_parse(const char *cmdline)
-{
-    int r;
-    r = usb_device_add(cmdline);
-    if (r < 0) {
-        error_report("could not add USB device '%s'", cmdline);
-    }
-    return r;
-}
-
 /***********************************************************/
 /* machine registration */