]> 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>
Wed, 23 Jul 2008 14:59:00 +0000 (16:59 +0200)
fixed usbcan board name
fixed memory allocation of usbcan structure
pending kernel thread running in atomic context

lincan/include/usbcan.h
lincan/src/boardlist.c
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 46d606309bd88feedbba69c8285eaebff99b35f5..6caf3a286a53a7edef191ea7bb7814c1f83c6c45 100644 (file)
@@ -150,7 +150,7 @@ const struct boardtype_t can_boardtypes[]={
        {"nsicanpci", nsi_canpci_register, 1},
     #endif
     #if defined(CONFIG_OC_LINCAN_CARD_usbcan)
-       {"nsicanpci", usbcan_register, 0},
+       {"usbcan", usbcan_register, 0},
     #endif
        {NULL}
 };
index 1574169c3ffd161d9543e1a709d542c42baa32a8..0e9f2a5cb607e041d8e786b03f961c275c4271e3 100644 (file)
@@ -414,13 +414,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 1782c5415713c52ed3a0ca1acb4cdd4719466268..3c79a36d907faac7dccbe44affdf33291df85ce1 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 can.o hw=pip5 irq=4 io=0x8000\n");
-               return -ENODEV;
+               //return -ENODEV;
        }
 
        while ( (hw[i] != NULL) && (i < MAX_HW_CARDS) ) {
@@ -36,7 +37,7 @@ int parse_mod_parms(void)
 
        /* Check wether the supplied number of io addresses is correct. */
        io_needed=i;
-       while ( (io[io_supplied] != -1) & (io_supplied<MAX_HW_CARDS) ) 
+       while ( (io[io_supplied] != -1) & (io_supplied<MAX_HW_CARDS) )
                io_supplied++;
        if (io_needed != io_supplied) {
                CANMSG("Invalid number of io addresses.\n");
@@ -64,7 +65,7 @@ int parse_mod_parms(void)
        if (minor[0] != -1) {
                minor_needed=irq_needed;
                while ((minor[minor_supplied] != -1) & (minor_supplied<MAX_IRQ))
-                       minor_supplied++; 
+                       minor_supplied++;
                if (minor_supplied != minor_needed) {
                        CANMSG("Invalid number of minor numbers.\n");
                        CANMSG("Supplied hardware needs %d minor number(s).\n",minor_needed);
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 */