in maple/maple.c [794:893]
static int __init maple_bus_init(void)
{
int retval, i;
struct maple_device *mdev[MAPLE_PORTS];
__raw_writel(0, MAPLE_ENABLE);
retval = device_register(&maple_bus);
if (retval)
goto cleanup;
retval = bus_register(&maple_bus_type);
if (retval)
goto cleanup_device;
retval = driver_register(&maple_unsupported_device.drv);
if (retval)
goto cleanup_bus;
/* allocate memory for maple bus dma */
retval = maple_get_dma_buffer();
if (retval) {
dev_err(&maple_bus, "failed to allocate DMA buffers\n");
goto cleanup_basic;
}
/* set up DMA interrupt handler */
retval = maple_set_dma_interrupt_handler();
if (retval) {
dev_err(&maple_bus, "bus failed to grab maple "
"DMA IRQ\n");
goto cleanup_dma;
}
/* set up VBLANK interrupt handler */
retval = maple_set_vblank_interrupt_handler();
if (retval) {
dev_err(&maple_bus, "bus failed to grab VBLANK IRQ\n");
goto cleanup_irq;
}
maple_queue_cache = KMEM_CACHE(maple_buffer, SLAB_HWCACHE_ALIGN);
if (!maple_queue_cache) {
retval = -ENOMEM;
goto cleanup_bothirqs;
}
INIT_LIST_HEAD(&maple_waitq);
INIT_LIST_HEAD(&maple_sentq);
/* setup maple ports */
for (i = 0; i < MAPLE_PORTS; i++) {
checked[i] = false;
empty[i] = false;
mdev[i] = maple_alloc_dev(i, 0);
if (!mdev[i]) {
while (i-- > 0)
maple_free_dev(mdev[i]);
retval = -ENOMEM;
goto cleanup_cache;
}
baseunits[i] = mdev[i];
atomic_set(&mdev[i]->busy, 1);
maple_add_packet(mdev[i], 0, MAPLE_COMMAND_DEVINFO, 0, NULL);
subdevice_map[i] = 0;
}
maple_pnp_time = jiffies + HZ;
/* prepare initial queue */
maple_send();
dev_info(&maple_bus, "bus core now registered\n");
return 0;
cleanup_cache:
kmem_cache_destroy(maple_queue_cache);
cleanup_bothirqs:
free_irq(HW_EVENT_VSYNC, 0);
cleanup_irq:
free_irq(HW_EVENT_MAPLE_DMA, 0);
cleanup_dma:
free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES);
cleanup_basic:
driver_unregister(&maple_unsupported_device.drv);
cleanup_bus:
bus_unregister(&maple_bus_type);
cleanup_device:
device_unregister(&maple_bus);
cleanup:
printk(KERN_ERR "Maple bus registration failed\n");
return retval;
}