* Rewritten for new CAN queues by Pavel Pisa - OCERA team member
* email:pisa@cmp.felk.cvut.cz
* This software is released under the GPL-License.
- * Version lincan-0.2 9 Jul 2003
+ * Version lincan-0.3 17 Jun 2004
*/
-#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"
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);
+
+ copy_from_user(&read_msg, buffer, sizeof(struct canmsg_t));
+
+ 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;
}
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);
- copy_to_user(buffer, &read_msg, sizeof(struct canmsg_t));
+ can_spin_lock_irqsave(&hardware_p->rtr_lock, flags);
if (hardware_p->rtr_queue == new_rtr_entry) {
if (new_rtr_entry->next != NULL)
hardware_p->rtr_queue=new_rtr_entry->next;
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);
+ copy_to_user(buffer, &read_msg, sizeof(struct canmsg_t));
+
return obj->ret;
}
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;
}
copy_from_user(&read_msg, buffer, sizeof(struct canmsg_t));
if (read_msg.flags & MSG_RTR)
+ /* FIXME: RTR processing should go to its own IOCTLs */
ret = can_rtr_read(chip, obj, buffer);
else
ret = can_std_read(file, qends, obj, buffer, length);