]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/read.c
Structured comments updated.
[lincan.git] / lincan / src / read.c
index 64b24155723cd1ecdc92bc13c9933a9de15e750b..88248901b968882045a9a7e40a0b9ce7b08b0b69 100644 (file)
@@ -7,21 +7,8 @@
  * Version lincan-0.2  9 Jul 2003
  */
 
-#define __NO_VERSION__
-#include <linux/module.h> 
-
-#include <linux/autoconf.h>
-
-#include <linux/version.h>
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
-#include <linux/malloc.h>
-#else
-#include <linux/slab.h>
-#endif
-#include <linux/version.h>
-#include <asm/uaccess.h>
-#include <asm/irq.h>
-
+#include "../include/can.h"
+#include "../include/can_sysdep.h"
 #include "../include/main.h"
 #include "../include/read.h"
 #include "../include/ioctl.h"
@@ -76,16 +63,16 @@ inline ssize_t can_std_read(struct file *file, struct canque_ends_t *qends,
 inline ssize_t can_rtr_read(struct chip_t *chip, struct msgobj_t *obj, 
                                                                char *buffer)
 {
-       unsigned long flags;
+       can_spin_irqflags_t flags;
        struct rtr_id *rtr_current, *new_rtr_entry;
        struct canmsg_t read_msg;
        
        DEBUGMSG("Remote transmission request\n");
-       spin_lock_irqsave(&hardware_p->rtr_lock, flags);
+       can_spin_lock_irqsave(&hardware_p->rtr_lock, flags);
        if (hardware_p->rtr_queue == NULL) { //No remote messages pending
                new_rtr_entry=(struct rtr_id *)kmalloc(sizeof(struct rtr_id),GFP_ATOMIC);
                if (new_rtr_entry == NULL) {
-                       spin_unlock_irqrestore(&hardware_p->rtr_lock, 
+                       can_spin_unlock_irqrestore(&hardware_p->rtr_lock, 
                                                                flags);
                        return -ENOMEM;
                }
@@ -98,23 +85,19 @@ inline ssize_t can_rtr_read(struct chip_t *chip, struct msgobj_t *obj,
                new_rtr_entry=(struct rtr_id *)kmalloc(sizeof(struct rtr_id),GFP_ATOMIC);
                rtr_current->next=new_rtr_entry;
        }
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
-       init_waitqueue(&new_rtr_entry->rtr_wq);
-#else
        init_waitqueue_head(&new_rtr_entry->rtr_wq);
-#endif
        new_rtr_entry->id = read_msg.id;
        new_rtr_entry->rtr_message = &read_msg;
        new_rtr_entry->next=NULL;
 
-       spin_unlock_irqrestore(&hardware_p->rtr_lock, flags);
+       can_spin_unlock_irqrestore(&hardware_p->rtr_lock, flags);
 
        /* Send remote transmission request */
        chip->chipspecops->remote_request(chip,obj);
        obj->ret = 0;
        interruptible_sleep_on(&new_rtr_entry->rtr_wq);
 
-       spin_lock_irqsave(&hardware_p->rtr_lock, flags);
+       can_spin_lock_irqsave(&hardware_p->rtr_lock, flags);
        copy_to_user(buffer, &read_msg, sizeof(struct canmsg_t));
        if (hardware_p->rtr_queue == new_rtr_entry) {
                if (new_rtr_entry->next != NULL) 
@@ -131,7 +114,7 @@ inline ssize_t can_rtr_read(struct chip_t *chip, struct msgobj_t *obj,
                else
                        rtr_current->next=NULL;
        }
-       spin_unlock_irqrestore(&hardware_p->rtr_lock, flags);
+       can_spin_unlock_irqrestore(&hardware_p->rtr_lock, flags);
        kfree(new_rtr_entry);
 
        return obj->ret;
@@ -147,7 +130,7 @@ ssize_t can_read(struct file *file, char *buffer, size_t length, loff_t *offset)
        int ret=0;
 
        if(!canuser || (canuser->magic != CAN_USER_MAGIC)){
-               CANMSG("can_close: bad canuser magic\n");
+               CANMSG("can_read: bad canuser magic\n");
                return -ENODEV;
        }
 
@@ -156,11 +139,6 @@ ssize_t can_read(struct file *file, char *buffer, size_t length, loff_t *offset)
                DEBUGMSG("this will always return zero.\n");
                return 0;
        }
-       if (length > 8 * sizeof(struct canmsg_t)) {
-               DEBUGMSG("Reading more than 8 CAN messages, this is not supported.\n");
-               DEBUGMSG("Defaulting to 8 messages.\n");
-               length = 8 * sizeof(struct canmsg_t);
-       }
        /* Initialize hardware pointers */
        obj = canuser->msgobj;
        if (obj == NULL) {