]> Pileus Git - ~andy/linux/blobdiff - drivers/usb/misc/sisusbvga/sisusb.c
USB: sis FB driver: *_ioctl32_conversion functions do not exist in recent kernels
[~andy/linux] / drivers / usb / misc / sisusbvga / sisusb.c
index 9f37ba44c132d1cbbabb41f235b320dd155b92b3..8832a72bb1fb35a10ce6919a8cc9d048fe48abb8 100644 (file)
@@ -32,7 +32,7 @@
  * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * Author:     Thomas Winischhofer <thomas@winischhofer.net>
+ * Author:     Thomas Winischhofer <thomas@winischhofer.net>
  *
  */
 
@@ -962,12 +962,12 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
                           packet.address = 0x00000194;
                           packet.data    = addr;
                           ret = sisusb_send_bridge_packet(sisusb, 10,
-                                                               &packet, 0);
+                                                               &packet, 0);
                           packet.header  = 0x001f;
                           packet.address = 0x00000190;
                           packet.data    = (length & ~3);
                           ret |= sisusb_send_bridge_packet(sisusb, 10,
-                                                               &packet, 0);
+                                                               &packet, 0);
                           if (sisusb->flagb0 != 0x16) {
                                packet.header  = 0x001f;
                                packet.address = 0x00000180;
@@ -1003,23 +1003,17 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
                        if (ret) {
                                msgcount++;
                                if (msgcount < 500)
-                                       printk(KERN_ERR
-                                               "sisusbvga[%d]: Wrote %zd of "
-                                               "%d bytes, error %d\n",
-                                               sisusb->minor, *bytes_written,
-                                               length, ret);
+                                       dev_err(&sisusb->sisusb_dev->dev, "Wrote %zd of %d bytes, error %d\n",
+                                               *bytes_written, length, ret);
                                else if (msgcount == 500)
-                                       printk(KERN_ERR
-                                               "sisusbvga[%d]: Too many errors"
-                                               ", logging stopped\n",
-                                               sisusb->minor);
+                                       dev_err(&sisusb->sisusb_dev->dev, "Too many errors, logging stopped\n");
                        }
                        addr += (*bytes_written);
                        length -= (*bytes_written);
            }
 
            if (ret)
-               break;
+               break;
 
        }
 
@@ -1261,51 +1255,10 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
                                addr += 4;
                                length -= 4;
                        }
-#if 0          /* That does not work, as EP 2 is an OUT EP! */
-               default:
-                       CLEARPACKET(&packet);
-                       packet.header  = 0x001f;
-                       packet.address = 0x000001a0;
-                       packet.data    = 0x00000006;
-                       ret |= sisusb_send_bridge_packet(sisusb, 10,
-                                                               &packet, 0);
-                       packet.header  = 0x001f;
-                       packet.address = 0x000001b0;
-                       packet.data    = (length & ~3) | 0x40000000;
-                       ret |= sisusb_send_bridge_packet(sisusb, 10,
-                                                               &packet, 0);
-                       packet.header  = 0x001f;
-                       packet.address = 0x000001b4;
-                       packet.data    = addr;
-                       ret |= sisusb_send_bridge_packet(sisusb, 10,
-                                                               &packet, 0);
-                       packet.header  = 0x001f;
-                       packet.address = 0x000001a4;
-                       packet.data    = 0x00000001;
-                       ret |= sisusb_send_bridge_packet(sisusb, 10,
-                                                               &packet, 0);
-                       if (userbuffer) {
-                               ret |= sisusb_recv_bulk_msg(sisusb,
-                                                       SISUSB_EP_GFX_BULK_IN,
-                                                       (length & ~3),
-                                                       NULL, userbuffer,
-                                                       bytes_read, 0);
-                               if (!ret) userbuffer += (*bytes_read);
-                       } else {
-                               ret |= sisusb_recv_bulk_msg(sisusb,
-                                                       SISUSB_EP_GFX_BULK_IN,
-                                                       (length & ~3),
-                                                       kernbuffer, NULL,
-                                                       bytes_read, 0);
-                               if (!ret) kernbuffer += (*bytes_read);
-                       }
-                       addr += (*bytes_read);
-                       length -= (*bytes_read);
-#endif
            }
 
            if (ret)
-               break;
+               break;
        }
 
        return ret;
@@ -1401,22 +1354,6 @@ sisusb_readb(struct sisusb_usb_data *sisusb, u32 adr, u8 *data)
        return(sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM, adr, data));
 }
 
