X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/f911e79d724fdac3af2847cec6383a71e907b00a..bcdf432fa7e61f5992fdc801cedb7a9756835f8b:/lincan/src/pcan_dongle.c diff --git a/lincan/src/pcan_dongle.c b/lincan/src/pcan_dongle.c index 6bd3496..ce94186 100644 --- a/lincan/src/pcan_dongle.c +++ b/lincan/src/pcan_dongle.c @@ -109,7 +109,7 @@ typedef void (*PARPORT_IRQ_HANLDER)(int, void *, struct pt_regs *); /****************************************************************************/ // 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; }