1 /**************************************************************************/
2 /* File: main.c - the CAN driver top level glue code (needs rewrite) */
4 /* LinCAN - (Not only) Linux CAN bus driver */
5 /* Copyright (C) 2002-2009 DCE FEE CTU Prague <http://dce.felk.cvut.cz> */
6 /* Copyright (C) 2002-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz> */
7 /* Funded by OCERA and FRESCOR IST projects */
8 /* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl> */
10 /* LinCAN is free software; you can redistribute it and/or modify it */
11 /* under terms of the GNU General Public License as published by the */
12 /* Free Software Foundation; either version 2, or (at your option) any */
13 /* later version. LinCAN is distributed in the hope that it will be */
14 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
15 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
16 /* General Public License for more details. You should have received a */
17 /* copy of the GNU General Public License along with LinCAN; see file */
18 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
19 /* Cambridge, MA 02139, USA. */
21 /* To allow use of LinCAN in the compact embedded systems firmware */
22 /* and RT-executives (RTEMS for example), main authors agree with next */
23 /* special exception: */
25 /* Including LinCAN header files in a file, instantiating LinCAN generics */
26 /* or templates, or linking other files with LinCAN objects to produce */
27 /* an application image/executable, does not by itself cause the */
28 /* resulting application image/executable to be covered by */
29 /* the GNU General Public License. */
30 /* This exception does not however invalidate any other reasons */
31 /* why the executable file might be covered by the GNU Public License. */
32 /* Publication of enhanced or derived LinCAN files is required although. */
33 /**************************************************************************/
39 #include <linux/module.h>
41 #include <linux/kernel.h>
43 #include <linux/sched.h>
44 #include <linux/poll.h>
45 #include <linux/version.h>
46 #include <linux/interrupt.h>
48 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
49 #include <linux/autoconf.h>
50 #include <linux/wrapper.h>
52 #include <linux/device.h>
53 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
54 static struct class *can_class;
55 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
56 static struct class_simple *can_class;
57 #define class_create class_simple_create
58 #define class_device_create class_simple_device_add
59 #define class_device_destroy(a,b) class_simple_device_remove(b)
60 #define class_destroy class_simple_destroy
64 #if !defined (__GENKSYMS__)
65 #if (defined (MODVERSIONS) && !defined(NOVER))
66 #include <linux/modversions.h>
67 /*#include "../include/main.ver"*/
71 /*#undef CONFIG_DEVFS_FS*/
73 #ifdef CONFIG_DEVFS_FS
74 #include <linux/devfs_fs_kernel.h>
75 #include <linux/miscdevice.h>
78 #include "../include/can.h"
79 #include "../include/can_sysdep.h"
80 #include "../include/main.h"
81 #include "../include/modparms.h"
82 #include "../include/devcommon.h"
83 #include "../include/setup.h"
84 #include "../include/proc.h"
85 #include "../include/open.h"
86 #include "../include/close.h"
87 #include "../include/read.h"
88 #include "../include/select.h"
89 #include "../include/irq.h"
90 #include "../include/ioctl.h"
91 #include "../include/write.h"
92 #include "../include/finish.h"
93 #include "../include/fasync.h"
96 #include <rtl_posixio.h>
97 #include "../include/can_iortl.h"
98 #endif /*CAN_WITH_RTL*/
100 #if defined(CONFIG_OC_LINCAN_CARD_usbcan)
101 #include "../include/usbcan.h"
103 #if defined(CONFIG_OC_LINCAN_CARD_omap2_spican)
104 #include "../include/omap2_spican.h"
107 can_spinlock_t canuser_manipulation_lock;
110 int minor[MAX_TOT_CHIPS]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
113 int baudrate[MAX_TOT_CHIPS];
114 char *hw[MAX_HW_CARDS]={NULL,};
115 int irq[MAX_IRQ]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
116 unsigned long io[MAX_HW_CARDS]={-1,-1,-1,-1,-1,-1,-1,-1};
117 long clockfreq[MAX_HW_CARDS];
123 unsigned int minor_specified;
124 unsigned int baudrate_specified;
125 unsigned int hw_specified;
126 unsigned int irq_specified;
127 unsigned int io_specified;
128 unsigned int clockfreq_specified;
130 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12))
131 /* Module parameters, some must be supplied at module loading time */
132 MODULE_PARM(major,"1i");
133 /*MODULE_PARM(minor, "1-" __MODULE_STRING(MAX_TOT_CHIPS)"i");*/
134 MODULE_PARM(minor, "1-" __MODULE_STRING(MAX_TOT_CHIPS_STR)"i");
135 MODULE_PARM(extended,"1i");
136 MODULE_PARM(pelican,"1i");
137 MODULE_PARM(baudrate, "1-" __MODULE_STRING(MAX_TOT_CHIPS_STR)"i");
138 MODULE_PARM(hw, "1-" __MODULE_STRING(MAX_HW_CARDS)"s");
139 MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_IRQ)"i");
140 MODULE_PARM(io, "1-" __MODULE_STRING(MAX_HW_CARDS)"i");
141 MODULE_PARM(clockfreq, "1-" __MODULE_STRING(MAX_HW_CARDS)"i");
142 MODULE_PARM(stdmask, "1i");
143 MODULE_PARM(extmask, "1i");
144 MODULE_PARM(mo15mask, "1i");
145 MODULE_PARM(processlocal, "1i");
147 #else /* LINUX_VERSION_CODE >= 2,6,12 */
148 module_param(major, int, 0);
149 module_param_array(minor, int, &minor_specified, 0);
150 module_param(extended, int, 0);
151 module_param(pelican, int, 0);
152 module_param_array(baudrate, int, &baudrate_specified, 0);
153 module_param_array(hw, charp, &hw_specified, 0);
154 module_param_array(irq, int, &irq_specified, 0);
155 module_param_array(io, ulong, &io_specified, 0);
156 module_param_array(clockfreq, long, &clockfreq_specified, 0);
157 module_param(stdmask, int, 0);
158 module_param(extmask, int, 0);
159 module_param(mo15mask, int, 0);
160 module_param(processlocal, int, 0);
161 #endif /* LINUX_VERSION_CODE >= 2,6,12 */
163 MODULE_PARM_DESC(major,"can be used to change default major [" __MODULE_STRING(CAN_MAJOR) "]");
164 MODULE_PARM_DESC(minor,"can be used to change default starting minor for each channel");
165 MODULE_PARM_DESC(extended,"enables automatic switching to extended format if ID>2047,"
166 " selects extended frames reception for i82527");
167 MODULE_PARM_DESC(pelican,"unused parameter, PeliCAN used by default for sja1000p chips");
168 MODULE_PARM_DESC(baudrate,"baudrate for each channel in step of 1kHz");
169 MODULE_PARM_DESC(hw,"list of boards types to initialize - virtual,pip5,...");
170 MODULE_PARM_DESC(irq,"list of iterrupt signal numbers, most ISA has one per chip, no value for PCI or virtual");
171 MODULE_PARM_DESC(io,"IO address for each board, use 0 for PCI or virtual");
172 MODULE_PARM_DESC(clockfreq,"base board clock source frequency in step of 1kHz");
173 MODULE_PARM_DESC(stdmask,"default standard mask for i82527 chips");
174 MODULE_PARM_DESC(extmask,"default extended mask for i82527 chips");
175 MODULE_PARM_DESC(mo15mask,"mask for communication object 15 of i82527 chips");
176 MODULE_PARM_DESC(processlocal,"select postprocessing/loopback of transmitted messages - "
177 "0 .. disabled, 1 .. can be enabled by FIFO filter, 2 .. enabled by default");
180 int can_rtl_priority=-1;
181 MODULE_PARM(can_rtl_priority, "1i");
182 MODULE_PARM_DESC(can_rtl_priority,"select priority of chip worker thread");
183 #endif /*CAN_WITH_RTL*/
185 /* Other module attributes */
186 #ifdef MODULE_SUPPORTED_DEVICE
187 MODULE_SUPPORTED_DEVICE("can");
189 #ifdef MODULE_LICENSE
190 MODULE_LICENSE("GPL");
192 #ifdef MODULE_DESCRIPTION
193 MODULE_DESCRIPTION("Universal Linux CAN-bus device driver");
196 MODULE_AUTHOR("Pavel Pisa <pisa@cmp.felk.cvut.cz>, Arnaud Westenberg");
199 /* Global structures, used to describe the installed hardware. */
200 struct canhardware_t canhardware;
201 struct canhardware_t *hardware_p=&canhardware;
202 struct canchip_t *chips_p[MAX_TOT_CHIPS];
203 struct msgobj_t *objects_p[MAX_TOT_MSGOBJS];
204 #ifdef CONFIG_DEVFS_FS
205 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
206 devfs_handle_t devfs_handles[MAX_TOT_MSGOBJS];
210 /* Pointers to dynamically allocated memory are maintained in a linked list
211 * to ease memory deallocation.
213 struct mem_addr *mem_head=NULL;
215 struct file_operations can_fops=
217 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0))
226 #ifdef CAN_ENABLE_KERN_FASYNC
228 #endif /*CAN_ENABLE_KERN_FASYNC*/
231 EXPORT_SYMBOL(can_fops);
235 struct rtl_file_operations can_fops_rtl = {
237 read: can_read_rtl_posix,
238 write: can_write_rtl_posix,
239 ioctl: can_ioctl_rtl_posix,
241 open: can_open_rtl_posix,
242 release: can_release_rtl_posix
244 #endif /*CAN_WITH_RTL*/
248 2.6 kernel attributes for sysfs
250 static ssize_t show_xxx(struct class_device *cdev, char *buf)
252 return sprintf(buf, "xxxx\n");
255 static ssize_t store_xxx(struct class_device *cdev, const char * buf, size_t count)
259 static CLASS_DEVICE_ATTR(xxx, S_IRUGO, show_xxx, store_xxx/NULL);
261 ret = class_device_create_file(class_dev, class_device_attr_xxx);
267 int init_module(void)
270 struct candevice_t *candev;
271 struct canchip_t *chip;
273 if (parse_mod_parms())
276 can_spin_lock_init(&canuser_manipulation_lock);
277 canqueue_kern_initialize();
279 if (init_hw_struct())
286 res=register_chrdev(major,DEVICE_NAME, &can_fops);
288 CANMSG("Error registering driver.\n");
293 can_spin_lock_init(&can_irq_manipulation_lock);
294 canqueue_rtl_initialize();
295 res=rtl_register_rtldev(major,DEVICE_NAME,&can_fops_rtl);
297 CANMSG("Error registering RT-Linux major number.\n");
300 #endif /*CAN_WITH_RTL*/
302 for (i=0; i<hardware_p->nr_boards; i++) {
303 candev=hardware_p->candevice[i];
304 if (candev->hwspecops->request_io(candev))
305 goto request_io_error;
306 candev->flags|=CANDEV_IO_RESERVED;
309 for (i=0; i<hardware_p->nr_boards; i++) {
310 candev=hardware_p->candevice[i];
311 if (candev->hwspecops->reset(candev))
315 can_spin_lock_init(&hardware_p->rtr_lock);
316 hardware_p->rtr_queue=NULL;
318 for (i=0; i<hardware_p->nr_boards; i++) {
319 candev=hardware_p->candevice[i];
320 for(j=0; j<candev->nr_all_chips; j++) {
321 if((chip=candev->chip[j])==NULL)
324 if(chip->chipspecops->attach_to_chip(chip)<0) {
325 CANMSG("Initial attach to the chip HW failed\n");
326 goto interrupt_error;
329 chip->flags |= CHIP_ATTACHED;
331 if(can_chip_setup_irq(chip)<0) {
332 CANMSG("Error to setup chip IRQ\n");
333 goto interrupt_error;
337 if (candev->flags & CANDEV_PROGRAMMABLE_IRQ)
338 if (candev->hwspecops->program_irq(candev)){
339 CANMSG("Error to program board interrupt\n");
340 goto interrupt_error;
344 #ifdef CONFIG_PROC_FS
345 if (can_init_procdir())
349 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
350 can_class=class_create(THIS_MODULE, "can");
353 #if defined(CONFIG_DEVFS_FS) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
355 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
357 #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25) /* >= 2.6.15 */
358 struct class_device *this_dev;
360 struct device *this_dev;
363 for(i=0;i<MAX_TOT_MSGOBJS;i++) {
364 if(!objects_p[i]) continue;
365 dev_minor=objects_p[i]->minor;
366 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
367 sprintf (dev_name, "can%d", dev_minor);
368 devfs_handles[i]=devfs_register(NULL, dev_name,
369 DEVFS_FL_DEFAULT, major, dev_minor,
370 S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
371 &can_fops, (void*)objects_p[i]);
373 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,14))
374 this_dev=class_device_create(can_class, MKDEV(major, dev_minor), NULL, "can%d", dev_minor);
375 #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25) /* >= 2.6.15 */
376 this_dev=class_device_create(can_class, NULL, MKDEV(major, dev_minor), NULL, "can%d", dev_minor);
377 #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27)
378 this_dev=device_create_drvdata(can_class, NULL, MKDEV(major, dev_minor), objects_p[i], "can%d", dev_minor);
379 #else /* >= 2.6.28 */
380 this_dev=device_create(can_class, NULL, MKDEV(major, dev_minor), objects_p[i], "can%d", dev_minor);
381 #endif /* >= 2.6.28 */
382 if(IS_ERR(this_dev)){
383 CANMSG("problem to create device \"can%d\" in the class \"can\"\n", dev_minor);
384 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
386 /*this_dev->class_data=objects_p[i];*/
387 class_set_devdata(this_dev,objects_p[i]);
388 #endif /* <= 2.6.25 */
390 #ifdef CONFIG_DEVFS_FS
391 devfs_mk_cdev(MKDEV(major, dev_minor), S_IFCHR | S_IRUGO | S_IWUGO, "can%d", dev_minor);
398 #if defined(CONFIG_OC_LINCAN_CARD_usbcan)
401 CANMSG("usb_register for usbcan failed. Error number %d.\n", res);
405 #if defined(CONFIG_OC_LINCAN_CARD_omap2_spican)
406 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
407 res = omap2_spican_init();
409 CANMSG("omap2_spican_register for omap2_spican failed. Error number %d.\n", res);
413 #error There's no support for OMAP2 SPI subsystem in kernel versions before 2.6.23
419 #ifdef CONFIG_PROC_FS
421 CANMSG("Error registering /proc entry.\n");
429 CANMSG("Error resetting device.\n");
433 CANMSG("Error to request IO resources for device.\n");
437 canhardware_done(hardware_p);
440 rtl_unregister_rtldev(major,DEVICE_NAME);
443 #endif /*CAN_WITH_RTL*/
445 unregister_chrdev(major,DEVICE_NAME);
446 CANMSG("No CAN devices or driver setup error.\n");
449 if ( can_del_mem_list() )
450 CANMSG("Error deallocating memory\n");
459 struct candevice_t* register_hotplug_dev(const char *hwname,int (*chipdataregfnc)(struct canchip_t *ch,void *data),void *devdata){
461 struct candevice_t *candev;
462 struct canchip_t *chip;
463 struct boardtype_t *brp;
465 while ( (hw[board] != NULL) && (board < MAX_HW_CARDS) )
467 if (board>=MAX_HW_CARDS){
468 CANMSG("Maximum number of devices has been reached, no space for new device");
471 brp = boardtype_find(hwname);
473 CANMSG("Sorry, hardware \"%s\" is currently not supported.\n",hwname);
476 if (board==MAX_HW_CARDS){
477 CANMSG("Device \"%s\" could not be registered due to internal limits.\n",hwname);
480 hw[board]=brp->boardtype;
482 if (init_new_hw_struct(board)){
483 CANMSG("HW struct creation failed.\n");
491 candev=hardware_p->candevice[board];
493 /* Adding link to usb device structure into can device */
494 candev->sysdevptr.anydev=devdata;
496 if (candev->hwspecops->request_io(candev))
497 goto request_io_error;
498 candev->flags|=CANDEV_IO_RESERVED;
500 if (candev->hwspecops->reset(candev))
503 for(j=0; j<candev->nr_all_chips; j++) {
504 if((chip=candev->chip[j])==NULL)
507 if (chipdataregfnc && devdata){
508 if (chipdataregfnc(chip,devdata))
509 goto interrupt_error;
512 if(chip->chipspecops->attach_to_chip(chip)<0) {
513 CANMSG("Initial attach to the chip HW failed\n");
514 goto interrupt_error;
517 chip->flags |= CHIP_ATTACHED;
519 if(can_chip_setup_irq(chip)<0) {
520 CANMSG("Error to setup chip IRQ\n");
521 goto interrupt_error;
525 if (candev->flags & CANDEV_PROGRAMMABLE_IRQ)
526 if (candev->hwspecops->program_irq(candev)){
527 CANMSG("Error to program board interrupt\n");
528 goto interrupt_error;
530 CANMSG("Registering /proc entry\n");
531 #ifdef CONFIG_PROC_FS
532 if (can_init_procentry(board))
536 #if defined(CONFIG_DEVFS_FS) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
538 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
541 struct class_device *this_dev;
544 for(i=0;i<MAX_TOT_MSGOBJS;i++) {
545 if(!objects_p[i]) continue;
546 if(objects_p[i]->hostchip->hostdevice != candev) continue;
548 dev_minor=objects_p[i]->minor;
549 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
550 sprintf (dev_name, "can%d", dev_minor);
551 devfs_handles[i]=devfs_register(NULL, dev_name,
552 DEVFS_FL_DEFAULT, major, dev_minor,
553 S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
554 &can_fops, (void*)objects_p[i]);
556 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,14))
557 this_dev=class_device_create(can_class, MKDEV(major, dev_minor), NULL, "can%d", dev_minor);
558 #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25) /* >= 2.6.15 */
559 this_dev=class_device_create(can_class, NULL, MKDEV(major, dev_minor), NULL, "can%d", dev_minor);
560 #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27)
561 this_dev=device_create_drvdata(can_class, NULL, MKDEV(major, dev_minor), objects_p[i], "can%d", dev_minor);
562 #else /* >= 2.6.28 */
563 this_dev=device_create(can_class, NULL, MKDEV(major, dev_minor), objects_p[i], "can%d", dev_minor);
564 #endif /* >= 2.6.28 */
565 if(IS_ERR(this_dev)){
566 CANMSG("problem to create device \"can%d\" in the class \"can\"\n", dev_minor);
567 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
569 /*this_dev->class_data=objects_p[i];*/
570 class_set_devdata(this_dev,objects_p[i]);
571 #endif /* <= 2.6.25 */
573 #ifdef CONFIG_DEVFS_FS
574 devfs_mk_cdev(MKDEV(major, dev_minor), S_IFCHR | S_IRUGO | S_IWUGO, "can%d", dev_minor);
582 #ifdef CONFIG_PROC_FS
584 CANMSG("Error registering /proc entry.\n");
592 CANMSG("Error resetting device.\n");
596 CANMSG("Error to request IO resources for device.\n");
603 #endif /*CAN_WITH_RTL*/
606 // if ( can_del_mem_list() )
607 // CANMSG("Error deallocating memory\n");
612 void deregister_hotplug_dev(struct candevice_t *dev)
619 DEBUGMSG("Deregistering hotplug device.\n");
621 #ifdef CONFIG_PROC_FS
622 if (can_delete_procentry(dev))
623 CANMSG("Error unregistering /proc/can entry.\n");
626 #if defined(CONFIG_DEVFS_FS) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
627 for(i=0;i<MAX_TOT_MSGOBJS;i++) {
628 if(!objects_p[i]) continue;
629 if(objects_p[i]->hostchip->hostdevice != dev) continue;
630 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
632 devfs_unregister(devfs_handles[i]);
634 dev_minor=objects_p[i]->minor;
636 #ifdef CONFIG_DEVFS_FS
637 devfs_remove("can%d", dev_minor);
639 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
640 class_device_destroy(can_class, MKDEV(major, dev_minor));
641 #else /* >= 2.6.26 */
642 device_destroy(can_class, MKDEV(major, dev_minor));
643 #endif /* >= 2.6.26 */
652 void cleanup_hotplug_dev(struct candevice_t *dev)
659 DEBUGMSG("Cleaning up hotplug device.\n");
661 for(i=0;i<MAX_TOT_CHIPS;i++){
662 if(!chips_p[i]) continue;
663 if(chips_p[i]->hostdevice != dev) continue;
667 hardware_p->candevice[dev->candev_idx]=NULL;
668 hardware_p->nr_boards--;
669 hw[dev->candev_idx]=NULL;
672 can_checked_free(dev);
678 void cleanup_module(void)
680 #if defined(CONFIG_DEVFS_FS) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
684 #if defined(CONFIG_OC_LINCAN_CARD_usbcan)
685 DEBUGMSG("Unregistering usbcan.\n");
688 #if defined(CONFIG_OC_LINCAN_CARD_omap2_spican)
689 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
690 DEBUGMSG("Unregistering omap2_spican.\n");
694 DEBUGMSG("Continuing with coldplug cleanup.\n");
695 #ifdef CONFIG_PROC_FS
696 if (can_delete_procdir())
697 CANMSG("Error unregistering /proc/can entry.\n");
700 #if defined(CONFIG_DEVFS_FS) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
701 for(i=0;i<MAX_TOT_MSGOBJS;i++) {
702 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
704 devfs_unregister(devfs_handles[i]);
707 if(!objects_p[i]) continue;
708 dev_minor=objects_p[i]->minor;
710 #ifdef CONFIG_DEVFS_FS
711 devfs_remove("can%d", dev_minor);
713 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
714 class_device_destroy(can_class, MKDEV(major, dev_minor));
715 #else /* >= 2.6.26 */
716 device_destroy(can_class, MKDEV(major, dev_minor));
717 #endif /* >= 2.6.26 */
723 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
724 class_destroy(can_class);
727 canhardware_done(hardware_p);
730 rtl_unregister_rtldev(major,DEVICE_NAME);
732 #endif /*CAN_WITH_RTL*/
734 DEBUGMSG("Can hardware cleanup done, freeing memory.\n");
736 if ( can_del_mem_list() )
737 CANMSG("Error deallocating memory\n");
739 unregister_chrdev(major,DEVICE_NAME);