Message ID | 20200704144943.18292-17-f4bug@amsat.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ | expand |
On Sat, Jul 4, 2020 at 8:00 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote: > > Simplify usb_get_dev_path() a bit. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > hw/usb/bus.c | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) > > diff --git a/hw/usb/bus.c b/hw/usb/bus.c > index 111c3af7c1..f8901e822c 100644 > --- a/hw/usb/bus.c > +++ b/hw/usb/bus.c > @@ -580,19 +580,18 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent) > static char *usb_get_dev_path(DeviceState *qdev) > { > USBDevice *dev = USB_DEVICE(qdev); > - DeviceState *hcd = qdev->parent_bus->parent; > - char *id = NULL; > > if (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) { > - id = qdev_get_dev_path(hcd); > - } > - if (id) { > - char *ret = g_strdup_printf("%s/%s", id, dev->port->path); > - g_free(id); > - return ret; > - } else { > - return g_strdup(dev->port->path); > + DeviceState *hcd = qdev->parent_bus->parent; > + char *id = qdev_get_dev_path(hcd); > + > + if (id) { > + char *ret = g_strdup_printf("%s/%s", id, dev->port->path); > + g_free(id); > + return ret; > + } > } > + return g_strdup(dev->port->path); > } > > static char *usb_get_fw_dev_path(DeviceState *qdev) > -- > 2.21.3 > >
diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 111c3af7c1..f8901e822c 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -580,19 +580,18 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent) static char *usb_get_dev_path(DeviceState *qdev) { USBDevice *dev = USB_DEVICE(qdev); - DeviceState *hcd = qdev->parent_bus->parent; - char *id = NULL; if (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) { - id = qdev_get_dev_path(hcd); - } - if (id) { - char *ret = g_strdup_printf("%s/%s", id, dev->port->path); - g_free(id); - return ret; - } else { - return g_strdup(dev->port->path); + DeviceState *hcd = qdev->parent_bus->parent; + char *id = qdev_get_dev_path(hcd); + + if (id) { + char *ret = g_strdup_printf("%s/%s", id, dev->port->path); + g_free(id); + return ret; + } } + return g_strdup(dev->port->path); } static char *usb_get_fw_dev_path(DeviceState *qdev)
Simplify usb_get_dev_path() a bit. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/usb/bus.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)