//#define DEBUG
#ifdef DEBUG
-#define dprintf printf
+#define DPRINTF printf
#else
-#define dprintf(...)
+#define DPRINTF(...)
#endif
#define USBDBG_DEVOPENED "husb: opened %s/devices\n"
return;
}
- dprintf("husb: async. reap urb failed errno %d\n", errno);
+ DPRINTF("husb: async. reap urb failed errno %d\n", errno);
return;
}
p = aurb->packet;
- dprintf("husb: async completed. aurb %p status %d alen %d\n",
+ DPRINTF("husb: async completed. aurb %p status %d alen %d\n",
aurb, aurb->urb.status, aurb->urb.actual_length);
if (p) {
AsyncURB *aurb = opaque;
USBHostDevice *s = aurb->hdev;
- dprintf("husb: async cancel. aurb %p\n", aurb);
+ DPRINTF("husb: async cancel. aurb %p\n", aurb);
/* Mark it as dead (see async_complete above) */
aurb->packet = NULL;
int r = ioctl(s->fd, USBDEVFS_DISCARDURB, aurb);
if (r < 0) {
- dprintf("husb: async. discard urb failed errno %d\n", errno);
+ DPRINTF("husb: async. discard urb failed errno %d\n", errno);
}
}
if (configuration == 0) /* address state - ignore */
return 1;
- dprintf("husb: claiming interfaces. config %d\n", configuration);
+ DPRINTF("husb: claiming interfaces. config %d\n", configuration);
i = 0;
dev_descr_len = dev->descr[0];
i += dev_descr_len;
while (i < dev->descr_len) {
- dprintf("husb: i is %d, descr_len is %d, dl %d, dt %d\n", i, dev->descr_len,
+ DPRINTF("husb: i is %d, descr_len is %d, dl %d, dt %d\n", i, dev->descr_len,
dev->descr[i], dev->descr[i+1]);
if (dev->descr[i+1] != USB_DT_CONFIG) {
{
int ret, i;
- dprintf("husb: releasing interfaces\n");
+ DPRINTF("husb: releasing interfaces\n");
for (i = 0; i < s->ninterfaces; i++) {
ret = ioctl(s->fd, USBDEVFS_RELEASEINTERFACE, &i);
{
USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);
- dprintf("husb: reset device %u.%u\n", s->bus_num, s->addr);
+ DPRINTF("husb: reset device %u.%u\n", s->bus_num, s->addr);
ioctl(s->fd, USBDEVFS_RESET);
if (is_halted(s, p->devep)) {
ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &urb->endpoint);
if (ret < 0) {
- dprintf("husb: failed to clear halt. ep 0x%x errno %d\n",
+ DPRINTF("husb: failed to clear halt. ep 0x%x errno %d\n",
urb->endpoint, errno);
return USB_RET_NAK;
}
ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
- dprintf("husb: data submit. ep 0x%x len %u aurb %p\n", urb->endpoint, p->len, aurb);
+ DPRINTF("husb: data submit. ep 0x%x len %u aurb %p\n", urb->endpoint, p->len, aurb);
if (ret < 0) {
- dprintf("husb: submit failed. errno %d\n", errno);
+ DPRINTF("husb: submit failed. errno %d\n", errno);
async_free(aurb);
switch(errno) {
static int usb_host_set_address(USBHostDevice *s, int addr)
{
- dprintf("husb: ctrl set addr %u\n", addr);
+ DPRINTF("husb: ctrl set addr %u\n", addr);
s->dev.addr = addr;
return 0;
}
int ret = ioctl(s->fd, USBDEVFS_SETCONFIGURATION, &config);
- dprintf("husb: ctrl set config %d ret %d errno %d\n", config, ret, errno);
+ DPRINTF("husb: ctrl set config %d ret %d errno %d\n", config, ret, errno);
if (ret < 0)
return ctrl_error();
si.altsetting = alt;
ret = ioctl(s->fd, USBDEVFS_SETINTERFACE, &si);
- dprintf("husb: ctrl set iface %d altset %d ret %d errno %d\n",
+ DPRINTF("husb: ctrl set iface %d altset %d ret %d errno %d\n",
iface, alt, ret, errno);
if (ret < 0)
value = le16_to_cpu(s->ctrl.req.wValue);
index = le16_to_cpu(s->ctrl.req.wIndex);
- dprintf("husb: ctrl type 0x%x req 0x%x val 0x%x index %u len %u\n",
+ DPRINTF("husb: ctrl type 0x%x req 0x%x val 0x%x index %u len %u\n",
s->ctrl.req.bRequestType, s->ctrl.req.bRequest, value, index,
s->ctrl.len);
ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
- dprintf("husb: submit ctrl. len %u aurb %p\n", urb->buffer_length, aurb);
+ DPRINTF("husb: submit ctrl. len %u aurb %p\n", urb->buffer_length, aurb);
if (ret < 0) {
- dprintf("husb: submit failed. errno %d\n", errno);
+ DPRINTF("husb: submit failed. errno %d\n", errno);
async_free(aurb);
switch(errno) {
if (descriptors[i + 1] != USB_DT_CONFIG ||
descriptors[i + 5] != configuration) {
- dprintf("invalid descriptor data - configuration\n");
+ DPRINTF("invalid descriptor data - configuration\n");
return 1;
}
i += descriptors[i];
type = USBDEVFS_URB_TYPE_INTERRUPT;
break;
default:
- dprintf("usb_host: malformed endpoint type\n");
+ DPRINTF("usb_host: malformed endpoint type\n");
type = USBDEVFS_URB_TYPE_BULK;
}
s->endp_table[(devep & 0xf) - 1].type = type;
perror(buf);
goto fail;
}
- dprintf("husb: opened %s\n", buf);
+ DPRINTF("husb: opened %s\n", buf);
dev->bus_num = bus_num;
dev->addr = addr;
*/
static int usb_host_read_file(char *line, size_t line_size, const char *device_file, const char *device_name)
{
-#if 0
- Monitor *mon = cur_mon;
-#endif
FILE *f;
int ret = 0;
char filename[PATH_MAX];
if (f) {
ret = fgets(line, line_size, f) != NULL;
fclose(f);
-#if 0
- } else {
- if (mon)
- monitor_printf(mon, "husb: could not open %s\n", filename);
-#endif
}
return ret;
strcpy(devpath, USBDEVBUS_PATH);
usb_fs_type = USB_FS_SYS;
closedir(dir);
- dprintf(USBDBG_DEVOPENED, USBSYSBUS_PATH);
+ DPRINTF(USBDBG_DEVOPENED, USBSYSBUS_PATH);
goto found_devices;
}
f = fopen(USBPROCBUS_PATH "/devices", "r");
strcpy(devpath, USBPROCBUS_PATH);
usb_fs_type = USB_FS_PROC;
fclose(f);
- dprintf(USBDBG_DEVOPENED, USBPROCBUS_PATH);
+ DPRINTF(USBDBG_DEVOPENED, USBPROCBUS_PATH);
goto found_devices;
}
/* try additional methods if an access method hasn't been found yet */
strcpy(devpath, USBDEVBUS_PATH);
usb_fs_type = USB_FS_DEV;
fclose(f);
- dprintf(USBDBG_DEVOPENED, USBDEVBUS_PATH);
+ DPRINTF(USBDBG_DEVOPENED, USBDEVBUS_PATH);
goto found_devices;
}
found_devices:
if (s->fd != -1)
return 0;
- dprintf("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
+ DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
usb_host_open(s, bus_num, addr, product_name);
}