diff options
author | Matthew Wilcox <matthew@wil.cx> | 2007-07-30 11:08:34 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.localdomain> | 2007-10-12 14:38:53 -0400 |
commit | 8dfb537933a87588e83196d14cd9ec245eb065b8 (patch) | |
tree | d4bfeeecdd02e00cd4895dff6a3027f392ea2516 /drivers/scsi/advansys.c | |
parent | b2c16f586ee529e97ac63183e70e2bfd586a2f47 (diff) |
[SCSI] advansys: Move to scsi hotplug initialisation model
- Switch from scsi_register/scsi_unregister to scsi_host_alloc,
scsi_add_host, scsi_scan_host and scsi_host_put.
- Rename the scsi_host_template to advansys_template
- Use module_init and module_exit instead of scsi_module.c
- Remove protection against advansys_detect being called twice
Signed-off-by: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/advansys.c')
-rw-r--r-- | drivers/scsi/advansys.c | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index 303dc98b45c0..8353680b8682 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c | |||
@@ -3793,7 +3793,7 @@ typedef struct adv_req { | |||
3793 | /* | 3793 | /* |
3794 | * Structure allocated for each board. | 3794 | * Structure allocated for each board. |
3795 | * | 3795 | * |
3796 | * This structure is allocated by scsi_register() at the end | 3796 | * This structure is allocated by scsi_host_alloc() at the end |
3797 | * of the 'Scsi_Host' structure starting at the 'hostdata' | 3797 | * of the 'Scsi_Host' structure starting at the 'hostdata' |
3798 | * field. It is guaranteed to be allocated from DMA-able memory. | 3798 | * field. It is guaranteed to be allocated from DMA-able memory. |
3799 | */ | 3799 | */ |
@@ -4632,17 +4632,12 @@ advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev, | |||
4632 | return 0; | 4632 | return 0; |
4633 | } | 4633 | } |
4634 | 4634 | ||
4635 | static int __init advansys_detect(struct scsi_host_template *tpnt); | 4635 | static struct scsi_host_template advansys_template = { |
4636 | static int advansys_release(struct Scsi_Host *shp); | ||
4637 | |||
4638 | static struct scsi_host_template driver_template = { | ||
4639 | .proc_name = "advansys", | 4636 | .proc_name = "advansys", |
4640 | #ifdef CONFIG_PROC_FS | 4637 | #ifdef CONFIG_PROC_FS |
4641 | .proc_info = advansys_proc_info, | 4638 | .proc_info = advansys_proc_info, |
4642 | #endif | 4639 | #endif |
4643 | .name = "advansys", | 4640 | .name = "advansys", |
4644 | .detect = advansys_detect, | ||
4645 | .release = advansys_release, | ||
4646 | .info = advansys_info, | 4641 | .info = advansys_info, |
4647 | .queuecommand = advansys_queuecommand, | 4642 | .queuecommand = advansys_queuecommand, |
4648 | .eh_bus_reset_handler = advansys_reset, | 4643 | .eh_bus_reset_handler = advansys_reset, |
@@ -4650,8 +4645,8 @@ static struct scsi_host_template driver_template = { | |||
4650 | .slave_configure = advansys_slave_configure, | 4645 | .slave_configure = advansys_slave_configure, |
4651 | /* | 4646 | /* |
4652 | * Because the driver may control an ISA adapter 'unchecked_isa_dma' | 4647 | * Because the driver may control an ISA adapter 'unchecked_isa_dma' |
4653 | * must be set. The flag will be cleared in advansys_detect for non-ISA | 4648 | * must be set. The flag will be cleared in advansys_board_found |
4654 | * adapters. Refer to the comment in scsi_module.c for more information. | 4649 | * for non-ISA adapters. |
4655 | */ | 4650 | */ |
4656 | .unchecked_isa_dma = 1, | 4651 | .unchecked_isa_dma = 1, |
4657 | /* | 4652 | /* |
@@ -4664,8 +4659,6 @@ static struct scsi_host_template driver_template = { | |||
4664 | .use_clustering = ENABLE_CLUSTERING, | 4659 | .use_clustering = ENABLE_CLUSTERING, |
4665 | }; | 4660 | }; |
4666 | 4661 | ||
4667 | #include "scsi_module.c" | ||
4668 | |||
4669 | /* | 4662 | /* |
4670 | * --- Miscellaneous Driver Functions | 4663 | * --- Miscellaneous Driver Functions |
4671 | */ | 4664 | */ |
@@ -17839,8 +17832,8 @@ advansys_board_found(int iop, struct device *dev, int bus_type) | |||
17839 | * Register the adapter, get its configuration, and | 17832 | * Register the adapter, get its configuration, and |
17840 | * initialize it. | 17833 | * initialize it. |
17841 | */ | 17834 | */ |
17842 | ASC_DBG(2, "advansys_board_found: scsi_register()\n"); | 17835 | ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n"); |
17843 | shost = scsi_register(&driver_template, sizeof(asc_board_t)); | 17836 | shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t)); |
17844 | 17837 | ||
17845 | if (!shost) | 17838 | if (!shost) |
17846 | return NULL; | 17839 | return NULL; |
@@ -18503,6 +18496,11 @@ advansys_board_found(int iop, struct device *dev, int bus_type) | |||
18503 | 18496 | ||
18504 | ASC_DBG_PRT_SCSI_HOST(2, shost); | 18497 | ASC_DBG_PRT_SCSI_HOST(2, shost); |
18505 | 18498 | ||
18499 | ret = scsi_add_host(shost, dev); | ||
18500 | if (ret) | ||
18501 | goto err_free_wide_mem; | ||
18502 | |||
18503 | scsi_scan_host(shost); | ||
18506 | return shost; | 18504 | return shost; |
18507 | 18505 | ||
18508 | err_free_wide_mem: | 18506 | err_free_wide_mem: |
@@ -18519,7 +18517,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type) | |||
18519 | if (boardp->ioremap_addr) | 18517 | if (boardp->ioremap_addr) |
18520 | iounmap(boardp->ioremap_addr); | 18518 | iounmap(boardp->ioremap_addr); |
18521 | err_shost: | 18519 | err_shost: |
18522 | scsi_unregister(shost); | 18520 | scsi_host_put(shost); |
18523 | asc_board_count--; | 18521 | asc_board_count--; |
18524 | return NULL; | 18522 | return NULL; |
18525 | } | 18523 | } |
@@ -18537,9 +18535,8 @@ advansys_board_found(int iop, struct device *dev, int bus_type) | |||
18537 | * it must not call SCSI mid-level functions including scsi_malloc() | 18535 | * it must not call SCSI mid-level functions including scsi_malloc() |
18538 | * and scsi_free(). | 18536 | * and scsi_free(). |
18539 | */ | 18537 | */ |
18540 | static int __init advansys_detect(struct scsi_host_template *tpnt) | 18538 | static int __init advansys_detect(void) |
18541 | { | 18539 | { |
18542 | static int detect_called = ASC_FALSE; | ||
18543 | int iop; | 18540 | int iop; |
18544 | int bus; | 18541 | int bus; |
18545 | int ioport = 0; | 18542 | int ioport = 0; |
@@ -18561,14 +18558,6 @@ static int __init advansys_detect(struct scsi_host_template *tpnt) | |||
18561 | }; | 18558 | }; |
18562 | #endif /* CONFIG_PCI */ | 18559 | #endif /* CONFIG_PCI */ |
18563 | 18560 | ||
18564 | if (detect_called == ASC_FALSE) { | ||
18565 | detect_called = ASC_TRUE; | ||
18566 | } else { | ||
18567 | printk | ||
18568 | ("AdvanSys SCSI: advansys_detect() multiple calls ignored\n"); | ||
18569 | return 0; | ||
18570 | } | ||
18571 | |||
18572 | ASC_DBG(1, "advansys_detect: begin\n"); | 18561 | ASC_DBG(1, "advansys_detect: begin\n"); |
18573 | 18562 | ||
18574 | asc_board_count = 0; | 18563 | asc_board_count = 0; |
@@ -18829,6 +18818,7 @@ static int advansys_release(struct Scsi_Host *shost) | |||
18829 | asc_board_t *boardp; | 18818 | asc_board_t *boardp; |
18830 | 18819 | ||
18831 | ASC_DBG(1, "advansys_release: begin\n"); | 18820 | ASC_DBG(1, "advansys_release: begin\n"); |
18821 | scsi_remove_host(shost); | ||
18832 | boardp = ASC_BOARDP(shost); | 18822 | boardp = ASC_BOARDP(shost); |
18833 | free_irq(shost->irq, shost); | 18823 | free_irq(shost->irq, shost); |
18834 | if (shost->dma_channel != NO_ISA_DMA) { | 18824 | if (shost->dma_channel != NO_ISA_DMA) { |
@@ -18841,7 +18831,7 @@ static int advansys_release(struct Scsi_Host *shost) | |||
18841 | advansys_wide_free_mem(boardp); | 18831 | advansys_wide_free_mem(boardp); |
18842 | } | 18832 | } |
18843 | kfree(boardp->prtbuf); | 18833 | kfree(boardp->prtbuf); |
18844 | scsi_unregister(shost); | 18834 | scsi_host_put(shost); |
18845 | ASC_DBG(1, "advansys_release: end\n"); | 18835 | ASC_DBG(1, "advansys_release: end\n"); |
18846 | return 0; | 18836 | return 0; |
18847 | } | 18837 | } |
@@ -18867,4 +18857,25 @@ static struct pci_device_id advansys_pci_tbl[] __devinitdata = { | |||
18867 | MODULE_DEVICE_TABLE(pci, advansys_pci_tbl); | 18857 | MODULE_DEVICE_TABLE(pci, advansys_pci_tbl); |
18868 | #endif /* CONFIG_PCI */ | 18858 | #endif /* CONFIG_PCI */ |
18869 | 18859 | ||
18860 | static int __init advansys_init(void) | ||
18861 | { | ||
18862 | int count; | ||
18863 | count = advansys_detect(); | ||
18864 | if (count == 0) | ||
18865 | return -ENODEV; | ||
18866 | |||
18867 | return 0; | ||
18868 | } | ||
18869 | |||
18870 | static void __exit advansys_exit(void) | ||
18871 | { | ||
18872 | int i; | ||
18873 | |||
18874 | for (i = 0; i < asc_board_count; i++) | ||
18875 | advansys_release(asc_host[i]); | ||
18876 | } | ||
18877 | |||
18878 | module_init(advansys_init); | ||
18879 | module_exit(advansys_exit); | ||
18880 | |||
18870 | MODULE_LICENSE("GPL"); | 18881 | MODULE_LICENSE("GPL"); |