Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
[pandora-kernel.git] / drivers / char / rio / rio_linux.c
index c382df0..294e9cb 100644 (file)
@@ -418,8 +418,7 @@ static void rio_pollfunc(unsigned long data)
        func_enter();
 
        rio_interrupt(0, &p->RIOHosts[data]);
-       p->RIOHosts[data].timer.expires = jiffies + rio_poll;
-       add_timer(&p->RIOHosts[data].timer);
+       mod_timer(&p->RIOHosts[data].timer, jiffies + rio_poll);
 
        func_exit();
 }
@@ -1017,11 +1016,16 @@ static int __init rio_init(void)
                        rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
 
                        fix_rio_pci(pdev);
+
+                       p->RIOHosts[p->RIONumHosts].pdev = pdev;
+                       pci_dev_get(pdev);
+
                        p->RIOLastPCISearch = 0;
                        p->RIONumHosts++;
                        found++;
                } else {
                        iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
+                       p->RIOHosts[p->RIONumHosts].Caddr = NULL;
                }
        }
 
@@ -1066,11 +1070,15 @@ static int __init rio_init(void)
                            ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
                        rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
 
+                       p->RIOHosts[p->RIONumHosts].pdev = pdev;
+                       pci_dev_get(pdev);
+
                        p->RIOLastPCISearch = 0;
                        p->RIONumHosts++;
                        found++;
                } else {
                        iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
+                       p->RIOHosts[p->RIONumHosts].Caddr = NULL;
                }
 #else
                printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n");
@@ -1110,8 +1118,10 @@ static int __init rio_init(void)
                                }
                        }
 
-                       if (!okboard)
+                       if (!okboard) {
                                iounmap(hp->Caddr);
+                               hp->Caddr = NULL;
+                       }
                }
        }
 
@@ -1136,20 +1146,17 @@ static int __init rio_init(void)
                                rio_dprintk(RIO_DEBUG_INIT, "Enabling interrupts on rio card.\n");
                                hp->Mode |= RIO_PCI_INT_ENABLE;
                        } else
-                               hp->Mode &= !RIO_PCI_INT_ENABLE;
+                               hp->Mode &= ~RIO_PCI_INT_ENABLE;
                        rio_dprintk(RIO_DEBUG_INIT, "New Mode: %x\n", hp->Mode);
                        rio_start_card_running(hp);
                }
                /* Init the timer "always" to make sure that it can safely be
                   deleted when we unload... */
 
-               init_timer(&hp->timer);
+               setup_timer(&hp->timer, rio_pollfunc, i);
                if (!hp->Ivec) {
                        rio_dprintk(RIO_DEBUG_INIT, "Starting polling at %dj intervals.\n", rio_poll);
-                       hp->timer.data = i;
-                       hp->timer.function = rio_pollfunc;
-                       hp->timer.expires = jiffies + rio_poll;
-                       add_timer(&hp->timer);
+                       mod_timer(&hp->timer, jiffies + rio_poll);
                }
        }
 
@@ -1180,7 +1187,11 @@ static void __exit rio_exit(void)
                        rio_dprintk(RIO_DEBUG_INIT, "freed irq %d.\n", hp->Ivec);
                }
                /* It is safe/allowed to del_timer a non-active timer */
-               del_timer(&hp->timer);
+               del_timer_sync(&hp->timer);
+               if (hp->Caddr)
+                       iounmap(hp->Caddr);
+               if (hp->Type == RIO_PCI)
+                       pci_dev_put(hp->pdev);
        }
 
        if (misc_deregister(&rio_fw_device) < 0) {