USBDevice *usb_host_device_open(USBBus *bus, const char *devname)

{

    struct USBAutoFilter filter;

    USBDevice *dev;

    char *p;



    dev = usb_create(bus, "usb-host");



    if (strstr(devname, "auto:")) {

        if (parse_filter(devname, &filter) < 0) {

            goto fail;

        }

    } else {

        p = strchr(devname, '.');

        if (p) {

            filter.bus_num    = strtoul(devname, NULL, 0);

            filter.addr       = strtoul(p + 1, NULL, 0);

            filter.vendor_id  = 0;

            filter.product_id = 0;

        } else {

            p = strchr(devname, ':');

            if (p) {

                filter.bus_num    = 0;

                filter.addr       = 0;

                filter.vendor_id  = strtoul(devname, NULL, 16);

                filter.product_id = strtoul(p + 1, NULL, 16);

            } else {

                goto fail;

            }

        }

    }



    qdev_prop_set_uint32(&dev->qdev, "hostbus",   filter.bus_num);

    qdev_prop_set_uint32(&dev->qdev, "hostaddr",  filter.addr);

    qdev_prop_set_uint32(&dev->qdev, "vendorid",  filter.vendor_id);

    qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id);

    qdev_init_nofail(&dev->qdev);

    return dev;



fail:

    object_unparent(OBJECT(dev));

    return NULL;

}

USBDevice *usb_host_device_open(USBBus *bus, const char *devname)

{

    struct USBAutoFilter filter;

    USBDevice *dev;

    char *p;



    dev = usb_create(bus, "usb-host");



    if (strstr(devname, "auto:")) {

        if (parse_filter(devname, &filter) < 0) {

            goto fail;

        }

    } else {

        p = strchr(devname, '.');

        if (p) {

            filter.bus_num    = strtoul(devname, NULL, 0);

            filter.addr       = strtoul(p + 1, NULL, 0);

            filter.vendor_id  = 0;

            filter.product_id = 0;

        } else {

            p = strchr(devname, ':');

            if (p) {

                filter.bus_num    = 0;

                filter.addr       = 0;

                filter.vendor_id  = strtoul(devname, NULL, 16);

                filter.product_id = strtoul(p + 1, NULL, 16);

            } else {

                goto fail;

            }

        }

    }



    qdev_prop_set_uint32(&dev->qdev, "hostbus",   filter.bus_num);

    qdev_prop_set_uint32(&dev->qdev, "hostaddr",  filter.addr);

    qdev_prop_set_uint32(&dev->qdev, "vendorid",  filter.vendor_id);

    qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id);

    qdev_init_nofail(&dev->qdev);

    return dev;



fail:

    object_unparent(OBJECT(dev));

    return NULL;

}

    qdev_init_nofail(&dev->qdev);     qdev_init_nofail(&dev->qdev);     qdev_init_nofail(&dev->qdev);     qdev_init_nofail(&dev->qdev);
USBDevice *FUNC_0(USBBus *bus, const char *devname)

{

    struct USBAutoFilter VAR_0;

    USBDevice *dev;

    char *VAR_1;



    dev = usb_create(bus, "usb-host");



    if (strstr(devname, "auto:")) {

        if (parse_filter(devname, &VAR_0) < 0) {

            goto fail;

        }

    } else {

        VAR_1 = strchr(devname, '.');

        if (VAR_1) {

            VAR_0.bus_num    = strtoul(devname, NULL, 0);

            VAR_0.addr       = strtoul(VAR_1 + 1, NULL, 0);

            VAR_0.vendor_id  = 0;

            VAR_0.product_id = 0;

        } else {

            VAR_1 = strchr(devname, ':');

            if (VAR_1) {

                VAR_0.bus_num    = 0;

                VAR_0.addr       = 0;

                VAR_0.vendor_id  = strtoul(devname, NULL, 16);

                VAR_0.product_id = strtoul(VAR_1 + 1, NULL, 16);

            } else {

                goto fail;

            }

        }

    }



    qdev_prop_set_uint32(&dev->qdev, "hostbus",   VAR_0.bus_num);

    qdev_prop_set_uint32(&dev->qdev, "hostaddr",  VAR_0.addr);

    qdev_prop_set_uint32(&dev->qdev, "vendorid",  VAR_0.vendor_id);

    qdev_prop_set_uint32(&dev->qdev, "productid", VAR_0.product_id);

    qdev_init_nofail(&dev->qdev);

    return dev;



fail:

    object_unparent(OBJECT(dev));

    return NULL;

}

USBDevice *FUNC_0(USBBus *bus, const char *devname)
{ struct USBAutoFilter VAR_0; USBDevice *dev; char *VAR_1; dev = usb_create(bus, "usb-host"); if (strstr(devname, "auto:")) { if (parse_filter(devname, &VAR_0) < 0) { goto fail; } } else { VAR_1 = strchr(devname, '.'); if (VAR_1) { VAR_0.bus_num    = strtoul(devname, NULL, 0); VAR_0.addr       = strtoul(VAR_1 + 1, NULL, 0); VAR_0.vendor_id  = 0; VAR_0.product_id = 0; } else { VAR_1 = strchr(devname, ':'); if (VAR_1) { VAR_0.bus_num    = 0; VAR_0.addr       = 0; VAR_0.vendor_id  = strtoul(devname, NULL, 16); VAR_0.product_id = strtoul(VAR_1 + 1, NULL, 16); } else { goto fail; } } } qdev_prop_set_uint32(&dev->qdev, "hostbus",   VAR_0.bus_num); qdev_prop_set_uint32(&dev->qdev, "hostaddr",  VAR_0.addr); qdev_prop_set_uint32(&dev->qdev, "vendorid",  VAR_0.vendor_id); qdev_prop_set_uint32(&dev->qdev, "productid", VAR_0.product_id); qdev_init_nofail(&dev->qdev); return dev; fail:
object_unparent(OBJECT(dev)); return NULL; }