Revision 41c01ee7 usb-linux.c

b/usb-linux.c
267 267
    qemu_free(aurb);
268 268
}
269 269

  
270
static void do_disconnect(USBHostDevice *s)
271
{
272
    printf("husb: device %d.%d disconnected\n",
273
           s->bus_num, s->addr);
274
    usb_host_close(s);
275
    usb_host_auto_check(NULL);
276
}
277

  
270 278
static void async_complete(void *opaque)
271 279
{
272 280
    USBHostDevice *s = opaque;
......
281 289
                return;
282 290
            }
283 291
            if (errno == ENODEV && !s->closing) {
284
                printf("husb: device %d.%d disconnected\n",
285
                       s->bus_num, s->addr);
286
                usb_host_close(s);
287
                usb_host_auto_check(NULL);
292
                do_disconnect(s);
288 293
                return;
289 294
            }
290 295

  
......
358 363

  
359 364
static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
360 365
{
366
    const char *op = NULL;
361 367
    int dev_descr_len, config_descr_len;
362 368
    int interface, nb_interfaces;
363 369
    int ret, i;
......
410 416
            ctrl.ioctl_code = USBDEVFS_DISCONNECT;
411 417
            ctrl.ifno = interface;
412 418
            ctrl.data = 0;
419
            op = "USBDEVFS_DISCONNECT";
413 420
            ret = ioctl(dev->fd, USBDEVFS_IOCTL, &ctrl);
414 421
            if (ret < 0 && errno != ENODATA) {
415
                perror("USBDEVFS_DISCONNECT");
416 422
                goto fail;
417 423
            }
418 424
        }
......
421 427

  
422 428
    /* XXX: only grab if all interfaces are free */
423 429
    for (interface = 0; interface < nb_interfaces; interface++) {
430
        op = "USBDEVFS_CLAIMINTERFACE";
424 431
        ret = ioctl(dev->fd, USBDEVFS_CLAIMINTERFACE, &interface);
425 432
        if (ret < 0) {
426 433
            if (errno == EBUSY) {
......
428 435
            } else {
429 436
                perror("husb: failed to claim interface");
430 437
            }
431
        fail:
432
            return 0;
438
            goto fail;
433 439
        }
434 440
    }
435 441

  
......
439 445
    dev->ninterfaces   = nb_interfaces;
440 446
    dev->configuration = configuration;
441 447
    return 1;
448

  
449
fail:
450
    if (errno == ENODEV) {
451
        do_disconnect(dev);
452
    }
453
    perror(op);
454
    return 0;
442 455
}
443 456

  
444 457
static int usb_host_release_interfaces(USBHostDevice *s)

Also available in: Unified diff