]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/smartcan.c
Changed data size from byte to unsigned for write_register indirect call
[lincan.git] / lincan / src / smartcan.c
index 731f6572f7a1debdcd0abc14087bf3576f6042a2..4abbc9c79690a7030278f666973531eebcca0fb2 100644 (file)
@@ -7,15 +7,8 @@
  * Version lincan-0.2  9 Jul 2003
  */ 
 
-#include <linux/autoconf.h>
-
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <asm/errno.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-
+#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,27 +95,28 @@ 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;
 }
 
 
-void smartcan_write_register(unsigned char data, unsigned long address)
+void smartcan_write_register(unsigned 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;
 }