system: squash usb_parse into a single function
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. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20250116160306.1709518-10-alex.bennee@linaro.org>
This commit is contained in:
parent
77e911d0c7
commit
05cdd648a8
24
system/vl.c
24
system/vl.c
@ -811,29 +811,15 @@ static void configure_msg(QemuOpts *opts)
|
|||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* USB devices */
|
/* USB devices */
|
||||||
|
|
||||||
static int usb_device_add(const char *devname)
|
|
||||||
{
|
|
||||||
USBDevice *dev = NULL;
|
|
||||||
|
|
||||||
if (!machine_usb(current_machine)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev = usbdevice_create(devname);
|
|
||||||
if (!dev)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int usb_parse(const char *cmdline)
|
static int usb_parse(const char *cmdline)
|
||||||
{
|
{
|
||||||
int r;
|
g_assert(machine_usb(current_machine));
|
||||||
r = usb_device_add(cmdline);
|
|
||||||
if (r < 0) {
|
if (!usbdevice_create(cmdline)) {
|
||||||
error_report("could not add USB device '%s'", cmdline);
|
error_report("could not add USB device '%s'", cmdline);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return r;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user