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>

authored by Andrew Morton and committed by Linus Torvalds 24601bbc 43cbe2cb

+68 -73
+61 -71
drivers/scsi/dpt_i2o.c
··· 173 }; 174 MODULE_DEVICE_TABLE(pci,dptids); 175 176 - static void adpt_exit(void); 177 - 178 - static int adpt_detect(void) 179 { 180 struct pci_dev *pDev = NULL; 181 adpt_hba* pHba; 182 183 PINFO("Detecting Adaptec I2O RAID controllers...\n"); 184 ··· 186 while ((pDev = pci_get_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) { 187 if(pDev->device == PCI_DPT_DEVICE_ID || 188 pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){ 189 - if(adpt_install_hba(pDev) ){ 190 PERROR("Could not Init an I2O RAID device\n"); 191 PERROR("Will not try to detect others.\n"); 192 return hba_count-1; ··· 248 } 249 250 for (pHba = hba_chain; pHba; pHba = pHba->next) { 251 - if (adpt_scsi_register(pHba) < 0) { 252 adpt_i2o_delete_hba(pHba); 253 continue; 254 } 255 pHba->initialized = TRUE; 256 pHba->state &= ~DPTI_STATE_RESET; 257 - scsi_scan_host(pHba->host); 258 } 259 260 // Register our control device node 261 // nodes will need to be created in /dev to access this 262 // the nodes can not be created from within the driver 263 if (hba_count && register_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER, &adpt_fops)) { 264 - adpt_exit(); 265 return 0; 266 } 267 return hba_count; 268 } 269 270 271 - static int adpt_release(adpt_hba *pHba) 272 { 273 - struct Scsi_Host *shost = pHba->host; 274 - scsi_remove_host(shost); 275 // adpt_i2o_quiesce_hba(pHba); 276 adpt_i2o_delete_hba(pHba); 277 - scsi_host_put(shost); 278 return 0; 279 } 280 ··· 882 #endif 883 884 885 - static int adpt_install_hba(struct pci_dev* pDev) 886 { 887 888 adpt_hba* pHba = NULL; ··· 1029 1030 1031 mutex_lock(&adpt_configuration_lock); 1032 if(pHba->host){ 1033 free_irq(pHba->host->irq, pHba); 1034 } ··· 1079 if(hba_count <= 0){ 1080 unregister_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER); 1081 } 1082 } 1083 1084 ··· 2175 return 0; 2176 } 2177 return rcode; 2178 } 2179 2180 ··· 3324 3325 #endif 3326 3327 - static struct scsi_host_template adpt_template = { 3328 .name = "dpt_i2o", 3329 .proc_name = "dpt_i2o", 3330 .proc_info = adpt_proc_info, 3331 .info = adpt_info, 3332 .queuecommand = adpt_queue, 3333 .eh_abort_handler = adpt_abort, ··· 3344 .use_clustering = ENABLE_CLUSTERING, 3345 .use_sg_chaining = ENABLE_SG_CHAINING, 3346 }; 3347 - 3348 - static s32 adpt_scsi_register(adpt_hba* pHba) 3349 - { 3350 - struct Scsi_Host *host; 3351 - 3352 - host = scsi_host_alloc(&adpt_template, sizeof(adpt_hba*)); 3353 - if (host == NULL) { 3354 - printk ("%s: scsi_host_alloc returned NULL\n",pHba->name); 3355 - return -1; 3356 - } 3357 - host->hostdata[0] = (unsigned long)pHba; 3358 - pHba->host = host; 3359 - 3360 - host->irq = pHba->pDev->irq; 3361 - /* no IO ports, so don't have to set host->io_port and 3362 - * host->n_io_port 3363 - */ 3364 - host->io_port = 0; 3365 - host->n_io_port = 0; 3366 - /* see comments in scsi_host.h */ 3367 - host->max_id = 16; 3368 - host->max_lun = 256; 3369 - host->max_channel = pHba->top_scsi_channel + 1; 3370 - host->cmd_per_lun = 1; 3371 - host->unique_id = (uint) pHba; 3372 - host->sg_tablesize = pHba->sg_tablesize; 3373 - host->can_queue = pHba->post_fifo_size; 3374 - 3375 - if (scsi_add_host(host, &pHba->pDev->dev)) { 3376 - scsi_host_put(host); 3377 - return -1; 3378 - } 3379 - 3380 - return 0; 3381 - } 3382 - 3383 - static int __init adpt_init(void) 3384 - { 3385 - int count; 3386 - 3387 - printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n"); 3388 - #ifdef REBOOT_NOTIFIER 3389 - register_reboot_notifier(&adpt_reboot_notifier); 3390 - #endif 3391 - 3392 - count = adpt_detect(); 3393 - 3394 - return count > 0 ? 0 : -ENODEV; 3395 - } 3396 - 3397 - static void adpt_exit(void) 3398 - { 3399 - while (hba_chain) 3400 - adpt_release(hba_chain); 3401 - } 3402 - 3403 - module_init(adpt_init); 3404 - module_exit(adpt_exit); 3405 MODULE_LICENSE("GPL");
··· 173 }; 174 MODULE_DEVICE_TABLE(pci,dptids); 175 176 + static int adpt_detect(struct scsi_host_template* sht) 177 { 178 struct pci_dev *pDev = NULL; 179 adpt_hba* pHba; 180 + 181 + adpt_init(); 182 183 PINFO("Detecting Adaptec I2O RAID controllers...\n"); 184 ··· 186 while ((pDev = pci_get_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) { 187 if(pDev->device == PCI_DPT_DEVICE_ID || 188 pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){ 189 + if(adpt_install_hba(sht, pDev) ){ 190 PERROR("Could not Init an I2O RAID device\n"); 191 PERROR("Will not try to detect others.\n"); 192 return hba_count-1; ··· 248 } 249 250 for (pHba = hba_chain; pHba; pHba = pHba->next) { 251 + if( adpt_scsi_register(pHba,sht) < 0){ 252 adpt_i2o_delete_hba(pHba); 253 continue; 254 } 255 pHba->initialized = TRUE; 256 pHba->state &= ~DPTI_STATE_RESET; 257 } 258 259 // Register our control device node 260 // nodes will need to be created in /dev to access this 261 // the nodes can not be created from within the driver 262 if (hba_count && register_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER, &adpt_fops)) { 263 + adpt_i2o_sys_shutdown(); 264 return 0; 265 } 266 return hba_count; 267 } 268 269 270 + /* 271 + * scsi_unregister will be called AFTER we return. 272 + */ 273 + static int adpt_release(struct Scsi_Host *host) 274 { 275 + adpt_hba* pHba = (adpt_hba*) host->hostdata[0]; 276 // adpt_i2o_quiesce_hba(pHba); 277 adpt_i2o_delete_hba(pHba); 278 + scsi_unregister(host); 279 return 0; 280 } 281 ··· 881 #endif 882 883 884 + static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) 885 { 886 887 adpt_hba* pHba = NULL; ··· 1028 1029 1030 mutex_lock(&adpt_configuration_lock); 1031 + // scsi_unregister calls our adpt_release which 1032 + // does a quiese 1033 if(pHba->host){ 1034 free_irq(pHba->host->irq, pHba); 1035 } ··· 1076 if(hba_count <= 0){ 1077 unregister_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER); 1078 } 1079 + } 1080 + 1081 + 1082 + static int adpt_init(void) 1083 + { 1084 + printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n"); 1085 + #ifdef REBOOT_NOTIFIER 1086 + register_reboot_notifier(&adpt_reboot_notifier); 1087 + #endif 1088 + 1089 + return 0; 1090 } 1091 1092 ··· 2161 return 0; 2162 } 2163 return rcode; 2164 + } 2165 + 2166 + 2167 + static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht) 2168 + { 2169 + struct Scsi_Host *host = NULL; 2170 + 2171 + host = scsi_register(sht, sizeof(adpt_hba*)); 2172 + if (host == NULL) { 2173 + printk ("%s: scsi_register returned NULL\n",pHba->name); 2174 + return -1; 2175 + } 2176 + host->hostdata[0] = (unsigned long)pHba; 2177 + pHba->host = host; 2178 + 2179 + host->irq = pHba->pDev->irq; 2180 + /* no IO ports, so don't have to set host->io_port and 2181 + * host->n_io_port 2182 + */ 2183 + host->io_port = 0; 2184 + host->n_io_port = 0; 2185 + /* see comments in scsi_host.h */ 2186 + host->max_id = 16; 2187 + host->max_lun = 256; 2188 + host->max_channel = pHba->top_scsi_channel + 1; 2189 + host->cmd_per_lun = 1; 2190 + host->unique_id = (uint) pHba; 2191 + host->sg_tablesize = pHba->sg_tablesize; 2192 + host->can_queue = pHba->post_fifo_size; 2193 + 2194 + return 0; 2195 } 2196 2197 ··· 3279 3280 #endif 3281 3282 + static struct scsi_host_template driver_template = { 3283 .name = "dpt_i2o", 3284 .proc_name = "dpt_i2o", 3285 .proc_info = adpt_proc_info, 3286 + .detect = adpt_detect, 3287 + .release = adpt_release, 3288 .info = adpt_info, 3289 .queuecommand = adpt_queue, 3290 .eh_abort_handler = adpt_abort, ··· 3297 .use_clustering = ENABLE_CLUSTERING, 3298 .use_sg_chaining = ENABLE_SG_CHAINING, 3299 }; 3300 + #include "scsi_module.c" 3301 MODULE_LICENSE("GPL");
+7 -2
drivers/scsi/dpti.h
··· 28 * SCSI interface function Prototypes 29 */ 30 31 static int adpt_queue(struct scsi_cmnd * cmd, void (*cmdcomplete) (struct scsi_cmnd *)); 32 static int adpt_abort(struct scsi_cmnd * cmd); 33 static int adpt_reset(struct scsi_cmnd* cmd); 34 static int adpt_slave_configure(struct scsi_device *); 35 36 static const char *adpt_info(struct Scsi_Host *pSHost); ··· 48 */ 49 50 #define DPT_DRIVER_NAME "Adaptec I2O RAID" 51 52 #include "dpt/sys_info.h" 53 #include <linux/wait.h> ··· 289 static s32 adpt_i2o_hrt_get(adpt_hba* pHba); 290 static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice); 291 static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd); 292 - static s32 adpt_scsi_register(adpt_hba* pHba); 293 static s32 adpt_hba_reset(adpt_hba* pHba); 294 static s32 adpt_i2o_reset_hba(adpt_hba* pHba); 295 static s32 adpt_rescan(adpt_hba* pHba); ··· 299 static void adpt_inquiry(adpt_hba* pHba); 300 static void adpt_fail_posted_scbs(adpt_hba* pHba); 301 static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun); 302 - static int adpt_install_hba(struct pci_dev* pDev) ; 303 static int adpt_i2o_online_hba(adpt_hba* pHba); 304 static void adpt_i2o_post_wait_complete(u32, int); 305 static int adpt_i2o_systab_send(adpt_hba* pHba); ··· 343 #define FW_DEBUG_BLED_OFFSET 8 344 345 #define FW_DEBUG_FLAGS_NO_HEADERS_B 0x01 346 #endif /* _DPT_H */
··· 28 * SCSI interface function Prototypes 29 */ 30 31 + static int adpt_detect(struct scsi_host_template * sht); 32 static int adpt_queue(struct scsi_cmnd * cmd, void (*cmdcomplete) (struct scsi_cmnd *)); 33 static int adpt_abort(struct scsi_cmnd * cmd); 34 static int adpt_reset(struct scsi_cmnd* cmd); 35 + static int adpt_release(struct Scsi_Host *host); 36 static int adpt_slave_configure(struct scsi_device *); 37 38 static const char *adpt_info(struct Scsi_Host *pSHost); ··· 46 */ 47 48 #define DPT_DRIVER_NAME "Adaptec I2O RAID" 49 + 50 + #ifndef HOSTS_C 51 52 #include "dpt/sys_info.h" 53 #include <linux/wait.h> ··· 285 static s32 adpt_i2o_hrt_get(adpt_hba* pHba); 286 static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice); 287 static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd); 288 + static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht); 289 static s32 adpt_hba_reset(adpt_hba* pHba); 290 static s32 adpt_i2o_reset_hba(adpt_hba* pHba); 291 static s32 adpt_rescan(adpt_hba* pHba); ··· 295 static void adpt_inquiry(adpt_hba* pHba); 296 static void adpt_fail_posted_scbs(adpt_hba* pHba); 297 static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun); 298 + static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) ; 299 static int adpt_i2o_online_hba(adpt_hba* pHba); 300 static void adpt_i2o_post_wait_complete(u32, int); 301 static int adpt_i2o_systab_send(adpt_hba* pHba); ··· 339 #define FW_DEBUG_BLED_OFFSET 8 340 341 #define FW_DEBUG_FLAGS_NO_HEADERS_B 0x01 342 + #endif /* !HOSTS_C */ 343 #endif /* _DPT_H */