/* 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))
{
int res=0,i=0, j;
struct candevice_t *candev;
- struct chip_t *chip;
+ struct canchip_t *chip;
if (parse_mod_parms())
return -EINVAL;
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
for (i=0; i<hardware_p->nr_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;
}
for(j=0; j<candev->nr_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
#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<MAX_TOT_MSGOBJS;i++) {
if(!objects_p[i]) continue;
#endif
interrupt_error: ;
- CANMSG("Error registering interrupt line.\n");
goto memory_error;
reset_error: ;
+ CANMSG("Error resetting device.\n");
+ goto memory_error;
+
+ request_io_error: ;
+ CANMSG("Error to request IO resources for device.\n");
goto memory_error;
memory_error: ;
CANMSG("Error unloading CAN driver, error: %d\n",res);
else
CANMSG("No CAN devices or driver setup error.\n");
- return -ENODEV;
+ register_error:
+ if ( can_del_mem_list() )
+ CANMSG("Error deallocating memory\n");
+
+ return -ENODEV;
}
void cleanup_module(void)