]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/pcan_dongle.c
Update of IRQ handlers to conform to arguments from new function prototype (Linux...
[lincan.git] / lincan / src / pcan_dongle.c
index 10b6efa782aa74def0fe4dc8de20648ebf93959e..ca7ef798152fc3a19934464f769336f5ed47ce0c 100644 (file)
 #define ECR_PORT_SIZE            1  // size of the associated ECR register
 #define DNG_DEFAULT_COUNT        4  // count of defaults for init
 
-typedef void (*PARPORT_IRQ_HANLDER)(int, void *, struct pt_regs *);
+typedef void (*PARPORT_IRQ_HANLDER)(CAN_IRQ_HANDLER_ARGS(irq_number, dev_id));
 
 /****************************************************************************/
 // GLOBALS
-spinlock_t pcan_lock = SPIN_LOCK_UNLOCKED;
+CAN_DEFINE_SPINLOCK(pcan_lock);
 
 /****************************************************************************/
 // LOCALS
@@ -158,14 +158,9 @@ static u8 pcan_dongle_sp_readreg(struct DONGLE_PORT *dng, u8 port) // read a reg
   u16 _PC_ = _PB_ + 1;
   u8  b0, b1 ;
   u8  irqEnable = inb(_PC_) & 0x10; // don't influence irqEnable
-  unsigned long flags;
+  can_spin_irqflags_t flags;
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  save_flags(flags);
-  cli();
-  #else
-  spin_lock_irqsave(&pcan_lock, flags);
-  #endif
+  can_spin_lock_irqsave(&pcan_lock, flags);
 
   outb((0x0B ^ 0x0D) | irqEnable, _PC_);
   outb((port & 0x1F) | 0x80,      _PA_);
@@ -175,11 +170,7 @@ static u8 pcan_dongle_sp_readreg(struct DONGLE_PORT *dng, u8 port) // read a reg
   b0=nibble_decode[inb(_PB_)>>3];
   outb((0x0B ^ 0x0D) | irqEnable, _PC_);
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  restore_flags(flags);
-  #else
-  spin_unlock_irqrestore(&pcan_lock, flags);
-  #endif
+  can_spin_unlock_irqrestore(&pcan_lock, flags);
 
   return  (b1 << 4) | b0 ;
 }
@@ -189,14 +180,9 @@ static void pcan_dongle_writereg(struct DONGLE_PORT *dng, u8 port, u8 data) // w
   u16 _PA_ = (u16)dng->dwPort;
   u16 _PC_ = _PA_ + 2;
   u8  irqEnable = inb(_PC_) & 0x10; // don't influence irqEnable
-  unsigned long flags;
+  can_spin_irqflags_t flags;
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  save_flags(flags);
-  cli();
-  #else
-  spin_lock_irqsave(&pcan_lock, flags);
-  #endif
+  can_spin_lock_irqsave(&pcan_lock, flags);
 
   outb((0x0B ^ 0x0D) | irqEnable, _PC_);
   outb(port & 0x1F,               _PA_);
@@ -204,11 +190,7 @@ static void pcan_dongle_writereg(struct DONGLE_PORT *dng, u8 port, u8 data) // w
   outb(data,                      _PA_);
   outb((0x0B ^ 0x0D) | irqEnable, _PC_);
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  restore_flags(flags);
-  #else
-  spin_unlock_irqrestore(&pcan_lock, flags);
-  #endif
+  can_spin_unlock_irqrestore(&pcan_lock, flags);
 }
 
 // functions for EPP port
@@ -218,14 +200,9 @@ static u8 pcan_dongle_epp_readreg(struct DONGLE_PORT *dng, u8 port) // read a re
   u16 _PC_ = _PA_ + 2;
   u8  wert;
   u8  irqEnable = inb(_PC_) & 0x10; // don't influence irqEnable
-  unsigned long flags;
+  can_spin_irqflags_t flags;
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  save_flags(flags);
-  cli();
-  #else
-  spin_lock_irqsave(&pcan_lock, flags);
-  #endif
+  can_spin_lock_irqsave(&pcan_lock, flags);
 
   outb((0x0B ^ 0x0F) | irqEnable, _PC_);
   outb((port & 0x1F) | 0x80,      _PA_);
@@ -233,11 +210,7 @@ static u8 pcan_dongle_epp_readreg(struct DONGLE_PORT *dng, u8 port) // read a re
   wert = inb(_PA_);
   outb((0x0B ^ 0x0F) | irqEnable, _PC_);
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  restore_flags(flags);
-  #else
-  spin_unlock_irqrestore(&pcan_lock, flags);
-  #endif
+  can_spin_unlock_irqrestore(&pcan_lock, flags);
 
   return wert;
 }
@@ -527,7 +500,7 @@ int pcan_dongle_release_io(struct candevice_t *candev)
 int pcan_dongle_reset(struct candevice_t *candev)
 {
        int i=0;
-       struct chip_t *chip;
+       struct canchip_t *chip;
        int chipnr;
        unsigned cdr;
        
@@ -639,7 +612,7 @@ int pcan_dongle_init_chip_data(struct candevice_t *candev, int chipnr)
        candev->chip[chipnr]->sja_cdr_reg = sjaCDR_CBP | sjaCDR_CLK_OFF;
        candev->chip[chipnr]->sja_ocr_reg = sjaOCR_MODE_NORMAL | sjaOCR_TX0_LH;
 
-       candev->chip[chipnr]->flags |= CHIP_IRQ_VME;  // I don't want setup call request_irq 
+       candev->chip[chipnr]->flags |= CHIP_IRQ_CUSTOM;  // I don't want setup call request_irq 
                                      // I'm going to do it through parport_register_device 
 
      }
@@ -664,7 +637,7 @@ int pcan_dongle_init_chip_data(struct candevice_t *candev, int chipnr)
  * Return Value: The function always returns zero
  * File: src/template.c
  */
-int pcan_dongle_init_obj_data(struct chip_t *chip, int objnr)
+int pcan_dongle_init_obj_data(struct canchip_t *chip, int objnr)
 {
        chip->msgobj[objnr]->obj_base_addr=chip->chip_base_addr;
        chip->msgobj[objnr]->obj_flags=0;