aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/dpt_i2o.c
diff options
context:
space:
mode:
authorAndrew Morton <akpm@linux-foundation.org>2007-12-10 18:49:20 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-12-10 22:43:54 -0500
commit24601bbcacb3356657747f2e64317923feb7a1a2 (patch)
treec46a1514433be05c6d3798f627346888df35d6ff /drivers/scsi/dpt_i2o.c
parent43cbe2cbdd5320f1ac785c6f016923609831effe (diff)
revert "dpt_i2o: convert to SCSI hotplug model"
revert commit 55d9fcf57ba5ec427544fca7abc335cf3da78160 Author: Matthew Wilcox <matthew@wil.cx> Date: Mon Jul 30 15:19:18 2007 -0600 [SCSI] dpt_i2o: convert to SCSI hotplug model - Delete refereces to HOSTS_C - Switch to module_init/module_exit instead of detect/release - Don't pass around the host template and rename it to adpt_template - Switch from scsi_register/scsi_unregister to scsi_host_alloc, scsi_add_host, scsi_scan_host and scsi_host_put. Because it caused (for unknown reasons) Andres' all-data-reads-as-zeroes problem, reported at http://groups.google.com/group/fa.linux.kernel/msg/083a9acff0330234 Cc: Matthew Wilcox <matthew@wil.cx> Cc: "Salyzyn, Mark" <mark_salyzyn@adaptec.com> Cc: James Bottomley <James.Bottomley@SteelEye.com> Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Anders Henke <anders.henke@1und1.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/scsi/dpt_i2o.c')
-rw-r--r--drivers/scsi/dpt_i2o.c132
1 files changed, 61 insertions, 71 deletions
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 8258506ba7d7..70f48a1a6d58 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -173,20 +173,20 @@ static struct pci_device_id dptids[] = {
173}; 173};
174MODULE_DEVICE_TABLE(pci,dptids); 174MODULE_DEVICE_TABLE(pci,dptids);
175 175
176static void adpt_exit(void); 176static int adpt_detect(struct scsi_host_template* sht)
177
178static int adpt_detect(void)
179{ 177{
180 struct pci_dev *pDev = NULL; 178 struct pci_dev *pDev = NULL;
181 adpt_hba* pHba; 179 adpt_hba* pHba;
182 180
181 adpt_init();
182
183 PINFO("Detecting Adaptec I2O RAID controllers...\n"); 183 PINFO("Detecting Adaptec I2O RAID controllers...\n");
184 184
185 /* search for all Adatpec I2O RAID cards */ 185 /* search for all Adatpec I2O RAID cards */
186 while ((pDev = pci_get_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) { 186 while ((pDev = pci_get_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) {
187 if(pDev->device == PCI_DPT_DEVICE_ID || 187 if(pDev->device == PCI_DPT_DEVICE_ID ||
188 pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){ 188 pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){
189 if(adpt_install_hba(pDev) ){ 189 if(adpt_install_hba(sht, pDev) ){
190 PERROR("Could not Init an I2O RAID device\n"); 190 PERROR("Could not Init an I2O RAID device\n");
191 PERROR("Will not try to detect others.\n"); 191 PERROR("Will not try to detect others.\n");
192 return hba_count-1; 192 return hba_count-1;
@@ -248,33 +248,34 @@ rebuild_sys_tab:
248 } 248 }
249 249
250 for (pHba = hba_chain; pHba; pHba = pHba->next) { 250 for (pHba = hba_chain; pHba; pHba = pHba->next) {
251 if (adpt_scsi_register(pHba) < 0) { 251 if( adpt_scsi_register(pHba,sht) < 0){
252 adpt_i2o_delete_hba(pHba); 252 adpt_i2o_delete_hba(pHba);
253 continue; 253 continue;
254 } 254 }
255 pHba->initialized = TRUE; 255 pHba->initialized = TRUE;
256 pHba->state &= ~DPTI_STATE_RESET; 256 pHba->state &= ~DPTI_STATE_RESET;
257 scsi_scan_host(pHba->host);
258 } 257 }
259 258
260 // Register our control device node 259 // Register our control device node
261 // nodes will need to be created in /dev to access this 260 // nodes will need to be created in /dev to access this
262 // the nodes can not be created from within the driver 261 // the nodes can not be created from within the driver
263 if (hba_count && register_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER, &adpt_fops)) { 262 if (hba_count && register_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER, &adpt_fops)) {
264 adpt_exit(); 263 adpt_i2o_sys_shutdown();
265 return 0; 264 return 0;
266 } 265 }
267 return hba_count; 266 return hba_count;
268} 267}
269 268
270 269
271static int adpt_release(adpt_hba *pHba) 270/*
271 * scsi_unregister will be called AFTER we return.
272 */
273static int adpt_release(struct Scsi_Host *host)
272{ 274{
273 struct Scsi_Host *shost = pHba->host; 275 adpt_hba* pHba = (adpt_hba*) host->hostdata[0];
274 scsi_remove_host(shost);
275// adpt_i2o_quiesce_hba(pHba); 276// adpt_i2o_quiesce_hba(pHba);
276 adpt_i2o_delete_hba(pHba); 277 adpt_i2o_delete_hba(pHba);
277 scsi_host_put(shost); 278 scsi_unregister(host);
278 return 0; 279 return 0;
279} 280}
280 281
@@ -881,7 +882,7 @@ static int adpt_reboot_event(struct notifier_block *n, ulong code, void *p)
881#endif 882#endif
882 883
883 884
884static int adpt_install_hba(struct pci_dev* pDev) 885static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev)
885{ 886{
886 887
887 adpt_hba* pHba = NULL; 888 adpt_hba* pHba = NULL;
@@ -1028,6 +1029,8 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1028 1029
1029 1030
1030 mutex_lock(&adpt_configuration_lock); 1031 mutex_lock(&adpt_configuration_lock);
1032 // scsi_unregister calls our adpt_release which
1033 // does a quiese
1031 if(pHba->host){ 1034 if(pHba->host){
1032 free_irq(pHba->host->irq, pHba); 1035 free_irq(pHba->host->irq, pHba);
1033 } 1036 }
@@ -1079,6 +1082,17 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1079} 1082}
1080 1083
1081 1084
1085static int adpt_init(void)
1086{
1087 printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n");
1088#ifdef REBOOT_NOTIFIER
1089 register_reboot_notifier(&adpt_reboot_notifier);
1090#endif
1091
1092 return 0;
1093}
1094
1095
1082static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun) 1096static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun)
1083{ 1097{
1084 struct adpt_device* d; 1098 struct adpt_device* d;
@@ -2164,6 +2178,37 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d
2164} 2178}
2165 2179
2166 2180
2181static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht)
2182{
2183 struct Scsi_Host *host = NULL;
2184
2185 host = scsi_register(sht, sizeof(adpt_hba*));
2186 if (host == NULL) {
2187 printk ("%s: scsi_register returned NULL\n",pHba->name);
2188 return -1;
2189 }
2190 host->hostdata[0] = (unsigned long)pHba;
2191 pHba->host = host;
2192
2193 host->irq = pHba->pDev->irq;
2194 /* no IO ports, so don't have to set host->io_port and
2195 * host->n_io_port
2196 */
2197 host->io_port = 0;
2198 host->n_io_port = 0;
2199 /* see comments in scsi_host.h */
2200 host->max_id = 16;
2201 host->max_lun = 256;
2202 host->max_channel = pHba->top_scsi_channel + 1;
2203 host->cmd_per_lun = 1;
2204 host->unique_id = (uint) pHba;
2205 host->sg_tablesize = pHba->sg_tablesize;
2206 host->can_queue = pHba->post_fifo_size;
2207
2208 return 0;
2209}
2210
2211
2167static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) 2212static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd)
2168{ 2213{
2169 adpt_hba* pHba; 2214 adpt_hba* pHba;
@@ -3279,10 +3324,12 @@ static static void adpt_delay(int millisec)
3279 3324
3280#endif 3325#endif
3281 3326
3282static struct scsi_host_template adpt_template = { 3327static struct scsi_host_template driver_template = {
3283 .name = "dpt_i2o", 3328 .name = "dpt_i2o",
3284 .proc_name = "dpt_i2o", 3329 .proc_name = "dpt_i2o",
3285 .proc_info = adpt_proc_info, 3330 .proc_info = adpt_proc_info,
3331 .detect = adpt_detect,
3332 .release = adpt_release,
3286 .info = adpt_info, 3333 .info = adpt_info,
3287 .queuecommand = adpt_queue, 3334 .queuecommand = adpt_queue,
3288 .eh_abort_handler = adpt_abort, 3335 .eh_abort_handler = adpt_abort,
@@ -3297,62 +3344,5 @@ static struct scsi_host_template adpt_template = {
3297 .use_clustering = ENABLE_CLUSTERING, 3344 .use_clustering = ENABLE_CLUSTERING,
3298 .use_sg_chaining = ENABLE_SG_CHAINING, 3345 .use_sg_chaining = ENABLE_SG_CHAINING,
3299}; 3346};
3300 3347#include "scsi_module.c"
3301static s32 adpt_scsi_register(adpt_hba* pHba)
3302{
3303 struct Scsi_Host *host;
3304
3305 host = scsi_host_alloc(&adpt_template, sizeof(adpt_hba*));
3306 if (host == NULL) {
3307 printk ("%s: scsi_host_alloc returned NULL\n",pHba->name);
3308 return -1;
3309 }
3310 host->hostdata[0] = (unsigned long)pHba;
3311 pHba->host = host;
3312
3313 host->irq = pHba->pDev->irq;
3314 /* no IO ports, so don't have to set host->io_port and
3315 * host->n_io_port
3316 */
3317 host->io_port = 0;
3318 host->n_io_port = 0;
3319 /* see comments in scsi_host.h */
3320 host->max_id = 16;
3321 host->max_lun = 256;
3322 host->max_channel = pHba->top_scsi_channel + 1;
3323 host->cmd_per_lun = 1;
3324 host->unique_id = (uint) pHba;
3325 host->sg_tablesize = pHba->sg_tablesize;
3326 host->can_queue = pHba->post_fifo_size;
3327
3328 if (scsi_add_host(host, &pHba->pDev->dev)) {
3329 scsi_host_put(host);
3330 return -1;
3331 }
3332
3333 return 0;
3334}
3335
3336static int __init adpt_init(void)
3337{
3338 int count;
3339
3340 printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n");
3341#ifdef REBOOT_NOTIFIER
3342 register_reboot_notifier(&adpt_reboot_notifier);
3343#endif
3344
3345 count = adpt_detect();
3346
3347 return count > 0 ? 0 : -ENODEV;
3348}
3349
3350static void adpt_exit(void)
3351{
3352 while (hba_chain)
3353 adpt_release(hba_chain);
3354}
3355
3356module_init(adpt_init);
3357module_exit(adpt_exit);
3358MODULE_LICENSE("GPL"); 3348MODULE_LICENSE("GPL");