static USBDevice *usb_serial_init(USBBus *bus, const char *filename)

{

    USBDevice *dev;

    CharDriverState *cdrv;

    uint32_t vendorid = 0, productid = 0;

    char label[32];

    static int index;



    while (*filename && *filename != ':') {

        const char *p;

        char *e;

        if (strstart(filename, "vendorid=", &p)) {

            vendorid = strtol(p, &e, 16);

            if (e == p || (*e && *e != ',' && *e != ':')) {

                error_report("bogus vendor ID %s", p);

                return NULL;

            }

            filename = e;

        } else if (strstart(filename, "productid=", &p)) {

            productid = strtol(p, &e, 16);

            if (e == p || (*e && *e != ',' && *e != ':')) {

                error_report("bogus product ID %s", p);

                return NULL;

            }

            filename = e;

        } else {

            error_report("unrecognized serial USB option %s", filename);

            return NULL;

        }

        while(*filename == ',')

            filename++;

    }

    if (!*filename) {

        error_report("character device specification needed");

        return NULL;

    }

    filename++;



    snprintf(label, sizeof(label), "usbserial%d", index++);

    cdrv = qemu_chr_new(label, filename, NULL);

    if (!cdrv)

        return NULL;



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

    qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);

    if (vendorid)

        qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);

    if (productid)

        qdev_prop_set_uint16(&dev->qdev, "productid", productid);

    qdev_init_nofail(&dev->qdev);



    return dev;

}

static USBDevice *usb_serial_init(USBBus *bus, const char *filename)

{

    USBDevice *dev;

    CharDriverState *cdrv;

    uint32_t vendorid = 0, productid = 0;

    char label[32];

    static int index;



    while (*filename && *filename != ':') {

        const char *p;

        char *e;

        if (strstart(filename, "vendorid=", &p)) {

            vendorid = strtol(p, &e, 16);

            if (e == p || (*e && *e != ',' && *e != ':')) {

                error_report("bogus vendor ID %s", p);

                return NULL;

            }

            filename = e;

        } else if (strstart(filename, "productid=", &p)) {

            productid = strtol(p, &e, 16);

            if (e == p || (*e && *e != ',' && *e != ':')) {

                error_report("bogus product ID %s", p);

                return NULL;

            }

            filename = e;

        } else {

            error_report("unrecognized serial USB option %s", filename);

            return NULL;

        }

        while(*filename == ',')

            filename++;

    }

    if (!*filename) {

        error_report("character device specification needed");

        return NULL;

    }

    filename++;



    snprintf(label, sizeof(label), "usbserial%d", index++);

    cdrv = qemu_chr_new(label, filename, NULL);

    if (!cdrv)

        return NULL;



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

    qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);

    if (vendorid)

        qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);

    if (productid)

        qdev_prop_set_uint16(&dev->qdev, "productid", productid);

    qdev_init_nofail(&dev->qdev);



    return dev;

}

        return NULL;     qdev_init_nofail(&dev->qdev);     qdev_init_nofail(&dev->qdev);     qdev_init_nofail(&dev->qdev);         return NULL;     qdev_init_nofail(&dev->qdev);
static USBDevice *FUNC_0(USBBus *bus, const char *filename)

{

    USBDevice *dev;

    CharDriverState *cdrv;

    uint32_t vendorid = 0, productid = 0;

    char VAR_0[32];

    static int VAR_1;



    while (*filename && *filename != ':') {

        const char *VAR_2;

        char *VAR_3;

        if (strstart(filename, "vendorid=", &VAR_2)) {

            vendorid = strtol(VAR_2, &VAR_3, 16);

            if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) {

                error_report("bogus vendor ID %s", VAR_2);

                return NULL;

            }

            filename = VAR_3;

        } else if (strstart(filename, "productid=", &VAR_2)) {

            productid = strtol(VAR_2, &VAR_3, 16);

            if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) {

                error_report("bogus product ID %s", VAR_2);

                return NULL;

            }

            filename = VAR_3;

        } else {

            error_report("unrecognized serial USB option %s", filename);

            return NULL;

        }

        while(*filename == ',')

            filename++;

    }

    if (!*filename) {

        error_report("character device specification needed");

        return NULL;

    }

    filename++;



    snprintf(VAR_0, sizeof(VAR_0), "usbserial%d", VAR_1++);

    cdrv = qemu_chr_new(VAR_0, filename, NULL);

    if (!cdrv)

        return NULL;



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

    qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);

    if (vendorid)

        qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);

    if (productid)

        qdev_prop_set_uint16(&dev->qdev, "productid", productid);

    qdev_init_nofail(&dev->qdev);



    return dev;

}

static USBDevice *FUNC_0(USBBus *bus, const char *filename)
{ USBDevice *dev; CharDriverState *cdrv; uint32_t vendorid = 0, productid = 0; char VAR_0[32]; static int VAR_1; while (*filename && *filename != ':') { const char *VAR_2; char *VAR_3; if (strstart(filename, "vendorid=", &VAR_2)) { vendorid = strtol(VAR_2, &VAR_3, 16); if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) { error_report("bogus vendor ID %s", VAR_2); return NULL; } filename = VAR_3; } else if (strstart(filename, "productid=", &VAR_2)) { productid = strtol(VAR_2, &VAR_3, 16); if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) { error_report("bogus product ID %s", VAR_2); return NULL; } filename = VAR_3; } else { error_report("unrecognized serial USB option %s", filename); return NULL; } while(*filename == ',')
filename++; } if (!*filename) { error_report("character device specification needed"); return NULL; } filename++; snprintf(VAR_0, sizeof(VAR_0), "usbserial%d", VAR_1++); cdrv = qemu_chr_new(VAR_0, filename, NULL); if (!cdrv)
return NULL; dev = usb_create(bus, "usb-serial"); qdev_prop_set_chr(&dev->qdev, "chardev", cdrv); if (vendorid)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid); if (productid)
qdev_prop_set_uint16(&dev->qdev, "productid", productid); qdev_init_nofail(&dev->qdev); return dev; }