From: Jan Kriz Date: Wed, 23 Jul 2008 14:59:11 +0000 (+0200) Subject: Minor fixes X-Git-Tag: CLT_COMM_CAN_usb_can1_kriz_bp~8 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/commitdiff_plain/49e5d02a7ffce9534cdbb70d0b4e1181755da074 Minor fixes fixed usbcan board name fixed memory allocation of usbcan structure pending kernel thread running in atomic context --- diff --git a/lincan/include/usbcan.h b/lincan/include/usbcan.h index 2d580fb..3e79bf0 100644 --- a/lincan/include/usbcan.h +++ b/lincan/include/usbcan.h @@ -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*/ diff --git a/lincan/src/boardlist.c b/lincan/src/boardlist.c index 46d6063..6caf3a2 100644 --- a/lincan/src/boardlist.c +++ b/lincan/src/boardlist.c @@ -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} }; diff --git a/lincan/src/main.c b/lincan/src/main.c index 1574169..0e9f2a5 100644 --- a/lincan/src/main.c +++ b/lincan/src/main.c @@ -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]); diff --git a/lincan/src/modparms.c b/lincan/src/modparms.c index 1782c54..3c79a36 100644 --- a/lincan/src/modparms.c +++ b/lincan/src/modparms.c @@ -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_suppliedflags)){ 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 */