aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-10-02 17:09:56 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:55:55 -0400
commit835cc24aff0fd4b9da9d0a45d9bd043adcb2cf89 (patch)
treecabe4c3c01410a4a3ad4d2b3021f3a2d6350529e /drivers
parent10e1b4bc9238687a4b1311bd5b6769d6b8c704e6 (diff)
[SCSI] gdth: switch to modern scsi host registration
- Use scsi_add_host and friends and track instances ourselves. And generally modernize the driver's structure. - TODO: Next we can remove the controller table - TODO: Fix use of deprecated pci_find_device() Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/gdth.c320
-rw-r--r--drivers/scsi/gdth.h1
2 files changed, 157 insertions, 164 deletions
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index ef67e664c9e6..11796e61a76b 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -119,6 +119,7 @@
119#include <linux/time.h> 119#include <linux/time.h>
120#include <linux/timer.h> 120#include <linux/timer.h>
121#include <linux/dma-mapping.h> 121#include <linux/dma-mapping.h>
122#include <linux/list.h>
122 123
123#ifdef GDTH_RTC 124#ifdef GDTH_RTC
124#include <linux/mc146818rtc.h> 125#include <linux/mc146818rtc.h>
@@ -184,15 +185,6 @@ static void gdth_flush(gdth_ha_str *ha);
184static int gdth_halt(struct notifier_block *nb, ulong event, void *buf); 185static int gdth_halt(struct notifier_block *nb, ulong event, void *buf);
185static int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *)); 186static int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *));
186static void gdth_scsi_done(struct scsi_cmnd *scp); 187static void gdth_scsi_done(struct scsi_cmnd *scp);
187#ifdef CONFIG_ISA
188static int gdth_isa_probe_one(struct scsi_host_template *, ulong32);
189#endif
190#ifdef CONFIG_EISA
191static int gdth_eisa_probe_one(struct scsi_host_template *, ushort);
192#endif
193#ifdef CONFIG_PCI
194static int gdth_pci_probe_one(struct scsi_host_template *, gdth_pci_str *, int);
195#endif
196 188
197#ifdef DEBUG_GDTH 189#ifdef DEBUG_GDTH
198static unchar DebugState = DEBUG_GDTH; 190static unchar DebugState = DEBUG_GDTH;
@@ -298,8 +290,8 @@ static unchar gdth_irq_tab[6] = {0,10,11,12,14,0}; /* IRQ table */
298#endif 290#endif
299static unchar gdth_polling; /* polling if TRUE */ 291static unchar gdth_polling; /* polling if TRUE */
300static int gdth_ctr_count = 0; /* controller count */ 292static int gdth_ctr_count = 0; /* controller count */
301static int gdth_ctr_released = 0; /* gdth_release() */
302static struct Scsi_Host *gdth_ctr_tab[MAXHA]; /* controller table */ 293static struct Scsi_Host *gdth_ctr_tab[MAXHA]; /* controller table */
294static LIST_HEAD(gdth_instances);
303static unchar gdth_write_through = FALSE; /* write through */ 295static unchar gdth_write_through = FALSE; /* write through */
304static gdth_evt_str ebuffer[MAX_EVENTS]; /* event buffer */ 296static gdth_evt_str ebuffer[MAX_EVENTS]; /* event buffer */
305static int elastidx; 297static int elastidx;
@@ -3872,145 +3864,6 @@ int __init option_setup(char *str)
3872 return 1; 3864 return 1;
3873} 3865}
3874 3866
3875static int __init gdth_detect(struct scsi_host_template *shtp)
3876{
3877#ifdef DEBUG_GDTH
3878 printk("GDT: This driver contains debugging information !! Trace level = %d\n",
3879 DebugState);
3880 printk(" Destination of debugging information: ");
3881#ifdef __SERIAL__
3882#ifdef __COM2__
3883 printk("Serial port COM2\n");
3884#else
3885 printk("Serial port COM1\n");
3886#endif
3887#else
3888 printk("Console\n");
3889#endif
3890 gdth_delay(3000);
3891#endif
3892
3893 TRACE(("gdth_detect()\n"));
3894
3895 if (disable) {
3896 printk("GDT-HA: Controller driver disabled from command line !\n");
3897 return 0;
3898 }
3899
3900 printk("GDT-HA: Storage RAID Controller Driver. Version: %s\n",GDTH_VERSION_STR);
3901 /* initializations */
3902 gdth_polling = TRUE;
3903 gdth_clear_events();
3904
3905 /* As default we do not probe for EISA or ISA controllers */
3906 if (probe_eisa_isa) {
3907 /* scanning for controllers, at first: ISA controller */
3908#ifdef CONFIG_ISA
3909 ulong32 isa_bios;
3910 for (isa_bios = 0xc8000UL; isa_bios <= 0xd8000UL;
3911 isa_bios += 0x8000UL) {
3912 if (gdth_ctr_count >= MAXHA)
3913 break;
3914 gdth_isa_probe_one(shtp, isa_bios);
3915 }
3916#endif
3917#ifdef CONFIG_EISA
3918 {
3919 ushort eisa_slot;
3920 for (eisa_slot = 0x1000; eisa_slot <= 0x8000; eisa_slot += 0x1000) {
3921 if (gdth_ctr_count >= MAXHA)
3922 break;
3923 gdth_eisa_probe_one(shtp, eisa_slot);
3924 }
3925 }
3926#endif
3927 }
3928
3929#ifdef CONFIG_PCI
3930 /* scanning for PCI controllers */
3931 {
3932 gdth_pci_str pcistr[MAXHA];
3933 int cnt,ctr;
3934
3935 cnt = gdth_search_pci(pcistr);
3936 printk("GDT-HA: Found %d PCI Storage RAID Controllers\n",cnt);
3937 gdth_sort_pci(pcistr,cnt);
3938 for (ctr = 0; ctr < cnt; ++ctr) {
3939 if (gdth_ctr_count >= MAXHA)
3940 break;
3941 gdth_pci_probe_one(shtp, pcistr, ctr);
3942 }
3943 }
3944#endif /* CONFIG_PCI */
3945
3946 TRACE2(("gdth_detect() %d controller detected\n",gdth_ctr_count));
3947 if (gdth_ctr_count > 0) {
3948#ifdef GDTH_STATISTICS
3949 TRACE2(("gdth_detect(): Initializing timer !\n"));
3950 init_timer(&gdth_timer);
3951 gdth_timer.expires = jiffies + HZ;
3952 gdth_timer.data = 0L;
3953 gdth_timer.function = gdth_timeout;
3954 add_timer(&gdth_timer);
3955#endif
3956 major = register_chrdev(0,"gdth",&gdth_fops);
3957 notifier_disabled = 0;
3958 register_reboot_notifier(&gdth_notifier);
3959 }
3960 gdth_polling = FALSE;
3961 return gdth_ctr_count;
3962}
3963
3964static int gdth_release(struct Scsi_Host *shp)
3965{
3966 gdth_ha_str *ha = shost_priv(shp);
3967
3968 TRACE2(("gdth_release()\n"));
3969 if (ha->sdev) {
3970 scsi_free_host_dev(ha->sdev);
3971 ha->sdev = NULL;
3972 }
3973 gdth_flush(ha);
3974
3975 if (shp->irq) {
3976 free_irq(shp->irq,ha);
3977 }
3978#ifdef CONFIG_ISA
3979 if (shp->dma_channel != 0xff) {
3980 free_dma(shp->dma_channel);
3981 }
3982#endif
3983#ifdef INT_COAL
3984 if (ha->coal_stat)
3985 pci_free_consistent(ha->pdev, sizeof(gdth_coal_status) *
3986 MAXOFFSETS, ha->coal_stat, ha->coal_stat_phys);
3987#endif
3988 if (ha->pscratch)
3989 pci_free_consistent(ha->pdev, GDTH_SCRATCH,
3990 ha->pscratch, ha->scratch_phys);
3991 if (ha->pmsg)
3992 pci_free_consistent(ha->pdev, sizeof(gdth_msg_str),
3993 ha->pmsg, ha->msg_phys);
3994 if (ha->ccb_phys)
3995 pci_unmap_single(ha->pdev,ha->ccb_phys,
3996 sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL);
3997 gdth_ctr_released++;
3998 TRACE2(("gdth_release(): HA %d of %d\n",
3999 gdth_ctr_released, gdth_ctr_count));
4000
4001 if (gdth_ctr_released == gdth_ctr_count) {
4002#ifdef GDTH_STATISTICS
4003 del_timer(&gdth_timer);
4004#endif
4005 unregister_chrdev(major,"gdth");
4006 unregister_reboot_notifier(&gdth_notifier);
4007 }
4008
4009 scsi_unregister(shp);
4010 return 0;
4011}
4012
4013
4014static const char *gdth_ctr_name(gdth_ha_str *ha) 3867static const char *gdth_ctr_name(gdth_ha_str *ha)
4015{ 3868{
4016 TRACE2(("gdth_ctr_name()\n")); 3869 TRACE2(("gdth_ctr_name()\n"));
@@ -4819,10 +4672,8 @@ static int gdth_slave_configure(struct scsi_device *sdev)
4819 return 0; 4672 return 0;
4820} 4673}
4821 4674
4822static struct scsi_host_template driver_template = { 4675static struct scsi_host_template gdth_template = {
4823 .name = "GDT SCSI Disk Array Controller", 4676 .name = "GDT SCSI Disk Array Controller",
4824 .detect = gdth_detect,
4825 .release = gdth_release,
4826 .info = gdth_info, 4677 .info = gdth_info,
4827 .queuecommand = gdth_queuecommand, 4678 .queuecommand = gdth_queuecommand,
4828 .eh_bus_reset_handler = gdth_eh_bus_reset, 4679 .eh_bus_reset_handler = gdth_eh_bus_reset,
@@ -4839,7 +4690,7 @@ static struct scsi_host_template driver_template = {
4839}; 4690};
4840 4691
4841#ifdef CONFIG_ISA 4692#ifdef CONFIG_ISA
4842static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios) 4693static int gdth_isa_probe_one(ulong32 isa_bios)
4843{ 4694{
4844 struct Scsi_Host *shp; 4695 struct Scsi_Host *shp;
4845 gdth_ha_str *ha; 4696 gdth_ha_str *ha;
@@ -4849,7 +4700,7 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios)
4849 if (!gdth_search_isa(isa_bios)) 4700 if (!gdth_search_isa(isa_bios))
4850 return -ENXIO; 4701 return -ENXIO;
4851 4702
4852 shp = scsi_register(shtp, sizeof(gdth_ha_str)); 4703 shp = scsi_host_alloc(&gdth_template, sizeof(gdth_ha_str));
4853 if (!shp) 4704 if (!shp)
4854 return -ENOMEM; 4705 return -ENOMEM;
4855 ha = shost_priv(shp); 4706 ha = shost_priv(shp);
@@ -4941,6 +4792,10 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios)
4941 spin_lock_init(&ha->smp_lock); 4792 spin_lock_init(&ha->smp_lock);
4942 gdth_enable_int(ha); 4793 gdth_enable_int(ha);
4943 4794
4795 error = scsi_add_host(shp, NULL);
4796 if (error)
4797 goto out_free_coal_stat;
4798 list_add_tail(&ha->list, &gdth_instances);
4944 return 0; 4799 return 0;
4945 4800
4946 out_free_coal_stat: 4801 out_free_coal_stat:
@@ -4959,14 +4814,13 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios)
4959 out_free_irq: 4814 out_free_irq:
4960 free_irq(ha->irq, ha); 4815 free_irq(ha->irq, ha);
4961 out_host_put: 4816 out_host_put:
4962 scsi_unregister(shp); 4817 scsi_host_put(shp);
4963 return error; 4818 return error;
4964} 4819}
4965#endif /* CONFIG_ISA */ 4820#endif /* CONFIG_ISA */
4966 4821
4967#ifdef CONFIG_EISA 4822#ifdef CONFIG_EISA
4968static int gdth_eisa_probe_one(struct scsi_host_template *shtp, 4823static int gdth_eisa_probe_one(ushort eisa_slot)
4969 ushort eisa_slot)
4970{ 4824{
4971 struct Scsi_Host *shp; 4825 struct Scsi_Host *shp;
4972 gdth_ha_str *ha; 4826 gdth_ha_str *ha;
@@ -4976,7 +4830,7 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp,
4976 if (!gdth_search_eisa(eisa_slot)) 4830 if (!gdth_search_eisa(eisa_slot))
4977 return -ENXIO; 4831 return -ENXIO;
4978 4832
4979 shp = scsi_register(shtp,sizeof(gdth_ha_str)); 4833 shp = scsi_host_alloc(&gdth_template, sizeof(gdth_ha_str));
4980 if (!shp) 4834 if (!shp)
4981 return -ENOMEM; 4835 return -ENOMEM;
4982 ha = shost_priv(shp); 4836 ha = shost_priv(shp);
@@ -5066,6 +4920,11 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp,
5066 4920
5067 spin_lock_init(&ha->smp_lock); 4921 spin_lock_init(&ha->smp_lock);
5068 gdth_enable_int(ha); 4922 gdth_enable_int(ha);
4923
4924 error = scsi_add_host(shp, NULL);
4925 if (error)
4926 goto out_free_coal_stat;
4927 list_add_tail(&ha->list, &gdth_instances);
5069 return 0; 4928 return 0;
5070 4929
5071 out_free_ccb_phys: 4930 out_free_ccb_phys:
@@ -5086,21 +4945,20 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp,
5086 free_irq(ha->irq, ha); 4945 free_irq(ha->irq, ha);
5087 gdth_ctr_count--; 4946 gdth_ctr_count--;
5088 out_host_put: 4947 out_host_put:
5089 scsi_unregister(shp); 4948 scsi_host_put(shp);
5090 return error; 4949 return error;
5091} 4950}
5092#endif /* CONFIG_EISA */ 4951#endif /* CONFIG_EISA */
5093 4952
5094#ifdef CONFIG_PCI 4953#ifdef CONFIG_PCI
5095static int gdth_pci_probe_one(struct scsi_host_template *shtp, 4954static int gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr)
5096 gdth_pci_str *pcistr, int ctr)
5097{ 4955{
5098 struct Scsi_Host *shp; 4956 struct Scsi_Host *shp;
5099 gdth_ha_str *ha; 4957 gdth_ha_str *ha;
5100 dma_addr_t scratch_dma_handle = 0; 4958 dma_addr_t scratch_dma_handle = 0;
5101 int error, hanum, i; 4959 int error, hanum, i;
5102 4960
5103 shp = scsi_register(shtp,sizeof(gdth_ha_str)); 4961 shp = scsi_host_alloc(&gdth_template, sizeof(gdth_ha_str));
5104 if (!shp) 4962 if (!shp)
5105 return -ENOMEM; 4963 return -ENOMEM;
5106 ha = shost_priv(shp); 4964 ha = shost_priv(shp);
@@ -5201,6 +5059,11 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp,
5201 5059
5202 spin_lock_init(&ha->smp_lock); 5060 spin_lock_init(&ha->smp_lock);
5203 gdth_enable_int(ha); 5061 gdth_enable_int(ha);
5062
5063 error = scsi_add_host(shp, &pcistr[ctr].pdev->dev);
5064 if (error)
5065 goto out_free_coal_stat;
5066 list_add_tail(&ha->list, &gdth_instances);
5204 return 0; 5067 return 0;
5205 5068
5206 out_free_coal_stat: 5069 out_free_coal_stat:
@@ -5218,12 +5081,141 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp,
5218 free_irq(ha->irq, ha); 5081 free_irq(ha->irq, ha);
5219 gdth_ctr_count--; 5082 gdth_ctr_count--;
5220 out_host_put: 5083 out_host_put:
5221 scsi_unregister(shp); 5084 scsi_host_put(shp);
5222 return error; 5085 return error;
5223} 5086}
5224#endif /* CONFIG_PCI */ 5087#endif /* CONFIG_PCI */
5225 5088
5226#include "scsi_module.c" 5089static void gdth_remove_one(gdth_ha_str *ha)
5090{
5091 struct Scsi_Host *shp = ha->shost;
5092
5093 TRACE2(("gdth_remove_one()\n"));
5094
5095 scsi_remove_host(shp);
5096
5097 if (ha->sdev) {
5098 scsi_free_host_dev(ha->sdev);
5099 ha->sdev = NULL;
5100 }
5101
5102 gdth_flush(ha);
5103
5104 if (shp->irq)
5105 free_irq(shp->irq,ha);
5106
5107#ifdef CONFIG_ISA
5108 if (shp->dma_channel != 0xff)
5109 free_dma(shp->dma_channel);
5110#endif
5111#ifdef INT_COAL
5112 if (ha->coal_stat)
5113 pci_free_consistent(ha->pdev, sizeof(gdth_coal_status) *
5114 MAXOFFSETS, ha->coal_stat, ha->coal_stat_phys);
5115#endif
5116 if (ha->pscratch)
5117 pci_free_consistent(ha->pdev, GDTH_SCRATCH,
5118 ha->pscratch, ha->scratch_phys);
5119 if (ha->pmsg)
5120 pci_free_consistent(ha->pdev, sizeof(gdth_msg_str),
5121 ha->pmsg, ha->msg_phys);
5122 if (ha->ccb_phys)
5123 pci_unmap_single(ha->pdev,ha->ccb_phys,
5124 sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL);
5125
5126 scsi_host_put(shp);
5127}
5128
5129static int __init gdth_init(void)
5130{
5131 if (disable) {
5132 printk("GDT-HA: Controller driver disabled from"
5133 " command line !\n");
5134 return 0;
5135 }
5136
5137 printk("GDT-HA: Storage RAID Controller Driver. Version: %s\n",
5138 GDTH_VERSION_STR);
5139
5140 /* initializations */
5141 gdth_polling = TRUE;
5142 gdth_clear_events();
5143
5144 /* As default we do not probe for EISA or ISA controllers */
5145 if (probe_eisa_isa) {
5146 /* scanning for controllers, at first: ISA controller */
5147#ifdef CONFIG_ISA
5148 ulong32 isa_bios;
5149 for (isa_bios = 0xc8000UL; isa_bios <= 0xd8000UL;
5150 isa_bios += 0x8000UL) {
5151 if (gdth_ctr_count >= MAXHA)
5152 break;
5153 gdth_isa_probe_one(isa_bios);
5154 }
5155#endif
5156#ifdef CONFIG_EISA
5157 {
5158 ushort eisa_slot;
5159 for (eisa_slot = 0x1000; eisa_slot <= 0x8000;
5160 eisa_slot += 0x1000) {
5161 if (gdth_ctr_count >= MAXHA)
5162 break;
5163 gdth_eisa_probe_one(eisa_slot);
5164 }
5165 }
5166#endif
5167 }
5168
5169#ifdef CONFIG_PCI
5170 /* scanning for PCI controllers */
5171 {
5172 gdth_pci_str pcistr[MAXHA];
5173 int cnt,ctr;
5174
5175 cnt = gdth_search_pci(pcistr);
5176 printk("GDT-HA: Found %d PCI Storage RAID Controllers\n", cnt);
5177 gdth_sort_pci(pcistr,cnt);
5178 for (ctr = 0; ctr < cnt; ++ctr) {
5179 if (gdth_ctr_count >= MAXHA)
5180 break;
5181 gdth_pci_probe_one(pcistr, ctr);
5182 }
5183 }
5184#endif /* CONFIG_PCI */
5185
5186 TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count));
5187#ifdef GDTH_STATISTICS
5188 TRACE2(("gdth_detect(): Initializing timer !\n"));
5189 init_timer(&gdth_timer);
5190 gdth_timer.expires = jiffies + HZ;
5191 gdth_timer.data = 0L;
5192 gdth_timer.function = gdth_timeout;
5193 add_timer(&gdth_timer);
5194#endif
5195 major = register_chrdev(0,"gdth", &gdth_fops);
5196 notifier_disabled = 0;
5197 register_reboot_notifier(&gdth_notifier);
5198 gdth_polling = FALSE;
5199 return 0;
5200}
5201
5202static void __exit gdth_exit(void)
5203{
5204 gdth_ha_str *ha;
5205
5206 list_for_each_entry(ha, &gdth_instances, list)
5207 gdth_remove_one(ha);
5208
5209#ifdef GDTH_STATISTICS
5210 del_timer(&gdth_timer);
5211#endif
5212 unregister_chrdev(major,"gdth");
5213 unregister_reboot_notifier(&gdth_notifier);
5214}
5215
5216module_init(gdth_init);
5217module_exit(gdth_exit);
5218
5227#ifndef MODULE 5219#ifndef MODULE
5228__setup("gdth=", option_setup); 5220__setup("gdth=", option_setup);
5229#endif 5221#endif
diff --git a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h
index e8b9eb771d36..e6178c421855 100644
--- a/drivers/scsi/gdth.h
+++ b/drivers/scsi/gdth.h
@@ -854,6 +854,7 @@ typedef struct {
854/* controller information structure */ 854/* controller information structure */
855typedef struct { 855typedef struct {
856 struct Scsi_Host *shost; 856 struct Scsi_Host *shost;
857 struct list_head list;
857 ushort hanum; 858 ushort hanum;
858 ushort oem_id; /* OEM */ 859 ushort oem_id; /* OEM */
859 ushort type; /* controller class */ 860 ushort type; /* controller class */