]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
Minor fixes
authorJan Kriz <krizj1@fel.cvut.cz>
Wed, 23 Jul 2008 14:59:11 +0000 (16:59 +0200)
committerppisa <pisa@cmp.felk.cvut.cz>
Sun, 23 Nov 2008 23:25:20 +0000 (00:25 +0100)
fixed usbcan board name
fixed memory allocation of usbcan structure
pending kernel thread running in atomic context

lincan/include/usbcan.h
lincan/src/main.c
lincan/src/modparms.c
lincan/src/usbcan.c

index 2d580fb3424ddde470f5f62edd6ff2df1a6be672..3e79bf06ed1d2fde26d41136ee8e52341e88bf85 100644 (file)
@@ -71,47 +71,47 @@ int usbcan_chip_queue_status(struct canchip_t *chip);
 
 #ifdef CONFIG_OC_LINCAN_DETAILED_ERRORS
 
-static const char *sja1000_ecc_errc_str[]={
-       "bit error",
-       "form error",
-       "stuff error",
-       "other type of error"
-};
-
-static const char *sja1000_ecc_seg_str[]={
-       "?0?",
-       "?1?",
-       "ID.28 to ID.21",
-       "start of frame",
-       "bit SRTR",
-       "bit IDE",
-       "ID.20 to ID.18",
-       "ID.17 to ID.13",
-       "CRC sequence",
-       "reserved bit 0",
-       "data field",
-       "data length code",
-       "bit RTR",
-       "reserved bit 1",
-       "ID.4 to ID.0",
-       "ID.12 to ID.5",
-       "?16?"
-       "active error flag",
-       "intermission",
-       "tolerate dominant bits",
-       "?20?",
-       "?21?",
-       "passive error flag",
-       "error delimiter",
-       "CRC delimiter",
-       "acknowledge slot",
-       "end of frame",
-       "acknowledge delimiter",
-       "overload flag",
-       "?29?",
-       "?30?",
-       "?31?"
-};
+// static const char *sja1000_ecc_errc_str[]={
+//     "bit error",
+//     "form error",
+//     "stuff error",
+//     "other type of error"
+// };
+//
+// static const char *sja1000_ecc_seg_str[]={
+//     "?0?",
+//     "?1?",
+//     "ID.28 to ID.21",
+//     "start of frame",
+//     "bit SRTR",
+//     "bit IDE",
+//     "ID.20 to ID.18",
+//     "ID.17 to ID.13",
+//     "CRC sequence",
+//     "reserved bit 0",
+//     "data field",
+//     "data length code",
+//     "bit RTR",
+//     "reserved bit 1",
+//     "ID.4 to ID.0",
+//     "ID.12 to ID.5",
+//     "?16?"
+//     "active error flag",
+//     "intermission",
+//     "tolerate dominant bits",
+//     "?20?",
+//     "?21?",
+//     "passive error flag",
+//     "error delimiter",
+//     "CRC delimiter",
+//     "acknowledge slot",
+//     "end of frame",
+//     "acknowledge delimiter",
+//     "overload flag",
+//     "?29?",
+//     "?30?",
+//     "?31?"
+// };
 
 #endif /*CONFIG_OC_LINCAN_DETAILED_ERRORS*/
 
index dd2319a876618a68471a83e5a9541bbc5d908676..f66a2881c2f8a8c575354dd8807641581a8b02b2 100644 (file)
@@ -418,13 +418,17 @@ int init_module(void)
 
 
 struct candevice_t* register_usbdev(const char *hwname,void *anydev){
-       int i=0, j, board;
+       int i=0, j, board=0;
        struct candevice_t *candev;
        struct canchip_t *chip;
        struct boardtype_t *brp;
 
        while ( (hw[board] != NULL) && (board < MAX_HW_CARDS) )
                board++;
+       if (board>=MAX_HW_CARDS){
+               CANMSG("Maximum number of devices has been reached, no space for new device");
+               return NULL;
+       }
        brp = boardtype_find(hwname);
        if(!brp) {
                CANMSG("Sorry, hardware \"%s\" is currently not supported.\n",hw[board]);
index a0aad042446b96d5f4a634da866e8e245b138291..c53971f790a4a5c8ab30e72fd13449d013849aa9 100644 (file)
@@ -19,9 +19,10 @@ int parse_mod_parms(void)
        const struct boardtype_t *brp;
 
        if ( (hw[0] == NULL) | (io[0] == -1) ) {
-               CANMSG("You must supply your type of hardware, interrupt numbers and io address.\n");
+               //CANMSG("You must supply your type of hardware, interrupt numbers and io address.\n");
+               CANMSG("Autodetection works only for USB devices, supply your type of hardware for PCI devices \n");
                CANMSG("Example: # insmod lincan.ko hw=pip5 irq=4 io=0x8000\n");
-               return -ENODEV;
+               //return -ENODEV;
        }
 
        while ( (hw[i] != NULL) && (i < MAX_HW_CARDS) ) {
index a18f8621cda002f65ace1943d966577e9c257cef..1be7a9031225a224ae23175607bde197d09156b0 100644 (file)
@@ -177,7 +177,7 @@ int usbcan_register(struct hwspecops_t *hwspecops)
        return 0;
 }
 
-static int sja1000_report_error_limit_counter;
+// static int sja1000_report_error_limit_counter;
 
 static void sja1000_report_error(struct canchip_t *chip,
                                unsigned sr, unsigned ir, unsigned ecc)
@@ -1041,7 +1041,7 @@ void usbcan_read_kthread(kthread_t *kthread)
 
                if (test_bit(USBCAN_ERROR,&dev->flags)){
                        CANMSG("URB error %d\n",retval);
-                       break;
+                       clear_bit(USBCAN_ERROR,&dev->flags);
                }
 
                { /* Normal work to do */
@@ -1098,6 +1098,7 @@ static int usbcan_probe(struct usb_interface *interface, const struct usb_device
                err("Out of memory");
                goto error;
        }
+       memset(dev, 0, sizeof(struct usbcan_usb));
 
        sema_init(&dev->limit_sem, WRITES_IN_FLIGHT);
        spin_lock_init(&dev->err_lock);
@@ -1188,6 +1189,8 @@ static void usbcan_disconnect(struct usb_interface *interface)
        int minor = interface->minor;
 
        dev = usb_get_intfdata(interface);
+       if (!dev)
+               return;
        usb_set_intfdata(interface, NULL);
 
        /* prevent more I/O from starting */