2 * Linux CAN-bus device driver.
3 * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
4 * Rewritten for new CAN queues by Pavel Pisa - OCERA team member
5 * email:pisa@cmp.felk.cvut.cz
6 * This software is released under the GPL-License.
7 * Version lincan-0.2 9 Jul 2003
12 #include "../include/can.h"
13 #include "../include/can_sysdep.h"
14 #include "../include/main.h"
16 #include <rtl_posixio.h>
17 #include "../include/can_iortl.h"
20 int can_ioctl_rtl_posix(struct rtl_file *fptr, unsigned int cmd, unsigned long arg)
22 struct canuser_t *canuser =
23 (struct canuser_t *)can_get_rtl_file_private_data(fptr);
25 unsigned short channel=0;
26 unsigned btr0=0, btr1=0;
29 struct canque_ends_t *qends;
31 if(!canuser || (canuser->magic != CAN_USER_MAGIC)){
32 CANMSG("can_ioctl_: bad canuser magic\n");
36 obj = canuser->msgobj;
38 CANMSG("Could not assign buffer structure\n");
42 qends = canuser->qends;
45 CANMSG("Device is not correctly configured.\n");
46 CANMSG("Please reload the driver.\n");
52 for (i=0x0; i<0x100; i++)
53 CANMSG("0x%x is 0x%x\n",i,can_read_reg(chip,i));
57 if (chip->chipspecops->start_chip(chip))
62 if (chip->chipspecops->stop_chip(chip))
67 canque_flush(canuser->rx_edge0);
71 if(canuser->rx_edge0){
72 canque_set_filt(canuser->rx_edge0, arg, ~0, 0);
79 struct canfilt_t canfilt;
80 copy_from_user(&canfilt, (void*)arg, sizeof(struct canfilt_t));
81 if(canuser->rx_edge0){
82 canque_set_filt(canuser->rx_edge0, canfilt.id, canfilt.mask, canfilt.flags);
89 btr0 = (arg >> 8) & 0xff;
90 btr1 = (arg >> 16) & 0xff;
92 if (chip->chipspecops->set_btregs(chip, btr0, btr1)) {
93 CANMSG("Error setting bit timing registers\n");
99 CANMSG("Not a valid ioctl command\n");
108 #endif /*CAN_WITH_RTL*/