Change Sparc uses of pic_set_irq to pic_set_irq_new
[qemu] / usb-linux.c
index 420382b..50386ea 100644 (file)
@@ -26,7 +26,6 @@
 #if defined(__linux__)
 #include <dirent.h>
 #include <sys/ioctl.h>
-#include <linux/compiler.h>
 #include <linux/usbdevice_fs.h>
 #include <linux/version.h>
 
@@ -58,16 +57,8 @@ typedef struct USBHostDevice {
     int fd;
 } USBHostDevice;
 
-static void usb_host_handle_reset(USBDevice *dev, int destroy)
+static void usb_host_handle_reset(USBDevice *dev)
 {
-    USBHostDevice *s = (USBHostDevice *)dev;
-    
-    if (destroy) {
-        if (s->fd >= 0)
-            close(s->fd);
-        qemu_free(s);
-        return;
-    }
 #if 0
     USBHostDevice *s = (USBHostDevice *)dev;
     /* USBDEVFS_RESET, but not the first time as it has already be
@@ -76,6 +67,15 @@ static void usb_host_handle_reset(USBDevice *dev, int destroy)
 #endif
 } 
 
+static void usb_host_handle_destroy(USBDevice *dev)
+{
+    USBHostDevice *s = (USBHostDevice *)dev;
+
+    if (s->fd >= 0)
+        close(s->fd);
+    qemu_free(s);
+}
+
 static int usb_host_handle_control(USBDevice *dev,
                                    int request,
                                    int value,
@@ -113,22 +113,21 @@ static int usb_host_handle_control(USBDevice *dev,
    }
 }
 
-static int usb_host_handle_data(USBDevice *dev, int pid, 
-                                uint8_t devep,
-                                uint8_t *data, int len)
+static int usb_host_handle_data(USBDevice *dev, USBPacket *p)
 {
     USBHostDevice *s = (USBHostDevice *)dev;
     struct usbdevfs_bulktransfer bt;
     int ret;
+    uint8_t devep = p->devep;
 
     /* XXX: optimize and handle all data types by looking at the
        config descriptor */
-    if (pid == USB_TOKEN_IN)
+    if (p->pid == USB_TOKEN_IN)
         devep |= 0x80;
     bt.ep = devep;
-    bt.len = len;
+    bt.len = p->len;
     bt.timeout = 50;
-    bt.data = data;
+    bt.data = p->data;
     ret = ioctl(s->fd, USBDEVFS_BULK, &bt);
     if (ret < 0) {
         switch(errno) {
@@ -244,6 +243,7 @@ USBDevice *usb_host_device_open(const char *devname)
     dev->dev.handle_reset = usb_host_handle_reset;
     dev->dev.handle_control = usb_host_handle_control;
     dev->dev.handle_data = usb_host_handle_data;
+    dev->dev.handle_destroy = usb_host_handle_destroy;
 
     if (product_name[0] == '\0')
         snprintf(dev->dev.devname, sizeof(dev->dev.devname),