]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/setup.c
The first enhanced version of Linux CAN-bus driver for OCERA project
[lincan.git] / lincan / src / setup.c
index 74ba10f0f4f1d40765e0bb36011912da5193b56e..a8f76cc2d1e2816c0f4d83bc15030102dd2e227e 100644 (file)
@@ -5,6 +5,9 @@
  * Version 0.7  6 Aug 2001
  */ 
 
+#define __NO_VERSION__
+#include <linux/module.h>
+
 #include <linux/autoconf.h>
 #if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS)
 #define MODVERSIONS
 #include <linux/modversions.h>
 #endif
 
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
 #include <linux/malloc.h>
+#else
+#include <linux/slab.h>
+#endif
 #include <linux/fs.h>
 
-#include "../.support"
+#include ".supported_cards.h"
 
 #include "../include/main.h"
 #include "../include/setup.h"
@@ -49,6 +57,8 @@ extern int pcm3680_register(struct hwspecops_t *hwspecops);
 extern int aim104_register(struct hwspecops_t *hwspecops);
 extern int pcccan_register(struct hwspecops_t *hwspecops);
 extern int ssv_register(struct hwspecops_t *hwspecops);
+extern int bfadcan_register(struct hwspecops_t *hwspecops);
+extern int pikronisa_register(struct hwspecops_t *hwspecops);
 
 int init_device_struct(int card);
 int init_hwspecops(int card);
@@ -86,7 +96,12 @@ int del_mem_from_list(void *address_p)
        DEBUGMSG("del_mem_from_list %p, mem_head=%p\n", address_p, mem_head);
        return 0;
 #endif
-       
+       if(mem_head == NULL) {
+               CANMSG("del_mem_from_list: mem_head == NULL address_p=%p!\n",
+                               address_p);
+               return 0;
+       }
+
        mem_search = mem_head;
 
        if (mem_head->address == address_p) {
@@ -114,6 +129,10 @@ int del_mem_list(void)
        DEBUGMSG("del_mem_list, mem_head=%p\n", mem_head);
        return 0;
 #endif
+       if(mem_head == NULL) {
+               CANMSG("del_mem_list: mem_head == NULL!\n");
+               return 0;
+       }
 
        while (mem_head->next != NULL) {
                mem_old=mem_head;
@@ -271,12 +290,12 @@ int init_obj_struct(int card, int chip)
 
 int init_hwspecops(int card)
 {
-       #ifdef TEMPLATE
+       #ifdef ENABLE_CARD_template
        if (!strcmp(candevices_p[card]->hwname,"template")) {
                template_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef PIP
+       #ifdef ENABLE_CARD_pip
        if (!strcmp(candevices_p[card]->hwname,"pip5")) {
                pip5_register(candevices_p[card]->hwspecops);
        }
@@ -284,37 +303,37 @@ int init_hwspecops(int card)
                pip6_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef SMARTCAN
+       #ifdef ENABLE_CARD_smartcan
        if (!strcmp(candevices_p[card]->hwname,"smartcan")) {
                smartcan_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef NSI
+       #ifdef ENABLE_CARD_nsi
        if (!strcmp(candevices_p[card]->hwname,"nsican")) {
                nsi_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef CC104
+       #ifdef ENABLE_CARD_cc_can104
        if (!strcmp(candevices_p[card]->hwname,"cc104")) {
                cc104_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef AIM104
+       #ifdef ENABLE_CARD_aim104
        if (!strcmp(candevices_p[card]->hwname,"aim104")) {
                aim104_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef PCI03
+       #ifdef ENABLE_CARD_pc_i03
        if (!strcmp(candevices_p[card]->hwname,"pc-i03")) {
                pci03_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef PCM3680
+       #ifdef ENABLE_CARD_pcm3680
        if (!strcmp(candevices_p[card]->hwname,"pcm3680")) {
                pcm3680_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef PCCAN
+       #ifdef ENABLE_CARD_pccan
        if (!strcmp(candevices_p[card]->hwname,"pccan-f") |
                 !strcmp(candevices_p[card]->hwname,"pccan-s") ) {
                pccanf_register(candevices_p[card]->hwspecops);
@@ -326,21 +345,31 @@ int init_hwspecops(int card)
                pccanq_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef M437
+       #ifdef ENABLE_CARD_m437
        if (!strcmp(candevices_p[card]->hwname,"m437")) {
                m437_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef PCCCAN
+       #ifdef ENABLE_CARD_pcccan
        if (!strcmp(candevices_p[card]->hwname,"pcccan")) {
                pcccan_register(candevices_p[card]->hwspecops);
        }
        #endif
-       #ifdef SSV
+       #ifdef ENABLE_CARD_ssv
        if (!strcmp(candevices_p[card]->hwname,"ssv")) {
                ssv_register(candevices_p[card]->hwspecops);
        }
        #endif
+       #ifdef ENABLE_CARD_bfadcan
+       if (!strcmp(candevices_p[card]->hwname,"bfadcan")) {
+               bfadcan_register(candevices_p[card]->hwspecops);
+       }
+       #endif
+       #ifdef ENABLE_CARD_pikronisa
+       if (!strcmp(candevices_p[card]->hwname,"pikronisa")) {
+               pikronisa_register(candevices_p[card]->hwspecops);
+       }
+       #endif
        return 0;
 }