static int __init pio2_init(void) { int retval = 0; if (bus_num == 0) { printk(KERN_ERR "%s: No cards, skipping registration\n", driver_name); goto err_nocard; } if (bus_num > PIO2_CARDS_MAX) { printk(KERN_ERR "%s: Driver only able to handle %d PIO2 Cards\n", driver_name, PIO2_CARDS_MAX); bus_num = PIO2_CARDS_MAX; } /* Register the PIO2 driver */ retval = vme_register_driver(&pio2_driver, bus_num); if (retval != 0) goto err_reg; return retval; err_reg: err_nocard: return retval; }
static int __init tvme200_init(void) { int error = 0; printk(KERN_INFO PFX "Carrier driver loading...\n"); error = tvme200_check_params(); if (error) return -EINVAL; carrier_boards = (struct tvme200_board*) kzalloc(num_lun * sizeof(struct tvme200_board), GFP_KERNEL); if (carrier_boards == NULL) { printk(KERN_ERR PFX "Unable to allocate carrier boards structure !\n"); return -ENOMEM; } error = vme_register_driver(&tvme200_driver, num_lun); if (error) { pr_err("%s: Cannot register vme driver - lun [%d]\n", __func__, num_lun); return error; } printk(KERN_INFO PFX "Carrier driver loaded.\n"); return 0; }
static int __init cvorb_init_module(void) { int error, i; /* Check Parameters */ if (num_lun > CVORB_MAX_BOARDS) { printk(KERN_ERR PFX "Number of boards to install exceed the limit (%d)\n", CVORB_MAX_BOARDS); return -EINVAL; } /* * Check if the difference between base addresses * is more that the board size */ for (i = 1; i < num_lun; ++i) { if ((base_address[i] - base_address[i - 1]) < CVORB_WINDOW_LENGTH) { printk(KERN_ERR PFX "base address are not correct(doesn't respect \n"); return -EINVAL; } } /* create device class */ cvorb_class = class_create(THIS_MODULE, "cvorb"); if (IS_ERR(cvorb_class)) { printk(KERN_ERR PFX "Failed to create cvorb class\n"); error = PTR_ERR(cvorb_class); /* nothing to clean, just returns the error */ return error; } /* Get a range of minor numbers (starting with 0) to work with */ error = alloc_chrdev_region(&cvorb_devno, 0, num_lun, DRIVER_NAME); if (error < 0) { printk(KERN_ERR PFX "Failed to allocate chrdev region\n"); goto alloc_chrdev_region_failed; } /* some sysfs initialization before instantiating the devices */ error = cvorb_sysfs_init_module(); if (error) { printk(KERN_ERR PFX "Failed initializing sysfs at module installation.(-ENOMEM) \n"); goto alloc_chrdev_region_failed; } error = vme_register_driver(&cvorb_driver, num_lun); if (error) { printk(KERN_ERR PFX "Could not register vme cvorb driver \n"); goto alloc_chrdev_region_failed; } return 0; alloc_chrdev_region_failed: class_destroy(cvorb_class); return error; }
static int __init vme_user_init(void) { int retval = 0; int i; struct vme_device_id *ids; printk(KERN_INFO "VME User Space Access Driver\n"); if (bus_num == 0) { printk(KERN_ERR "%s: No cards, skipping registration\n", driver_name); goto err_nocard; } /* Let's start by supporting one bus, we can support more than one * in future revisions if that ever becomes necessary. */ if (bus_num > USER_BUS_MAX) { printk(KERN_ERR "%s: Driver only able to handle %d PIO2 " "Cards\n", driver_name, USER_BUS_MAX); bus_num = USER_BUS_MAX; } /* Dynamically create the bind table based on module parameters */ ids = kmalloc(sizeof(struct vme_device_id) * (bus_num + 1), GFP_KERNEL); if (ids == NULL) { printk(KERN_ERR "%s: Unable to allocate ID table\n", driver_name); goto err_id; } memset(ids, 0, (sizeof(struct vme_device_id) * (bus_num + 1))); for (i = 0; i < bus_num; i++) { ids[i].bus = bus[i]; /* * We register the driver against the slot occupied by *this* * card, since it's really a low level way of controlling * the VME bridge */ ids[i].slot = VME_SLOT_CURRENT; } vme_user_driver.bind_table = ids; retval = vme_register_driver(&vme_user_driver); if (retval != 0) goto err_reg; return retval; vme_unregister_driver(&vme_user_driver); err_reg: kfree(ids); err_id: err_nocard: return retval; }
static int __init pio2_init(void) { if (bus_num == 0) { pr_err("No cards, skipping registration\n"); return -ENODEV; } if (bus_num > PIO2_CARDS_MAX) { pr_err("Driver only able to handle %d PIO2 Cards\n", PIO2_CARDS_MAX); bus_num = PIO2_CARDS_MAX; } /* Register the PIO2 driver */ return vme_register_driver(&pio2_driver, bus_num); }