fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / isdn / hysdn / boardergo.c
index e19a01a..a120649 100644 (file)
@@ -14,7 +14,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/signal.h>
 #include <linux/kernel.h>
 /* The cards interrupt handler. Called from system */
 /***************************************************/
 static irqreturn_t
-ergo_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+ergo_interrupt(int intno, void *dev_id)
 {
        hysdn_card *card = dev_id;      /* parameter from irq */
        tErgDpram *dpr;
-       ulong flags;
-       uchar volatile b;
+       unsigned long flags;
+       unsigned char volatile b;
 
        if (!card)
                return IRQ_NONE;                /* error -> spurious interrupt */
        if (!card->irq_enabled)
                return IRQ_NONE;                /* other device interrupting or irq switched off */
 
-       save_flags(flags);
-       cli();                  /* no further irqs allowed */
+       spin_lock_irqsave(&card->hysdn_lock, flags); /* no further irqs allowed */
 
        if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) {
-               restore_flags(flags);   /* restore old state */
+               spin_unlock_irqrestore(&card->hysdn_lock, flags);       /* restore old state */
                return IRQ_NONE;                /* no interrupt requested by E1 */
        }
        /* clear any pending ints on the board */
@@ -62,7 +60,7 @@ ergo_interrupt(int intno, void *dev_id, struct pt_regs *regs)
        /* start kernel task immediately after leaving all interrupts */
        if (!card->hw_lock)
                schedule_work(&card->irq_queue);
-       restore_flags(flags);
+       spin_unlock_irqrestore(&card->hysdn_lock, flags);
        return IRQ_HANDLED;
 }                              /* ergo_interrupt */
 
@@ -73,21 +71,21 @@ ergo_interrupt(int intno, void *dev_id, struct pt_regs *regs)
 /* may be queued from everywhere (interrupts included).                       */
 /******************************************************************************/
 static void
-ergo_irq_bh(hysdn_card * card)
+ergo_irq_bh(struct work_struct *ugli_api)
 {
+       hysdn_card * card = container_of(ugli_api, hysdn_card, irq_queue);
        tErgDpram *dpr;
        int again;
-       ulong flags;
+       unsigned long flags;
 
        if (card->state != CARD_STATE_RUN)
                return;         /* invalid call */
 
        dpr = card->dpram;      /* point to DPRAM */
 
-       save_flags(flags);
-       cli();
+       spin_lock_irqsave(&card->hysdn_lock, flags);
        if (card->hw_lock) {
-               restore_flags(flags);   /* hardware currently unavailable */
+               spin_unlock_irqrestore(&card->hysdn_lock, flags);       /* hardware currently unavailable */
                return;
        }
        card->hw_lock = 1;      /* we now lock the hardware */
@@ -121,7 +119,7 @@ ergo_irq_bh(hysdn_card * card)
                        card->hw_lock = 0;      /* free hardware again */
        } while (again);        /* until nothing more to do */
 
-       restore_flags(flags);
+       spin_unlock_irqrestore(&card->hysdn_lock, flags);
 }                              /* ergo_irq_bh */
 
 
@@ -131,15 +129,14 @@ ergo_irq_bh(hysdn_card * card)
 static void
 ergo_stopcard(hysdn_card * card)
 {
-       ulong flags;
-       uchar val;
+       unsigned long flags;
+       unsigned char val;
 
        hysdn_net_release(card);        /* first release the net device if existing */
 #ifdef CONFIG_HYSDN_CAPI
        hycapi_capi_stop(card);
 #endif /* CONFIG_HYSDN_CAPI */
-       save_flags(flags);
-       cli();
+       spin_lock_irqsave(&card->hysdn_lock, flags);
        val = bytein(card->iobase + PCI9050_INTR_REG);  /* get actual value */
        val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1);        /* mask irq */
        byteout(card->iobase + PCI9050_INTR_REG, val);
@@ -148,7 +145,7 @@ ergo_stopcard(hysdn_card * card)
        card->state = CARD_STATE_UNUSED;
        card->err_log_state = ERRLOG_STATE_OFF;         /* currently no log active */
 
-       restore_flags(flags);
+       spin_unlock_irqrestore(&card->hysdn_lock, flags);
 }                              /* ergo_stopcard */
 
 /**************************************************************************/
@@ -157,18 +154,17 @@ ergo_stopcard(hysdn_card * card)
 static void
 ergo_set_errlog_state(hysdn_card * card, int on)
 {
-       ulong flags;
+       unsigned long flags;
 
        if (card->state != CARD_STATE_RUN) {
                card->err_log_state = ERRLOG_STATE_OFF;         /* must be off */
                return;
        }
-       save_flags(flags);
-       cli();
+       spin_lock_irqsave(&card->hysdn_lock, flags);
 
        if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) ||
            ((card->err_log_state == ERRLOG_STATE_ON) && on)) {
-               restore_flags(flags);
+               spin_unlock_irqrestore(&card->hysdn_lock, flags);
                return;         /* nothing to do */
        }
        if (on)