-#if 0
-
-int
-sisusb_writew(struct sisusb_usb_data *sisusb, u32 adr, u16 data)
-{
-       return(sisusb_write_memio_word(sisusb, SISUSB_TYPE_MEM, adr, data));
-}
-
-int
-sisusb_readw(struct sisusb_usb_data *sisusb, u32 adr, u16 *data)
-{
-       return(sisusb_read_memio_word(sisusb, SISUSB_TYPE_MEM, adr, data));
-}
-
-#endif  /*  0  */
-
 int
 sisusb_copy_memory(struct sisusb_usb_data *sisusb, char *src,
                        u32 dest, int length, size_t *bytes_written)
@@ -1446,10 +1383,10 @@ sisusb_testreadwrite(struct sisusb_usb_data *sisusb)
     sisusb_copy_memory(sisusb, srcbuffer, sisusb->vrambase, 7, &dummy);
 
     for(i = 1; i <= 7; i++) {
-        printk(KERN_DEBUG "sisusb: rwtest %d bytes\n", i);
+        dev_dbg(&sisusb->sisusb_dev->dev, "sisusb: rwtest %d bytes\n", i);
        sisusb_read_memory(sisusb, destbuffer, sisusb->vrambase, i, &dummy);
        for(j = 0; j < i; j++) {
-            printk(KERN_DEBUG "sisusb: rwtest read[%d] = %x\n", j, destbuffer[j]);
+            dev_dbg(&sisusb->sisusb_dev->dev, "rwtest read[%d] = %x\n", j, destbuffer[j]);
        }
     }
 }
@@ -1533,9 +1470,9 @@ sisusb_clear_vram(struct sisusb_usb_data *sisusb, u32 address, int length)
 #define SETIREGAND(r,i,a)      sisusb_setidxregand(sisusb, r, i, a)
 #define SETIREGANDOR(r,i,a,o)  sisusb_setidxregandor(sisusb, r, i, a, o)
 #define READL(a,d)     sisusb_read_memio_long(sisusb, SISUSB_TYPE_MEM, a, d)
-#define WRITEL(a,d)    sisusb_write_memio_long(sisusb, SISUSB_TYPE_MEM, a, d)
+#define WRITEL(a,d)    sisusb_write_memio_long(sisusb, SISUSB_TYPE_MEM, a, d)
 #define READB(a,d)     sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM, a, d)
-#define WRITEB(a,d)    sisusb_write_memio_byte(sisusb, SISUSB_TYPE_MEM, a, d)
+#define WRITEB(a,d)    sisusb_write_memio_byte(sisusb, SISUSB_TYPE_MEM, a, d)
 
 static int
 sisusb_triggersr16(struct sisusb_usb_data *sisusb, u8 ramtype)
@@ -2008,7 +1945,7 @@ sisusb_set_default_mode(struct sisusb_usb_data *sisusb, int touchengines)
                SETIREG(SISSR, 0x26, 0x00);
        }
 
-       SETIREG(SISCR, 0x34, 0x44);     /* we just set std mode #44 */
+       SETIREG(SISCR, 0x34, 0x44);     /* we just set std mode #44 */
 
        return ret;
 }
@@ -2168,17 +2105,12 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb)
                if (ramtype <= 1) {
                        ret |= sisusb_get_sdram_size(sisusb, &iret, bw, chab);
                        if (iret) {
-                               printk(KERN_ERR "sisusbvga[%d]: RAM size "
-                                       "detection failed, "
-                                       "assuming 8MB video RAM\n",
-                                       sisusb->minor);
+                               dev_err(&sisusb->sisusb_dev->dev,"RAM size detection failed, assuming 8MB video RAM\n");
                                ret |= SETIREG(SISSR,0x14,0x31);
                                /* TODO */
                        }
                } else {
-                       printk(KERN_ERR "sisusbvga[%d]: DDR RAM device found, "
-                                       "assuming 8MB video RAM\n",
-                                       sisusb->minor);
+                       dev_err(&sisusb->sisusb_dev->dev, "DDR RAM device found, assuming 8MB video RAM\n");
                        ret |= SETIREG(SISSR,0x14,0x31);
                        /* *** TODO *** */
                }
@@ -2249,8 +2181,7 @@ sisusb_get_ramconfig(struct sisusb_usb_data *sisusb)
                break;
        }
 
