]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/ip2/ip2main.c
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[linux-2.6-omap-h63xx.git] / drivers / char / ip2 / ip2main.c
index 6005b52257725ed251a849184b8e56efc5f98133..b1d6cad84282e3960f974c9d41df0a4ed8c64500 100644 (file)
@@ -153,9 +153,6 @@ static char *pcVersion = "1.2.14";
 static char *pcDriver_name   = "ip2";
 static char *pcIpl              = "ip2ipl";
 
-/* Serial subtype definitions */
-#define SERIAL_TYPE_NORMAL    1
-
 // cheezy kludge or genius - you decide?
 int ip2_loadmain(int *, int *, unsigned char *, int);
 static unsigned char *Fip_firmware;
@@ -411,8 +408,8 @@ cleanup_module(void)
                        iiResetDelay( i2BoardPtrTable[i] );
                        /* free io addresses and Tibet */
                        release_region( ip2config.addr[i], 8 );
-                       class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i));
-                       class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
+                       device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i));
+                       device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
                }
                /* Disable and remove interrupt handler. */
                if ( (ip2config.irq[i] > 0) && have_requested_irq(ip2config.irq[i]) ) { 
@@ -500,7 +497,6 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
 {
        int i, j, box;
        int err = 0;
-       int status = 0;
        static int loaded;
        i2eBordStrPtr pB = NULL;
        int rc = -1;
@@ -588,6 +584,8 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                case PCI:
 #ifdef CONFIG_PCI
                        {
+                               int status;
+
                                pci_dev_i = pci_get_device(PCI_VENDOR_ID_COMPUTONE,
                                                          PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i);
                                if (pci_dev_i != NULL) {
@@ -618,11 +616,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                                        ip2config.irq[i] = pci_dev_i->irq;
                                } else {        // ann error
                                        ip2config.addr[i] = 0;
-                                       if (status == PCIBIOS_DEVICE_NOT_FOUND) {
-                                               printk( KERN_ERR "IP2: PCI board %d not found\n", i );
-                                       } else {
-                                               printk( KERN_ERR "IP2: PCI error 0x%x \n", status );
-                                       }
+                                       printk(KERN_ERR "IP2: PCI board %d not found\n", i);
                                } 
                        }
 #else
@@ -645,10 +639,9 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
 
        for ( i = 0; i < IP2_MAX_BOARDS; ++i ) {
                if ( ip2config.addr[i] ) {
-                       pB = kmalloc( sizeof(i2eBordStr), GFP_KERNEL);
-                       if ( pB != NULL ) {
+                       pB = kzalloc(sizeof(i2eBordStr), GFP_KERNEL);
+                       if (pB) {
                                i2BoardPtrTable[i] = pB;
-                               memset( pB, 0, sizeof(i2eBordStr) );
                                iiSetAddress( pB, ip2config.addr[i], ii2DelayTimer );
                                iiReset( pB );
                        } else {
@@ -717,12 +710,12 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                        }
 
                        if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
-                               class_device_create(ip2_class, NULL,
+                               device_create(ip2_class, NULL,
                                                MKDEV(IP2_IPL_MAJOR, 4 * i),
-                                               NULL, "ipl%d", i);
-                               class_device_create(ip2_class, NULL,
+                                               "ipl%d", i);
+                               device_create(ip2_class, NULL,
                                                MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
-                                               NULL, "stat%d", i);
+                                               "stat%d", i);
 
                            for ( box = 0; box < ABS_MAX_BOXES; ++box )
                            {
@@ -756,7 +749,7 @@ retry:
                                        continue;
                                rc = request_irq( ip2config.irq[i], ip2_interrupt,
                                        IP2_SA_FLAGS | (ip2config.type[i] == PCI ? IRQF_SHARED : 0),
-                                       pcName, (void *)&pcName);
+                                       pcName, i2BoardPtrTable[i]);
                                if (rc) {
                                        printk(KERN_ERR "IP2: an request_irq failed: error %d\n",rc);
                                        ip2config.irq[i] = CIR_POLL;
@@ -1170,12 +1163,37 @@ ip2_interrupt_bh(struct work_struct *work)
 /*                                                                            */
 /*                                                                            */
 /******************************************************************************/
-static irqreturn_t
-ip2_interrupt(int irq, void *dev_id)
+static void
+ip2_irq_work(i2eBordStrPtr pB)
+{
+#ifdef USE_IQI
+       if (NO_MAIL_HERE != ( pB->i2eStartMail = iiGetMail(pB))) {
+//             Disable his interrupt (will be enabled when serviced)
+//             This is mostly to protect from reentrancy.
+               iiDisableMailIrq(pB);
+
+//             Park the board on the immediate queue for processing.
+               schedule_work(&pB->tqueue_interrupt);
+
+//             Make sure the immediate queue is flagged to fire.
+       }
+#else
+
+//     We are using immediate servicing here.  This sucks and can
+//     cause all sorts of havoc with ppp and others.  The failsafe
+//     check on iiSendPendingMail could also throw a hairball.
+
+       i2ServiceBoard( pB );
+
+#endif /* USE_IQI */
+}
+
+static void
+ip2_polled_interrupt(void)
 {
        int i;
        i2eBordStrPtr  pB;
-       int handled = 0;
+       const int irq = 0;
 
        ip2trace (ITRC_NO_PORT, ITRC_INTR, 99, 1, irq );
 
@@ -1187,32 +1205,28 @@ ip2_interrupt(int irq, void *dev_id)
 //                     IRQ = 0 for polled boards, we won't poll "IRQ" boards
 
                if ( pB && (pB->i2eUsingIrq == irq) ) {
-                       handled = 1;
-#ifdef USE_IQI
+                       ip2_irq_work(pB);
+               }
+       }
 
-                   if (NO_MAIL_HERE != ( pB->i2eStartMail = iiGetMail(pB))) {
-//                     Disable his interrupt (will be enabled when serviced)
-//                     This is mostly to protect from reentrancy.
-                       iiDisableMailIrq(pB);
+       ++irq_counter;
 
-//                     Park the board on the immediate queue for processing.
-                       schedule_work(&pB->tqueue_interrupt);
+       ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 );
+}
 
-//                     Make sure the immediate queue is flagged to fire.
-                   }
-#else
-//             We are using immediate servicing here.  This sucks and can
-//             cause all sorts of havoc with ppp and others.  The failsafe
-//             check on iiSendPendingMail could also throw a hairball.
-                       i2ServiceBoard( pB );
-#endif /* USE_IQI */
-               }
-       }
+static irqreturn_t
+ip2_interrupt(int irq, void *dev_id)
+{
+       i2eBordStrPtr pB = dev_id;
+
+       ip2trace (ITRC_NO_PORT, ITRC_INTR, 99, 1, pB->i2eUsingIrq );
+
+       ip2_irq_work(pB);
 
        ++irq_counter;
 
        ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 );
-       return IRQ_RETVAL(handled);
+       return IRQ_HANDLED;
 }
 
 /******************************************************************************/
@@ -1234,8 +1248,8 @@ ip2_poll(unsigned long arg)
 
        // Just polled boards, IRQ = 0 will hit all non-interrupt boards.
        // It will NOT poll boards handled by hard interrupts.
-       // The issue of queued BH interrups is handled in ip2_interrupt().
-       ip2_interrupt(0, NULL);
+       // The issue of queued BH interrupts is handled in ip2_interrupt().
+       ip2_polled_interrupt();
 
        PollTimer.expires = POLL_TIMEOUT;
        add_timer( &PollTimer );