/* Called by modules package when installing the driver * or by kernel during the initialization phase */ static int __init ftape_init(void) { TRACE_FUN(ft_t_flow); #ifdef MODULE #ifndef CONFIG_FT_NO_TRACE_AT_ALL if (ft_tracing != -1) { ftape_tracing = ft_tracing; } #endif printk(KERN_INFO FTAPE_VERSION "\n"); if (TRACE_LEVEL >= ft_t_info) { printk( KERN_INFO "(c) 1993-1996 Bas Laarhoven ([email protected])\n" KERN_INFO "(c) 1995-1996 Kai Harrekilde-Petersen ([email protected])\n" KERN_INFO "(c) 1996-1997 Claus-Justus Heine ([email protected])\n" KERN_INFO "QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives\n" KERN_INFO "Compiled for Linux version %s\n", UTS_RELEASE); } #else /* !MODULE */ /* print a short no-nonsense boot message */ printk(KERN_INFO FTAPE_VERSION " for Linux " UTS_RELEASE "\n"); #endif /* MODULE */ TRACE(ft_t_info, "installing QIC-117 floppy tape hardware drive ... "); TRACE(ft_t_info, "ftape_init @ 0x%p", ftape_init); /* Allocate the DMA buffers. They are deallocated at cleanup() time. */ #if TESTING #ifdef MODULE while (ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS) < 0) { ftape_sleep(FT_SECOND/20); if (signal_pending(current)) { (void)ftape_set_nr_buffers(0); TRACE(ft_t_bug, "Killed by signal while allocating buffers."); TRACE_ABORT(-EINTR, ft_t_bug, "Free up memory and retry"); } } #else TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS), (void)ftape_set_nr_buffers(0)); #endif #else TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS), (void)ftape_set_nr_buffers(0)); #endif ft_drive_sel = -1; ft_failure = 1; /* inhibit any operation but open */ ftape_udelay_calibrate(); /* must be before fdc_wait_calibrate ! */ fdc_wait_calibrate(); #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS) (void)ftape_proc_init(); #endif #ifdef CONFIG_ZFTAPE (void)zft_init(); #endif TRACE_EXIT 0; }
int ftape_init(void) { int n; int order; TRACE_FUN(5, "ftape_init"); #ifdef MODULE printk(KERN_INFO "ftape-2.08 960314\n" KERN_INFO " (c) 1993-1995 Bas Laarhoven ([email protected])\n" KERN_INFO " (c) 1995-1996 Kai Harrekilde-Petersen ([email protected])\n" KERN_INFO " QIC-117 driver for QIC-40/80/3010/3020 tape drives\n" KERN_INFO " Compiled for kernel version %s" #ifdef MODVERSIONS " with versioned symbols" #endif "\n", kernel_version); #else /* !MODULE */ /* print a short no-nonsense boot message */ printk("ftape-2.08 960314 for Linux 1.3.70\n"); #endif /* MODULE */ TRACE(3, "installing QIC-117 ftape driver..."); if (register_chrdev(QIC117_TAPE_MAJOR, "ft", &ftape_cdev)) { TRACE(1, "register_chrdev failed"); TRACE_EXIT; return -EIO; } TRACEx1(3, "ftape_init @ 0x%p", ftape_init); /* * Allocate the DMA buffers. They are deallocated at cleanup() time. */ order = __get_order(BUFF_SIZE); for (n = 0; n < NR_BUFFERS; n++) { tape_buffer[n] = (byte *) dmaalloc(order); if (!tape_buffer[n]) { TRACE(1, "dmaalloc() failed"); for (n = 0; n < NR_BUFFERS; n++) { if (tape_buffer[n]) { dmafree(tape_buffer[n], order); tape_buffer[n] = NULL; } } current->blocked = old_sigmask; /* restore mask */ if (unregister_chrdev(QIC117_TAPE_MAJOR, "ft") != 0) { TRACE(3, "unregister_chrdev failed"); } TRACE_EXIT; return -ENOMEM; } else { TRACEx2(3, "dma-buffer #%d @ %p", n, tape_buffer[n]); } } busy_flag = 0; ftape_unit = -1; ftape_failure = 1; /* inhibit any operation but open */ udelay_calibrate(); /* must be before fdc_wait_calibrate ! */ fdc_wait_calibrate(); TRACE_EXIT; #ifdef MODULE register_symtab(0); /* remove global ftape symbols */ #endif return 0; }