Re: [PATCHv3 10/14] Add get_dev_path callback for usb bus.

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

 



On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@xxxxxxxxxx> wrote:
>
> Signed-off-by: Gleb Natapov <gleb@xxxxxxxxxx>
> ---
> Âhw/usb-bus.c | Â 35 +++++++++++++++++++++++++++++++++++
> Â1 files changed, 35 insertions(+), 0 deletions(-)
>
> diff --git a/hw/usb-bus.c b/hw/usb-bus.c
> index 256b881..6292282 100644
> --- a/hw/usb-bus.c
> +++ b/hw/usb-bus.c
> @@ -5,11 +5,13 @@
> Â#include "monitor.h"
>
> Âstatic void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
> +static char *usbbus_get_fw_dev_path(DeviceState *dev);
>
> Âstatic struct BusInfo usb_bus_info = {
>   .name   Â= "USB",
>   .size   Â= sizeof(USBBus),
> Â Â .print_dev = usb_bus_dev_print,
> + Â Â.get_fw_dev_path = usbbus_get_fw_dev_path,
> Â};
> Âstatic int next_usb_bus = 0;
> Âstatic QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
> @@ -307,3 +309,36 @@ USBDevice *usbdevice_create(const char *cmdline)
> Â Â }
> Â Â return usb->usbdevice_init(params);
> Â}
> +
> +static int usbbus_get_fw_dev_path_helper(USBDevice *d, USBBus *bus, char *p,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int len)
> +{
> + Â Âint l = 0;
> + Â ÂUSBPort *port;
> +
> + Â ÂQTAILQ_FOREACH(port, &bus->used, next) {
> + Â Â Â Âif (port->dev != d)

Braces.

> + Â Â Â Â Â Âcontinue;
> +
> + Â Â Â Âif (port->pdev) {
> + Â Â Â Â Â Âl = usbbus_get_fw_dev_path_helper(port->pdev, bus, p, len);
> + Â Â Â Â}
> + Â Â Â Âl += snprintf(p + l, len - l, "%s@%x/", qdev_fw_name(&d->qdev),
> + Â Â Â Â Â Â Â Â Â Â Âport->index);
> + Â Â Â Âreturn l;
> + Â Â}
> + Â Âreturn 0;

With this return value...

> +}
> +
> +static char *usbbus_get_fw_dev_path(DeviceState *dev)
> +{
> + Â ÂUSBDevice *d = (USBDevice*)dev;
> + Â ÂUSBBus *bus = usb_bus_from_device(d);
> + Â Âchar path[100];
> + Â Âint l;
> +
> + Â Âl = usbbus_get_fw_dev_path_helper(d, bus, path, sizeof(path));
> + Â Âpath[l-1] = '\0';

...this statement will have undesirable effects...

> +
> + Â Âreturn strdup(path);

...like this.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux