X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/11132ea490f9e860744ee4f851c67e7fb4444231..2827b727d2910a3b48f9de7d67b3a67f59e256c7:/lincan/src/smartcan.c diff --git a/lincan/src/smartcan.c b/lincan/src/smartcan.c index 731f657..4d638f9 100644 --- a/lincan/src/smartcan.c +++ b/lincan/src/smartcan.c @@ -7,15 +7,8 @@ * Version lincan-0.2 9 Jul 2003 */ -#include - -#include -#include -#include -#include -#include -#include - +#include "../include/can.h" +#include "../include/can_sysdep.h" #include "../include/main.h" #include "../include/smartcan.h" #include "../include/i82527.h" @@ -23,6 +16,8 @@ int smartcan_irq=-1; unsigned long smartcan_base=0x0; +static can_spinlock_t smartcan_port_lock=SPIN_LOCK_UNLOCKED; + int smartcan_request_io(struct candevice_t *candev) { if (!can_request_io_region(candev->io_addr,0x04,DEVICE_NAME)) { @@ -100,7 +95,6 @@ int smartcan_init_chip_data(struct candevice_t *candev, int chipnr) int smartcan_init_obj_data(struct chip_t *chip, int objnr) { chip->msgobj[objnr]->obj_base_addr=(objnr+1)*0x10; - chip->msgobj[objnr]->flags=0; return 0; } @@ -108,19 +102,21 @@ int smartcan_init_obj_data(struct chip_t *chip, int objnr) void smartcan_write_register(unsigned char data, unsigned long address) { - disable_irq(smartcan_irq); + can_spin_irqflags_t flags; + can_spin_lock_irqsave(&smartcan_port_lock,flags); outb(address-smartcan_base,smartcan_base); outb(data,smartcan_base+1); - enable_irq(smartcan_irq); + can_spin_unlock_irqrestore(&smartcan_port_lock,flags); } unsigned smartcan_read_register(unsigned long address) { unsigned ret; - disable_irq(smartcan_irq); + can_spin_irqflags_t flags; + can_spin_lock_irqsave(&smartcan_port_lock,flags); outb(address-smartcan_base,smartcan_base); ret=inb(smartcan_base+1); - enable_irq(smartcan_irq); + can_spin_unlock_irqrestore(&smartcan_port_lock,flags); return ret; }