-       printk(KERN_INFO "sisusbvga[%d]: %dMB %s %s, bus width %d\n",
-                       sisusb->minor, (sisusb->vramsize >> 20), ramtypetext1,
+       dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %s, bus width %d\n", (sisusb->vramsize >> 20), ramtypetext1,
                        ramtypetext2[ramtype], bw);
 }
 
@@ -2509,11 +2440,8 @@ sisusb_open(struct inode *inode, struct file *file)
        struct usb_interface *interface;
        int subminor = iminor(inode);
 
-       if (!(interface = usb_find_interface(&sisusb_driver, subminor))) {
-               printk(KERN_ERR "sisusb[%d]: Failed to find interface\n",
-                               subminor);
+       if (!(interface = usb_find_interface(&sisusb_driver, subminor)))
                return -ENODEV;
-       }
 
        if (!(sisusb = usb_get_intfdata(interface)))
                return -ENODEV;
@@ -2534,18 +2462,12 @@ sisusb_open(struct inode *inode, struct file *file)
                if (sisusb->sisusb_dev->speed == USB_SPEED_HIGH) {
                        if (sisusb_init_gfxdevice(sisusb, 0)) {
                                mutex_unlock(&sisusb->lock);
-                               printk(KERN_ERR
-                                       "sisusbvga[%d]: Failed to initialize "
-                                       "device\n",
-                                       sisusb->minor);
+                               dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n");
                                return -EIO;
                        }
                } else {
                        mutex_unlock(&sisusb->lock);
-                       printk(KERN_ERR
-                               "sisusbvga[%d]: Device not attached to "
-                               "USB 2.0 hub\n",
-                               sisusb->minor);
+                       dev_err(&sisusb->sisusb_dev->dev, "Device not attached to USB 2.0 hub\n");
                        return -EIO;
                }
        }
@@ -2586,7 +2508,6 @@ static int
 sisusb_release(struct inode *inode, struct file *file)
 {
        struct sisusb_usb_data *sisusb;
-       int myminor;
 
        if (!(sisusb = (struct sisusb_usb_data *)file->private_data))
                return -ENODEV;
@@ -2599,8 +2520,6 @@ sisusb_release(struct inode *inode, struct file *file)
                        sisusb_kill_all_busy(sisusb);
        }
 
-       myminor = sisusb->minor;
-
        sisusb->isopen = 0;
        file->private_data = NULL;
 
