X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/f322df49b2f3aa1d8a5ac71a0fba7f8084c26380..cd942e22c45aa0f9f9463777fe7e8635454bec81:/lincan/src/main.c diff --git a/lincan/src/main.c b/lincan/src/main.c index 7851340..dac9620 100644 --- a/lincan/src/main.c +++ b/lincan/src/main.c @@ -4,7 +4,7 @@ * Rewritten for new CAN queues by Pavel Pisa - OCERA team member * email:pisa@cmp.felk.cvut.cz * This software is released under the GPL-License. - * Version lincan-0.2 9 Jul 2003 + * Version lincan-0.3 17 Jun 2004 */ #ifndef EXPORT_SYMTAB @@ -63,8 +63,6 @@ #include "../include/can_iortl.h" #endif /*CAN_WITH_RTL*/ -#define EXPORT_SYMTAB - can_spinlock_t canuser_manipulation_lock; /* Module parameters, some must be supplied at module loading time */ @@ -130,7 +128,7 @@ MODULE_AUTHOR("Pavel Pisa , Arnaud Westenberg"); /* Global structures, used to describe the installed hardware. */ struct canhardware_t canhardware; struct canhardware_t *hardware_p=&canhardware; -struct chip_t *chips_p[MAX_TOT_CHIPS]; +struct canchip_t *chips_p[MAX_TOT_CHIPS]; struct msgobj_t *objects_p[MAX_TOT_MSGOBJS]; #ifdef CONFIG_DEVFS_FS #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,60)) @@ -179,7 +177,7 @@ int init_module(void) { int res=0,i=0, j; struct candevice_t *candev; - struct chip_t *chip; + struct canchip_t *chip; if (parse_mod_parms()) return -EINVAL; @@ -197,7 +195,7 @@ int init_module(void) res=register_chrdev(major,DEVICE_NAME, &can_fops); if (res<0) { CANMSG("Error registering driver.\n"); - return -ENODEV; + goto register_error; } #ifdef CAN_WITH_RTL @@ -213,7 +211,7 @@ int init_module(void) for (i=0; inr_boards; i++) { candev=hardware_p->candevice[i]; if (candev->hwspecops->request_io(candev)) - goto memory_error; + goto request_io_error; candev->flags|=CANDEV_IO_RESERVED; } @@ -231,15 +229,25 @@ int init_module(void) for(j=0; jnr_all_chips; j++) { if((chip=candev->chip[j])==NULL) continue; + + if(chip->chipspecops->attach_to_chip(chip)<0) { + CANMSG("Initial attach to the chip HW failed\n"); + goto interrupt_error; + } + + chip->flags |= CHIP_ATTACHED; + if(can_chip_setup_irq(chip)<0) { - CANMSG("IRQ setup failed\n"); + CANMSG("Error to setup chip IRQ\n"); goto interrupt_error; } } - + if (candev->flags & CANDEV_PROGRAMMABLE_IRQ) - if (candev->hwspecops->program_irq(candev)) + if (candev->hwspecops->program_irq(candev)){ + CANMSG("Error to program board interrupt\n"); goto interrupt_error; + } } #ifdef CONFIG_PROC_FS @@ -249,7 +257,9 @@ int init_module(void) #ifdef CONFIG_DEVFS_FS { + #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,50)) char dev_name[32]; + #endif int dev_minor; for(i=0;i