Revision d0f2c4c6 usb-linux.c

b/usb-linux.c
68 68
//#define DEBUG
69 69

  
70 70
#ifdef DEBUG
71
#define dprintf printf
71
#define DPRINTF printf
72 72
#else
73
#define dprintf(...)
73
#define DPRINTF(...)
74 74
#endif
75 75

  
76 76
#define USBDBG_DEVOPENED "husb: opened %s/devices\n"
......
234 234
                return;
235 235
            }
236 236

  
237
            dprintf("husb: async. reap urb failed errno %d\n", errno);
237
            DPRINTF("husb: async. reap urb failed errno %d\n", errno);
238 238
            return;
239 239
        }
240 240

  
241 241
        p = aurb->packet;
242 242

  
243
	dprintf("husb: async completed. aurb %p status %d alen %d\n", 
243
	DPRINTF("husb: async completed. aurb %p status %d alen %d\n", 
244 244
                aurb, aurb->urb.status, aurb->urb.actual_length);
245 245

  
246 246
	if (p) {
......
273 273
    AsyncURB *aurb = opaque;
274 274
    USBHostDevice *s = aurb->hdev;
275 275

  
276
    dprintf("husb: async cancel. aurb %p\n", aurb);
276
    DPRINTF("husb: async cancel. aurb %p\n", aurb);
277 277

  
278 278
    /* Mark it as dead (see async_complete above) */
279 279
    aurb->packet = NULL;
280 280

  
281 281
    int r = ioctl(s->fd, USBDEVFS_DISCARDURB, aurb);
282 282
    if (r < 0) {
283
        dprintf("husb: async. discard urb failed errno %d\n", errno);
283
        DPRINTF("husb: async. discard urb failed errno %d\n", errno);
284 284
    }
285 285
}
286 286

  
......
293 293
    if (configuration == 0) /* address state - ignore */
294 294
        return 1;
295 295

  
296
    dprintf("husb: claiming interfaces. config %d\n", configuration);
296
    DPRINTF("husb: claiming interfaces. config %d\n", configuration);
297 297

  
298 298
    i = 0;
299 299
    dev_descr_len = dev->descr[0];
......
303 303

  
304 304
    i += dev_descr_len;
305 305
    while (i < dev->descr_len) {
306
        dprintf("husb: i is %d, descr_len is %d, dl %d, dt %d\n", i, dev->descr_len,
306
        DPRINTF("husb: i is %d, descr_len is %d, dl %d, dt %d\n", i, dev->descr_len,
307 307
               dev->descr[i], dev->descr[i+1]);
308 308

  
309 309
        if (dev->descr[i+1] != USB_DT_CONFIG) {
......
370 370
{
371 371
    int ret, i;
372 372

  
373
    dprintf("husb: releasing interfaces\n");
373
    DPRINTF("husb: releasing interfaces\n");
374 374

  
375 375
    for (i = 0; i < s->ninterfaces; i++) {
376 376
        ret = ioctl(s->fd, USBDEVFS_RELEASEINTERFACE, &i);
......
387 387
{
388 388
    USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);
389 389

  
390
    dprintf("husb: reset device %u.%u\n", s->bus_num, s->addr);
390
    DPRINTF("husb: reset device %u.%u\n", s->bus_num, s->addr);
391 391

  
392 392
    ioctl(s->fd, USBDEVFS_RESET);
393 393

  
......
424 424
    if (is_halted(s, p->devep)) {
425 425
	ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &urb->endpoint);
426 426
        if (ret < 0) {
427
            dprintf("husb: failed to clear halt. ep 0x%x errno %d\n", 
427
            DPRINTF("husb: failed to clear halt. ep 0x%x errno %d\n", 
428 428
                   urb->endpoint, errno);
429 429
            return USB_RET_NAK;
430 430
        }
......
449 449

  
450 450
    ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
451 451

  
452
    dprintf("husb: data submit. ep 0x%x len %u aurb %p\n", urb->endpoint, p->len, aurb);
452
    DPRINTF("husb: data submit. ep 0x%x len %u aurb %p\n", urb->endpoint, p->len, aurb);
453 453

  
454 454
    if (ret < 0) {
455
        dprintf("husb: submit failed. errno %d\n", errno);
455
        DPRINTF("husb: submit failed. errno %d\n", errno);
456 456
        async_free(aurb);
457 457

  
458 458
        switch(errno) {
......
478 478

  
479 479
static int usb_host_set_address(USBHostDevice *s, int addr)
480 480
{
481
    dprintf("husb: ctrl set addr %u\n", addr);
481
    DPRINTF("husb: ctrl set addr %u\n", addr);
482 482
    s->dev.addr = addr;
483 483
    return 0;
484 484
}
......
489 489

  
490 490
    int ret = ioctl(s->fd, USBDEVFS_SETCONFIGURATION, &config);
491 491
 
492
    dprintf("husb: ctrl set config %d ret %d errno %d\n", config, ret, errno);
492
    DPRINTF("husb: ctrl set config %d ret %d errno %d\n", config, ret, errno);
493 493
    
494 494
    if (ret < 0)
495 495
        return ctrl_error();
......
507 507
    si.altsetting = alt;
508 508
    ret = ioctl(s->fd, USBDEVFS_SETINTERFACE, &si);
509 509
    
510
    dprintf("husb: ctrl set iface %d altset %d ret %d errno %d\n", 
510
    DPRINTF("husb: ctrl set iface %d altset %d ret %d errno %d\n", 
511 511
    	iface, alt, ret, errno);
512 512
    
513 513
    if (ret < 0)
......
531 531
    value = le16_to_cpu(s->ctrl.req.wValue);
532 532
    index = le16_to_cpu(s->ctrl.req.wIndex);
533 533

  
534
    dprintf("husb: ctrl type 0x%x req 0x%x val 0x%x index %u len %u\n",
534
    DPRINTF("husb: ctrl type 0x%x req 0x%x val 0x%x index %u len %u\n",
535 535
        s->ctrl.req.bRequestType, s->ctrl.req.bRequest, value, index, 
536 536
        s->ctrl.len);
537 537

  
......
580 580

  
581 581
    ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
582 582

  
583
    dprintf("husb: submit ctrl. len %u aurb %p\n", urb->buffer_length, aurb);
583
    DPRINTF("husb: submit ctrl. len %u aurb %p\n", urb->buffer_length, aurb);
584 584

  
585 585
    if (ret < 0) {
586
        dprintf("husb: submit failed. errno %d\n", errno);
586
        DPRINTF("husb: submit failed. errno %d\n", errno);
587 587
        async_free(aurb);
588 588

  
589 589
        switch(errno) {
......
786 786

  
787 787
    if (descriptors[i + 1] != USB_DT_CONFIG ||
788 788
        descriptors[i + 5] != configuration) {
789
        dprintf("invalid descriptor data - configuration\n");
789
        DPRINTF("invalid descriptor data - configuration\n");
790 790
        return 1;
791 791
    }
792 792
    i += descriptors[i];
......
847 847
                type = USBDEVFS_URB_TYPE_INTERRUPT;
848 848
                break;
849 849
            default:
850
                dprintf("usb_host: malformed endpoint type\n");
850
                DPRINTF("usb_host: malformed endpoint type\n");
851 851
                type = USBDEVFS_URB_TYPE_BULK;
852 852
            }
853 853
            s->endp_table[(devep & 0xf) - 1].type = type;
......
882 882
        perror(buf);
883 883
        goto fail;
884 884
    }
885
    dprintf("husb: opened %s\n", buf);
885
    DPRINTF("husb: opened %s\n", buf);
886 886

  
887 887
    dev->bus_num = bus_num;
888 888
    dev->addr = addr;
......
1313 1313
            strcpy(devpath, USBDEVBUS_PATH);
1314 1314
            usb_fs_type = USB_FS_SYS;
1315 1315
            closedir(dir);
1316
            dprintf(USBDBG_DEVOPENED, USBSYSBUS_PATH);
1316
            DPRINTF(USBDBG_DEVOPENED, USBSYSBUS_PATH);
1317 1317
            goto found_devices;
1318 1318
        }
1319 1319
        f = fopen(USBPROCBUS_PATH "/devices", "r");
......
1322 1322
            strcpy(devpath, USBPROCBUS_PATH);
1323 1323
            usb_fs_type = USB_FS_PROC;
1324 1324
            fclose(f);
1325
            dprintf(USBDBG_DEVOPENED, USBPROCBUS_PATH);
1325
            DPRINTF(USBDBG_DEVOPENED, USBPROCBUS_PATH);
1326 1326
            goto found_devices;
1327 1327
        }
1328 1328
        /* try additional methods if an access method hasn't been found yet */
......
1332 1332
            strcpy(devpath, USBDEVBUS_PATH);
1333 1333
            usb_fs_type = USB_FS_DEV;
1334 1334
            fclose(f);
1335
            dprintf(USBDBG_DEVOPENED, USBDEVBUS_PATH);
1335
            DPRINTF(USBDBG_DEVOPENED, USBDEVBUS_PATH);
1336 1336
            goto found_devices;
1337 1337
        }
1338 1338
    found_devices:
......
1399 1399
        if (s->fd != -1)
1400 1400
            return 0;
1401 1401

  
1402
        dprintf("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
1402
        DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
1403 1403

  
1404 1404
	usb_host_open(s, bus_num, addr, product_name);
1405 1405
    }

Also available in: Unified diff