@@ -2942,7 +2861,7 @@ static int
 sisusb_handle_command(struct sisusb_usb_data *sisusb, struct sisusb_command *y,
                                                        unsigned long arg)
 {
-       int     retval, port, length;
+       int     retval, port, length;
        u32     address;
 
        /* All our commands require the device
@@ -3065,12 +2984,12 @@ sisusb_handle_command(struct sisusb_usb_data *sisusb, struct sisusb_command *y,
 
 static int
 sisusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
-                                                       unsigned long arg)
+                                                       unsigned long arg)
 {
        struct sisusb_usb_data *sisusb;
        struct sisusb_info x;
        struct sisusb_command y;
-       int     retval = 0;
+       int     retval = 0;
        u32 __user *argp = (u32 __user *)arg;
 
        if (!(sisusb = (struct sisusb_usb_data *)file->private_data))
@@ -3095,7 +3014,7 @@ sisusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 
                case SISUSB_GET_CONFIG:
 
-                       x.sisusb_id         = SISUSB_ID;
+                       x.sisusb_id         = SISUSB_ID;
                        x.sisusb_version    = SISUSB_VERSION;
                        x.sisusb_revision   = SISUSB_REVISION;
                        x.sisusb_patchlevel = SISUSB_PATCHLEVEL;
@@ -3164,7 +3083,7 @@ static const struct file_operations usb_sisusb_fops = {
        .release =      sisusb_release,
        .read =         sisusb_read,
        .write =        sisusb_write,
-       .llseek =       sisusb_lseek,
+       .llseek =       sisusb_lseek,
 #ifdef SISUSB_NEW_CONFIG_COMPAT
        .compat_ioctl = sisusb_compat_ioctl,
 #endif
@@ -3183,17 +3102,13 @@ static int sisusb_probe(struct usb_interface *intf,
        struct usb_device *dev = interface_to_usbdev(intf);
        struct sisusb_usb_data *sisusb;
        int retval = 0, i;
-       const char *memfail =
-               KERN_ERR
-               "sisusbvga[%d]: Failed to allocate memory for %s buffer\n";
 
-       printk(KERN_INFO "sisusb: USB2VGA dongle found at address %d\n",
+       dev_info(&dev->dev, "USB2VGA dongle found at address %d\n",
                dev->devnum);
 
        /* Allocate memory for our private */
        if (!(sisusb = kzalloc(sizeof(*sisusb), GFP_KERNEL))) {
-               printk(KERN_ERR
-                       "sisusb: Failed to allocate memory for private data\n");
+               dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for private data\n");
                return -ENOMEM;
        }
        kref_init(&sisusb->kref);
@@ -3202,8 +3117,7 @@ static int sisusb_probe(struct usb_interface *intf,
 
        /* Register device */
        if ((retval = usb_register_dev(intf, &usb_sisusb_class))) {
-               printk(KERN_ERR
-                       "sisusb: Failed to get a minor for device %d\n",
+               dev_err(&sisusb->sisusb_dev->dev, "Failed to get a minor for device %d\n",
                        dev->devnum);
                retval = -ENODEV;
                goto error_1;
@@ -3221,7 +3135,7 @@ static int sisusb_probe(struct usb_interface *intf,
        sisusb->ibufsize = SISUSB_IBUF_SIZE;
        if (!(sisusb->ibuf = usb_buffer_alloc(dev, SISUSB_IBUF_SIZE,
                                        GFP_KERNEL, &sisusb->transfer_dma_in))) {
-               printk(memfail, "input", sisusb->minor);
+               dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for input buffer");
                retval = -ENOMEM;
                goto error_2;
        }
@@ -3233,7 +3147,7 @@ static int sisusb_probe(struct usb_interface *intf,
                                        GFP_KERNEL,
                                        &sisusb->transfer_dma_out[i]))) {
                        if (i == 0) {
-                               printk(memfail, "output", sisusb->minor);
+                               dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for output buffer\n");
                                retval = -ENOMEM;
                                goto error_3;
                        }
@@ -3245,9 +3159,7 @@ static int sisusb_probe(struct usb_interface *intf,
 
        /* Allocate URBs */
        if (!(sisusb->sisurbin = usb_alloc_urb(0, GFP_KERNEL))) {
-               printk(KERN_ERR
-                       "sisusbvga[%d]: Failed to allocate URBs\n",
-                       sisusb->minor);
+               dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate URBs\n");
                retval = -ENOMEM;
                goto error_3;
        }
@@ -3255,9 +3167,7 @@ static int sisusb_probe(struct usb_interface *intf,
 
        for (i = 0; i < sisusb->numobufs; i++) {
                if (!(sisusb->sisurbout[i] = usb_alloc_urb(0, GFP_KERNEL))) {
-                       printk(KERN_ERR
-                               "sisusbvga[%d]: Failed to allocate URBs\n",
-                               sisusb->minor);
+                       dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate URBs\n");
                        retval = -ENOMEM;
                        goto error_4;
                }
@@ -3266,15 +3176,12 @@ static int sisusb_probe(struct usb_interface *intf,
                sisusb->urbstatus[i] = 0;
        }
 
-       printk(KERN_INFO "sisusbvga[%d]: Allocated %d output buffers\n",
-                                       sisusb->minor, sisusb->numobufs);
+       dev_info(&sisusb->sisusb_dev->dev, "Allocated %d output buffers\n", sisusb->numobufs);
 
 #ifdef INCL_SISUSB_CON
        /* Allocate our SiS_Pr */
        if (!(sisusb->SiS_Pr = kmalloc(sizeof(struct SiS_Private), GFP_KERNEL))) {
-               printk(KERN_ERR
-                       "sisusbvga[%d]: Failed to allocate SiS_Pr\n",
-                       sisusb->minor);
+               dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate SiS_Pr\n");
        }
 #endif
 
@@ -3288,23 +3195,6 @@ static int sisusb_probe(struct usb_interface *intf,
 
        sisusb->present = 1;
 
-#ifdef SISUSB_OLD_CONFIG_COMPAT
-       {
-       int ret;
-       /* Our ioctls are all "32/64bit compatible" */
-       ret =  register_ioctl32_conversion(SISUSB_GET_CONFIG_SIZE, NULL);
-       ret |= register_ioctl32_conversion(SISUSB_GET_CONFIG,      NULL);
-       ret |= register_ioctl32_conversion(SISUSB_COMMAND,         NULL);
-       if (ret)
-               printk(KERN_ERR
-                       "sisusbvga[%d]: Error registering ioctl32 "
-                       "translations\n",
-                       sisusb->minor);
-       else
-               sisusb->ioctl32registered = 1;
-       }
-#endif
-
        if (dev->speed == USB_SPEED_HIGH) {
                int initscreen = 1;
 #ifdef INCL_SISUSB_CON
@@ -3315,23 +3205,17 @@ static int sisusb_probe(struct usb_interface *intf,
                        initscreen = 0;
 #endif
                if (sisusb_init_gfxdevice(sisusb, initscreen))
-                       printk(KERN_ERR
-                               "sisusbvga[%d]: Failed to early "
-                               "initialize device\n",
-                               sisusb->minor);
+                       dev_err(&sisusb->sisusb_dev->dev, "Failed to early initialize device\n");
 
        } else
-               printk(KERN_INFO
-                       "sisusbvga[%d]: Not attached to USB 2.0 hub, "
-                       "deferring init\n",
-                       sisusb->minor);
+               dev_info(&sisusb->sisusb_dev->dev, "Not attached to USB 2.0 hub, deferring init\n");
 
        sisusb->ready = 1;
 
 #ifdef SISUSBENDIANTEST
-       printk(KERN_DEBUG "sisusb: *** RWTEST ***\n");
+       dev_dbg(&sisusb->sisusb_dev->dev, "*** RWTEST ***\n");
        sisusb_testreadwrite(sisusb);
-       printk(KERN_DEBUG "sisusb: *** RWTEST END ***\n");
+       dev_dbg(&sisusb->sisusb_dev->dev, "*** RWTEST END ***\n");
 #endif
 
 #ifdef INCL_SISUSB_CON
@@ -3354,7 +3238,6 @@ error_1:
 static void sisusb_disconnect(struct usb_interface *intf)
 {
        struct sisusb_usb_data *sisusb;
-       int minor;
 
        /* This should *not* happen */
        if (!(sisusb = usb_get_intfdata(intf)))
@@ -3364,8 +3247,6 @@ static void sisusb_disconnect(struct usb_interface *intf)
        sisusb_console_exit(sisusb);
 #endif
 
-       minor = sisusb->minor;
-
        usb_deregister_dev(intf, &usb_sisusb_class);
 
        mutex_lock(&sisusb->lock);
@@ -3376,22 +3257,6 @@ static void sisusb_disconnect(struct usb_interface *intf)
 
        usb_set_intfdata(intf, NULL);
 
-#ifdef SISUSB_OLD_CONFIG_COMPAT
-       if (sisusb->ioctl32registered) {
-               int ret;
-               sisusb->ioctl32registered = 0;
-               ret =  unregister_ioctl32_conversion(SISUSB_GET_CONFIG_SIZE);
-               ret |= unregister_ioctl32_conversion(SISUSB_GET_CONFIG);
-               ret |= unregister_ioctl32_conversion(SISUSB_COMMAND);
-               if (ret) {
-                       printk(KERN_ERR
-                               "sisusbvga[%d]: Error unregistering "
-                               "ioctl32 translations\n",
-                               minor);
-               }
-       }
-#endif
-
        sisusb->present = 0;
        sisusb->ready = 0;
 
@@ -3400,10 +3265,11 @@ static void sisusb_disconnect(struct usb_interface *intf)
        /* decrement our usage count */
        kref_put(&sisusb->kref, sisusb_delete);
 
-       printk(KERN_INFO "sisusbvga[%d]: Disconnected\n", minor);
+       dev_info(&sisusb->sisusb_dev->dev, "Disconnected\n");
 }
 
 static struct usb_device_id sisusb_table [] = {
+       { USB_DEVICE(0x0711, 0x0550) },
        { USB_DEVICE(0x0711, 0x0900) },
        { USB_DEVICE(0x0711, 0x0901) },
        { USB_DEVICE(0x0711, 0x0902) },
@@ -3423,22 +3289,12 @@ static struct usb_driver sisusb_driver = {
 
 static int __init usb_sisusb_init(void)
 {
-       int retval;
 
 #ifdef INCL_SISUSB_CON
        sisusb_init_concode();
 #endif
 
-       if (!(retval = usb_register(&sisusb_driver))) {
-
-               printk(KERN_INFO "sisusb: Driver version %d.%d.%d\n",
-                       SISUSB_VERSION, SISUSB_REVISION, SISUSB_PATCHLEVEL);
-               printk(KERN_INFO
-                       "sisusb: Copyright (C) 2005 Thomas Winischhofer\n");
-
-       }
-
-       return retval;
+       return usb_register(&sisusb_driver);
 }
 
 static void __exit usb_sisusb_exit(void)