From 50c42bb67d8c58c507a9c4a58e50c6879f6711a3 Mon Sep 17 00:00:00 2001 From: Jan Kriz Date: Wed, 23 Jul 2008 16:59:11 +0200 Subject: [PATCH] Minor fixes fixed usbcan board name fixed memory allocation of usbcan structure pending kernel thread running in atomic context --- lincan/include/usbcan.h | 82 ++++++++++++++++++++--------------------- lincan/src/main.c | 6 ++- lincan/src/modparms.c | 5 ++- lincan/src/usbcan.c | 7 +++- 4 files changed, 54 insertions(+), 46 deletions(-) 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/main.c b/lincan/src/main.c index dd2319a..f66a288 100644 --- a/lincan/src/main.c +++ b/lincan/src/main.c @@ -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]); diff --git a/lincan/src/modparms.c b/lincan/src/modparms.c index a0aad04..c53971f 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 lincan.ko hw=pip5 irq=4 io=0x8000\n"); - return -ENODEV; + //return -ENODEV; } while ( (hw[i] != NULL) && (i < MAX_HW_CARDS) ) { diff --git a/lincan/src/usbcan.c b/lincan/src/usbcan.c index a18f862..1be7a90 100644 --- a/lincan/src/usbcan.c +++ b/lincan/src/usbcan.c @@ -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 */ -- 2.39.2