From: ppisa Date: Wed, 3 Mar 2004 00:37:25 +0000 (+0000) Subject: Added individual Kconfig for CAN and ORTE components. X-Git-Tag: CLT_COMM_CAN-lincan-0_2-040304~2 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/commitdiff_plain/ca4ad65fe791cd40f1dcec6d0398fd74b31051cd?hp=c316aed80a2047f337dc0cff35e2458c4cb13eca Added individual Kconfig for CAN and ORTE components. Work is based on the proposal and initial version done by Pierre. The option names has been preserved from the previous Kconfig version. This means, that compilation should work correctly with actual Kconfig and with new one after upper level Kconfig changes. IRQ manipulation changed to spin-locks for rest of boards to support better RT-Linux. --- diff --git a/lincan/src/bfadcan.c b/lincan/src/bfadcan.c index 2853ed1..c2c9ce7 100644 --- a/lincan/src/bfadcan.c +++ b/lincan/src/bfadcan.c @@ -29,7 +29,7 @@ MODULE_PARM(clock_freq,"i"); /* cli and sti are not allowed in 2.5.5x SMP kernels */ #ifdef WINDOWED_ACCESS -can_spinlock_t bfadcan_win_lock=SPIN_LOCK_UNLOCKED; +static can_spinlock_t bfadcan_win_lock=SPIN_LOCK_UNLOCKED; #endif /* diff --git a/lincan/src/nsi.c b/lincan/src/nsi.c index 9f6bdef..03ba230 100644 --- a/lincan/src/nsi.c +++ b/lincan/src/nsi.c @@ -16,6 +16,8 @@ int nsican_irq=-1; unsigned long nsican_base=0x0; +static can_spinlock_t nsican_port_lock=SPIN_LOCK_UNLOCKED; + /* IO_RANGE is the io-memory range that gets reserved, please adjust according * your hardware. Example: #define IO_RANGE 0x100 for i82527 chips or * #define IO_RANGE 0x20 for sja1000 chips. @@ -190,13 +192,14 @@ unsigned nsi_read_register(unsigned long address) We use the two register, we write the address where we want to read in a first time. In a second time we read the data */ - unsigned char ret; + unsigned char ret; + can_spin_irqflags_t flags; - can_disable_irq(nsican_irq); - outb(address-nsican_base, nsican_base); - ret=inb(nsican_base+1); - can_enable_irq(nsican_irq); - return ret; + can_spin_lock_irqsave(&nsican_port_lock,flags); + outb(address-nsican_base, nsican_base); + ret=inb(nsican_base+1); + can_spin_unlock_irqrestore(&nsican_port_lock,flags); + return ret; } diff --git a/lincan/src/pcccan.c b/lincan/src/pcccan.c index 64e6b70..ebf315c 100644 --- a/lincan/src/pcccan.c +++ b/lincan/src/pcccan.c @@ -20,6 +20,8 @@ int pcccan_irq=-1; unsigned long pcccan_base=0x0; +static can_spinlock_t pcccan_port_lock=SPIN_LOCK_UNLOCKED; + /* * IO_RANGE is the io-memory range that gets reserved, please adjust according * your hardware. Example: #define IO_RANGE 0x100 for i82527 chips or @@ -253,10 +255,11 @@ int pcccan_program_irq(struct candevice_t *candev) */ void pcccan_write_register(unsigned char data, unsigned long address) { - can_disable_irq(pcccan_irq); + can_spin_irqflags_t flags; + can_spin_lock_irqsave(&pcccan_port_lock,flags); outb(address - pcccan_base, pcccan_base+1); outb(data, pcccan_base+6); - can_enable_irq(pcccan_irq); + can_spin_unlock_irqrestore(&pcccan_port_lock,flags); } /** @@ -272,10 +275,11 @@ void pcccan_write_register(unsigned char data, unsigned long address) unsigned pcccan_read_register(unsigned long address) { unsigned ret; - can_disable_irq(pcccan_irq); + can_spin_irqflags_t flags; + can_spin_lock_irqsave(&pcccan_port_lock,flags); outb(address - pcccan_base, pcccan_base+1); ret=inb(pcccan_base+2); - can_enable_irq(pcccan_irq); + can_spin_unlock_irqrestore(&pcccan_port_lock,flags); return ret; } diff --git a/lincan/src/smartcan.c b/lincan/src/smartcan.c index abbbe1a..4d638f9 100644 --- a/lincan/src/smartcan.c +++ b/lincan/src/smartcan.c @@ -16,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,19 +102,21 @@ int smartcan_init_obj_data(struct chip_t *chip, int objnr) void smartcan_write_register(unsigned char data, unsigned long address) { - can_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); - can_enable_irq(smartcan_irq); + can_spin_unlock_irqrestore(&smartcan_port_lock,flags); } unsigned smartcan_read_register(unsigned long address) { unsigned ret; - can_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); - can_enable_irq(smartcan_irq); + can_spin_unlock_irqrestore(&smartcan_port_lock,flags); return ret; } diff --git a/lincan/src/ssv.c b/lincan/src/ssv.c index 83fbba3..802aee7 100644 --- a/lincan/src/ssv.c +++ b/lincan/src/ssv.c @@ -14,6 +14,8 @@ int ssvcan_irq[2]={-1,-1}; unsigned long ssvcan_base=0x0; +static can_spinlock_t ssv_port_lock=SPIN_LOCK_UNLOCKED; + /* IO_RANGE is the io-memory range that gets reserved, please adjust according * your hardware. Example: #define IO_RANGE 0x100 for i82527 chips or * #define IO_RANGE 0x20 for sja1000 chips. @@ -209,21 +211,22 @@ unsigned ssv_read_register(unsigned long address) want to read in a first time. In a second time we read the data */ unsigned char ret; + can_spin_irqflags_t flags; if((address-ssvcan_base)<0x100) { - can_disable_irq(ssvcan_irq[0]); + can_spin_lock_irqsave(&ssv_port_lock,flags); outb(address-ssvcan_base, ssvcan_base); ret=inb(ssvcan_base+1); - can_enable_irq(ssvcan_irq[0]); + can_spin_unlock_irqrestore(&ssv_port_lock,flags); } else { - can_disable_irq(ssvcan_irq[1]); + can_spin_lock_irqsave(&ssv_port_lock,flags); outb(address-ssvcan_base-0x100, ssvcan_base+0x02); ret=inb(ssvcan_base+1+0x02); - can_enable_irq(ssvcan_irq[1]); + can_spin_unlock_irqrestore(&ssv_port_lock,flags); } return ret;