#else
#include <bus/usb/usb.h>
#endif
-#include <signal.h>
/* This value has maximum potential at 16.
* You should also set hw.usb.debug to gain
} USBHostDevice;
-#if 0
static int ensure_ep_open(USBHostDevice *dev, int ep, int mode)
{
char buf[32];
epnum++;
}
}
-#endif
static void usb_host_handle_reset(USBDevice *dev)
{
#endif
}
-#if 0
/* XXX:
* -check device states against transfer requests
* and return appropriate response
int ret, fd, mode;
int one = 1, shortpacket = 0, timeout = 50;
sigset_t new_mask, old_mask;
- uint8_t devep = p->devep;
+ uint8_t devep = p->ep->nr;
/* protect data transfers from SIGALRM signal */
sigemptyset(&new_mask);
}
if (p->pid == USB_TOKEN_IN)
- ret = read(fd, p->data, p->len);
+ ret = readv(fd, p->iov.iov, p->iov.niov);
else
- ret = write(fd, p->data, p->len);
+ ret = writev(fd, p->iov.iov, p->iov.niov);
sigprocmask(SIG_SETMASK, &old_mask, NULL);
return ret;
}
}
-#endif
static void usb_host_handle_destroy(USBDevice *opaque)
{
close(s->devfd);
- qemu_free(s);
+ g_free(s);
}
static int usb_host_initfn(USBDevice *dev)
USBDevice *usb_host_device_open(const char *devname)
{
struct usb_device_info bus_info, dev_info;
- USBDevice *d = NULL;
- USBHostDevice *dev, *ret = NULL;
+ USBDevice *d = NULL, *ret = NULL;
+ USBHostDevice *dev;
char ctlpath[PATH_MAX + 1];
char buspath[PATH_MAX + 1];
int bfd, dfd, bus, address, i;
if (dev_info.udi_speed == 1) {
dev->dev.speed = USB_SPEED_LOW - 1;
+ dev->dev.speedmask = USB_SPEED_MASK_LOW;
} else {
dev->dev.speed = USB_SPEED_FULL - 1;
+ dev->dev.speedmask = USB_SPEED_MASK_FULL;
}
if (strncmp(dev_info.udi_product, "product", 7) != 0) {
return ret;
}
-static struct USBDeviceInfo usb_host_dev_info = {
- .product_desc = "USB Host Device",
- .qdev.name = "usb-host",
- .qdev.size = sizeof(USBHostDevice),
- .init = usb_host_initfn,
- .handle_packet = usb_generic_handle_packet,
- .handle_reset = usb_host_handle_reset,
-#if 0
- .handle_control = usb_host_handle_control,
- .handle_data = usb_host_handle_data,
-#endif
- .handle_destroy = usb_host_handle_destroy,
+static void usb_host_class_initfn(ObjectClass *klass, void *data)
+{
+ USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
+
+ uc->product_desc = "USB Host Device";
+ uc->init = usb_host_initfn;
+ uc->handle_reset = usb_host_handle_reset;
+ uc->handle_control = usb_host_handle_control;
+ uc->handle_data = usb_host_handle_data;
+ uc->handle_destroy = usb_host_handle_destroy;
+}
+
+static TypeInfo usb_host_dev_info = {
+ .name = "usb-host",
+ .parent = TYPE_USB_DEVICE,
+ .instance_size = sizeof(USBHostDevice),
+ .class_init = usb_host_class_initfn,
};
-static void usb_host_register_devices(void)
+static void usb_host_register_types(void)
{
- usb_qdev_register(&usb_host_dev_info);
+ type_register_static(&usb_host_dev_info);
}
-device_init(usb_host_register_devices)
+
+type_init(usb_host_register_types)
static int usb_host_scan(void *opaque, USBScanFunc *func)
{