/*
  * Structure allocated for each board.
  *
- * This structure is allocated by scsi_register() at the end
+ * This structure is allocated by scsi_host_alloc() at the end
  * of the 'Scsi_Host' structure starting at the 'hostdata'
  * field. It is guaranteed to be allocated from DMA-able memory.
  */
        return 0;
 }
 
-static int __init advansys_detect(struct scsi_host_template *tpnt);
-static int advansys_release(struct Scsi_Host *shp);
-
-static struct scsi_host_template driver_template = {
+static struct scsi_host_template advansys_template = {
        .proc_name = "advansys",
 #ifdef CONFIG_PROC_FS
        .proc_info = advansys_proc_info,
 #endif
        .name = "advansys",
-       .detect = advansys_detect,
-       .release = advansys_release,
        .info = advansys_info,
        .queuecommand = advansys_queuecommand,
        .eh_bus_reset_handler = advansys_reset,
        .slave_configure = advansys_slave_configure,
        /*
         * Because the driver may control an ISA adapter 'unchecked_isa_dma'
-        * must be set. The flag will be cleared in advansys_detect for non-ISA
-        * adapters. Refer to the comment in scsi_module.c for more information.
+        * must be set. The flag will be cleared in advansys_board_found
+        * for non-ISA adapters.
         */
        .unchecked_isa_dma = 1,
        /*
        .use_clustering = ENABLE_CLUSTERING,
 };
 
-#include "scsi_module.c"
-
 /*
  * --- Miscellaneous Driver Functions
  */
         * Register the adapter, get its configuration, and
         * initialize it.
         */
-       ASC_DBG(2, "advansys_board_found: scsi_register()\n");
-       shost = scsi_register(&driver_template, sizeof(asc_board_t));
+       ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n");
+       shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t));
 
        if (!shost)
                return NULL;
 
        ASC_DBG_PRT_SCSI_HOST(2, shost);
 
+       ret = scsi_add_host(shost, dev);
+       if (ret)
+               goto err_free_wide_mem;
+
+       scsi_scan_host(shost);
        return shost;
 
  err_free_wide_mem:
        if (boardp->ioremap_addr)
                iounmap(boardp->ioremap_addr);
  err_shost:
-       scsi_unregister(shost);
+       scsi_host_put(shost);
        asc_board_count--;
        return NULL;
 }
  * it must not call SCSI mid-level functions including scsi_malloc()
  * and scsi_free().
  */
-static int __init advansys_detect(struct scsi_host_template *tpnt)
+static int __init advansys_detect(void)
 {
-       static int detect_called = ASC_FALSE;
        int iop;
        int bus;
        int ioport = 0;
        };
 #endif /* CONFIG_PCI */
 
-       if (detect_called == ASC_FALSE) {
-               detect_called = ASC_TRUE;
-       } else {
-               printk
-                   ("AdvanSys SCSI: advansys_detect() multiple calls ignored\n");
-               return 0;
-       }
-
        ASC_DBG(1, "advansys_detect: begin\n");
 
        asc_board_count = 0;
        asc_board_t *boardp;
 
        ASC_DBG(1, "advansys_release: begin\n");
+       scsi_remove_host(shost);
        boardp = ASC_BOARDP(shost);
        free_irq(shost->irq, shost);
        if (shost->dma_channel != NO_ISA_DMA) {
                advansys_wide_free_mem(boardp);
        }
        kfree(boardp->prtbuf);
-       scsi_unregister(shost);
+       scsi_host_put(shost);
        ASC_DBG(1, "advansys_release: end\n");
        return 0;
 }
 MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
 #endif /* CONFIG_PCI */
 
+static int __init advansys_init(void)
+{
+       int count;
+       count = advansys_detect();
+       if (count == 0)
+               return -ENODEV;
+
+       return 0;
+}
+
+static void __exit advansys_exit(void)
+{
+       int i;
+
+       for (i = 0; i < asc_board_count; i++)
+               advansys_release(asc_host[i]);
+}
+
+module_init(advansys_init);
+module_exit(advansys_exit);
+
 MODULE_LICENSE("GPL");