Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
[safe/jmp/linux-2.6] / drivers / char / applicom.c
index b0bb71b..fe2cb2f 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
@@ -57,7 +58,6 @@
 #define PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN 0x0002
 #define PCI_DEVICE_ID_APPLICOM_PCI2000PFB     0x0003
 #endif
-#define MAX_PCI_DEVICE_NUM 3
 
 static char *applicom_pci_devnames[] = {
        "PCI board",
@@ -66,12 +66,9 @@ static char *applicom_pci_devnames[] = {
 };
 
 static struct pci_device_id applicom_pci_tbl[] = {
-       { PCI_VENDOR_ID_APPLICOM, PCI_DEVICE_ID_APPLICOM_PCIGENERIC,
-         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-       { PCI_VENDOR_ID_APPLICOM, PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN,
-         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-       { PCI_VENDOR_ID_APPLICOM, PCI_DEVICE_ID_APPLICOM_PCI2000PFB,
-         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+       { PCI_VDEVICE(APPLICOM, PCI_DEVICE_ID_APPLICOM_PCIGENERIC) },
+       { PCI_VDEVICE(APPLICOM, PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN) },
+       { PCI_VDEVICE(APPLICOM, PCI_DEVICE_ID_APPLICOM_PCI2000PFB) },
        { 0 }
 };
 MODULE_DEVICE_TABLE(pci, applicom_pci_tbl);
@@ -79,6 +76,7 @@ MODULE_DEVICE_TABLE(pci, applicom_pci_tbl);
 MODULE_AUTHOR("David Woodhouse & Applicom International");
 MODULE_DESCRIPTION("Driver for Applicom Profibus card");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_MISCDEV(AC_MINOR);
 
 MODULE_SUPPORTED_DEVICE("ac");
 
@@ -197,16 +195,13 @@ static int __init applicom_init(void)
 
        while ( (dev = pci_get_class(PCI_CLASS_OTHERS << 16, dev))) {
 
-               if (dev->vendor != PCI_VENDOR_ID_APPLICOM)
-                       continue;
-               
-               if (dev->device  > MAX_PCI_DEVICE_NUM || dev->device == 0)
+               if (!pci_match_id(applicom_pci_tbl, dev))
                        continue;
                
                if (pci_enable_device(dev))
                        return -EIO;
 
-               RamIO = ioremap(pci_resource_start(dev, 0), LEN_RAM_IO);
+               RamIO = ioremap_nocache(pci_resource_start(dev, 0), LEN_RAM_IO);
 
                if (!RamIO) {
                        printk(KERN_INFO "ac.o: Failed to ioremap PCI memory "
@@ -261,7 +256,7 @@ static int __init applicom_init(void)
        /* Now try the specified ISA cards */
 
        for (i = 0; i < MAX_ISA_BOARD; i++) {
-               RamIO = ioremap(mem + (LEN_RAM_IO * i), LEN_RAM_IO);
+               RamIO = ioremap_nocache(mem + (LEN_RAM_IO * i), LEN_RAM_IO);
 
                if (!RamIO) {
                        printk(KERN_INFO "ac.o: Failed to ioremap the ISA card's memory space (slot #%d)\n", i + 1);
@@ -485,7 +480,7 @@ static int do_ac_read(int IndexCard, char __user *buf,
                struct st_ram_io *st_loc, struct mailbox *mailbox)
 {
        void __iomem *from = apbs[IndexCard].RamIO + RAM_TO_PC;
-       unsigned char *to = (unsigned char *)&mailbox;
+       unsigned char *to = (unsigned char *)mailbox;
 #ifdef DEBUG
        int c;
 #endif
@@ -719,8 +714,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
        
        IndexCard = adgl->num_card-1;
         
-       if(cmd != 0 && cmd != 6 &&
-          ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) {
+       if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) {
                static int warncount = 10;
                if (warncount) {
                        printk( KERN_WARNING "APPLICOM driver IOCTL, bad board number %d\n",(int)IndexCard+1);
@@ -839,8 +833,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
                }
                break;
        default:
-               printk(KERN_INFO "APPLICOM driver ioctl, unknown function code %d\n",cmd) ;
-               ret = -EINVAL;
+               ret = -ENOTTY;
                break;
        }
        Dummy = readb(apbs[IndexCard].RamIO + VERS);