@@ -176,7 +172,7 @@ ergo_set_errlog_state(hysdn_card * card, int on)
        else
                card->err_log_state = ERRLOG_STATE_STOP;        /* request stop */
 
-       restore_flags(flags);
+       spin_unlock_irqrestore(&card->hysdn_lock, flags);
        schedule_work(&card->irq_queue);
 }                              /* ergo_set_errlog_state */
 
@@ -217,9 +213,10 @@ ergo_testram(hysdn_card * card)
 /* Negative return values are interpreted as errors.                         */
 /*****************************************************************************/
 static int
-ergo_writebootimg(struct HYSDN_CARD *card, uchar * buf, ulong offs)
+ergo_writebootimg(struct HYSDN_CARD *card, unsigned char *buf,
+                       unsigned long offs)
 {
-       uchar *dst;
+       unsigned char *dst;
        tErgDpram *dpram;
        int cnt = (BOOT_IMG_SIZE >> 2);         /* number of words to move and swap (byte order!) */
        
@@ -264,14 +261,14 @@ ergo_writebootimg(struct HYSDN_CARD *card, uchar * buf, ulong offs)
 /* case of errors a negative error value is returned.                           */
 /********************************************************************************/
 static int
-ergo_writebootseq(struct HYSDN_CARD *card, uchar * buf, int len)
+ergo_writebootseq(struct HYSDN_CARD *card, unsigned char *buf, int len)
 {
        tDpramBootSpooler *sp = (tDpramBootSpooler *) card->dpram;
-       uchar *dst;
-       uchar buflen;
+       unsigned char *dst;
+       unsigned char buflen;
        int nr_write;
-       uchar tmp_rdptr;
-       uchar wr_mirror;
+       unsigned char tmp_rdptr;
+       unsigned char wr_mirror;
        int i;
 
        if (card->debug_flags & LOG_POF_CARD)
@@ -330,7 +327,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
 {
        tErgDpram *dpr = card->dpram;   /* pointer to DPRAM structure */
        int timecnt = 10000 / 50;       /* timeout is 10 secs max. */
-       ulong flags;
+       unsigned long flags;
        int msg_size;
        int i;
 
@@ -345,7 +342,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
                        if ((dpr->ToPcChannel != CHAN_SYSTEM) ||
                            (dpr->ToPcSize < MIN_RDY_MSG_SIZE) ||
                            (dpr->ToPcSize > MAX_RDY_MSG_SIZE) ||
-                           ((*(ulong *) dpr->ToPcBuf) != RDY_MAGIC))
+                           ((*(unsigned long *) dpr->ToPcBuf) != RDY_MAGIC))
                                break;  /* an error occurred */
 
                        /* Check for additional data delivered during SysReady */
@@ -356,8 +353,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
 
                        if (card->debug_flags & LOG_POF_RECORD)
                                hysdn_addlog(card, "ERGO: pof boot success");
-                       save_flags(flags);
-                       cli();
+                       spin_lock_irqsave(&card->hysdn_lock, flags);
 
                        card->state = CARD_STATE_RUN;   /* now card is running */
                        /* enable the cards interrupt */
@@ -370,7 +366,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
                        dpr->ToHyInt = 1;
                        dpr->ToPcInt = 1;       /* interrupt to E1 for all cards */
 
-                       restore_flags(flags);
+                       spin_unlock_irqrestore(&card->hysdn_lock, flags);
                        if ((hynet_enable & (1 << card->myid)) 
                            && (i = hysdn_net_create(card))) 
                        {
@@ -408,7 +404,7 @@ ergo_releasehardware(hysdn_card * card)
        free_irq(card->irq, card);      /* release interrupt */
        release_region(card->iobase + PCI9050_INTR_REG, 1);     /* release all io ports */
        release_region(card->iobase + PCI9050_USER_IO, 1);
-       vfree(card->dpram);
+       iounmap(card->dpram);
        card->dpram = NULL;     /* release shared mem */
 }                              /* ergo_releasehardware */
 
@@ -435,7 +431,7 @@ ergo_inithardware(hysdn_card * card)
        }
 
        ergo_stopcard(card);    /* disable interrupts */
-       if (request_irq(card->irq, ergo_interrupt, SA_SHIRQ, "HYSDN", card)) {
+       if (request_irq(card->irq, ergo_interrupt, IRQF_SHARED, "HYSDN", card)) {
                ergo_releasehardware(card); /* return the acquired hardware */
                return (-1);
        }
@@ -447,7 +443,8 @@ ergo_inithardware(hysdn_card * card)
        card->writebootseq = ergo_writebootseq;
        card->waitpofready = ergo_waitpofready;
        card->set_errlog_state = ergo_set_errlog_state;
-       INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card);
+       INIT_WORK(&card->irq_queue, ergo_irq_bh);
+       card->hysdn_lock = SPIN_LOCK_UNLOCKED;
 
        return (0);
 }                              /* ergo_inithardware */