Revision 620150dc usb-bsd.c

b/usb-bsd.c
63 63
} USBHostDevice;
64 64

  
65 65

  
66
#if 0
66 67
static int ensure_ep_open(USBHostDevice *dev, int ep, int mode)
67 68
{
68 69
    char buf[32];
......
110 111
        epnum++;
111 112
    }
112 113
}
114
#endif
113 115

  
114 116
static void usb_host_handle_reset(USBDevice *dev)
115 117
{
......
118 120
#endif
119 121
}
120 122

  
123
#if 0
121 124
/* XXX:
122 125
 * -check device states against transfer requests
123 126
 *  and return appropriate response
......
275 278
        return ret;
276 279
    }
277 280
}
281
#endif
278 282

  
279 283
static void usb_host_handle_destroy(USBDevice *opaque)
280 284
{
......
293 297
    qemu_free(s);
294 298
}
295 299

  
300
static int usb_host_initfn(USBDevice *dev)
301
{
302
    return 0;
303
}
304

  
296 305
USBDevice *usb_host_device_open(const char *devname)
297 306
{
298 307
    struct usb_device_info bus_info, dev_info;
308
    USBDevice *d = NULL;
299 309
    USBHostDevice *dev;
300 310
    char ctlpath[PATH_MAX + 1];
301 311
    char buspath[PATH_MAX + 1];
......
343 353
    }
344 354

  
345 355
    if (dfd >= 0) {
346
        dev = qemu_mallocz(sizeof(USBHostDevice));
347
        dev->devfd = dfd;
348

  
349 356
        if (ioctl(dfd, USB_GET_DEVICEINFO, &dev_info) < 0) {
350 357
#ifdef DEBUG
351 358
            printf("usb_host_device_open: failed to grab device info - %s\n",
......
354 361
            goto fail;
355 362
        }
356 363

  
364
        d = usb_create(NULL /* FIXME */, "USB Host Device");
365
        dev = DO_UPCAST(USBHostDevice, dev, d);
366

  
357 367
        if (dev_info.udi_speed == 1)
358 368
            dev->dev.speed = USB_SPEED_LOW - 1;
359 369
        else
360 370
            dev->dev.speed = USB_SPEED_FULL - 1;
361 371

  
362
        dev->dev.handle_packet = usb_generic_handle_packet;
363

  
364
        dev->dev.handle_reset = usb_host_handle_reset;
365
        dev->dev.handle_control = usb_host_handle_control;
366
        dev->dev.handle_data = usb_host_handle_data;
367
        dev->dev.handle_destroy = usb_host_handle_destroy;
368

  
369 372
        if (strncmp(dev_info.udi_product, "product", 7) != 0)
370 373
            pstrcpy(dev->dev.devname, sizeof(dev->dev.devname),
371 374
                    dev_info.udi_product);
......
389 392
    return NULL;
390 393
}
391 394

  
395
static struct USBDeviceInfo usb_host_dev_info = {
396
    .qdev.name      = "USB Host Device",
397
    .qdev.size      = sizeof(USBHostDevice),
398
    .init           = usb_host_initfn,
399
    .handle_packet  = usb_generic_handle_packet,
400
    .handle_reset   = usb_host_handle_reset,
401
#if 0
402
    .handle_control = usb_host_handle_control,
403
    .handle_data    = usb_host_handle_data,
404
#endif
405
    .handle_destroy = usb_host_handle_destroy,
406
};
407

  
408
static void usb_host_register_devices(void)
409
{
410
    usb_qdev_register(&usb_host_dev_info);
411
}
412
device_init(usb_host_register_devices)
413

  
392 414
static int usb_host_scan(void *opaque, USBScanFunc *func)
393 415
{
394 416
    struct usb_device_info bus_info;

Also available in: Unified diff