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 173 }; 174 174 MODULE_DEVICE_TABLE(pci,dptids); 175 175 176 - static void adpt_exit(void); 177 - 178 - static int adpt_detect(void) 176 + static int adpt_detect(struct scsi_host_template* sht) 179 177 { 180 178 struct pci_dev *pDev = NULL; 181 179 adpt_hba* pHba; 180 + 181 + adpt_init(); 182 182 183 183 PINFO("Detecting Adaptec I2O RAID controllers...\n"); 184 184 ··· 186 186 while ((pDev = pci_get_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) { 187 187 if(pDev->device == PCI_DPT_DEVICE_ID || 188 188 pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){ 189 - if(adpt_install_hba(pDev) ){ 189 + if(adpt_install_hba(sht, pDev) ){ 190 190 PERROR("Could not Init an I2O RAID device\n"); 191 191 PERROR("Will not try to detect others.\n"); 192 192 return hba_count-1; ··· 248 248 } 249 249 250 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 252 adpt_i2o_delete_hba(pHba); 253 253 continue; 254 254 } 255 255 pHba->initialized = TRUE; 256 256 pHba->state &= ~DPTI_STATE_RESET; 257 - scsi_scan_host(pHba->host); 258 257 } 259 258 260 259 // Register our control device node 261 260 // nodes will need to be created in /dev to access this 262 261 // the nodes can not be created from within the driver 263 262 if (hba_count && register_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER, &adpt_fops)) { 264 - adpt_exit(); 263 + adpt_i2o_sys_shutdown(); 265 264 return 0; 266 265 } 267 266 return hba_count; 268 267 } 269 268 270 269 271 - static int adpt_release(adpt_hba *pHba) 270 + /* 271 + * scsi_unregister will be called AFTER we return. 272 + */ 273 + static int adpt_release(struct Scsi_Host *host) 272 274 { 273 - struct Scsi_Host *shost = pHba->host; 274 - scsi_remove_host(shost); 275 + adpt_hba* pHba = (adpt_hba*) host->hostdata[0]; 275 276 // adpt_i2o_quiesce_hba(pHba); 276 277 adpt_i2o_delete_hba(pHba); 277 - scsi_host_put(shost); 278 + scsi_unregister(host); 278 279 return 0; 279 280 } 280 281 ··· 882 881 #endif 883 882 884 883 885 - static int adpt_install_hba(struct pci_dev* pDev) 884 + static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) 886 885 { 887 886 888 887 adpt_hba* pHba = NULL; ··· 1029 1028 1030 1029 1031 1030 mutex_lock(&adpt_configuration_lock); 1031 + // scsi_unregister calls our adpt_release which 1032 + // does a quiese 1032 1033 if(pHba->host){ 1033 1034 free_irq(pHba->host->irq, pHba); 1034 1035 } ··· 1079 1076 if(hba_count <= 0){ 1080 1077 unregister_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER); 1081 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; 1082 1090 } 1083 1091 1084 1092 ··· 2175 2161 return 0; 2176 2162 } 2177 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; 2178 2195 } 2179 2196 2180 2197 ··· 3324 3279 3325 3280 #endif 3326 3281 3327 - static struct scsi_host_template adpt_template = { 3282 + static struct scsi_host_template driver_template = { 3328 3283 .name = "dpt_i2o", 3329 3284 .proc_name = "dpt_i2o", 3330 3285 .proc_info = adpt_proc_info, 3286 + .detect = adpt_detect, 3287 + .release = adpt_release, 3331 3288 .info = adpt_info, 3332 3289 .queuecommand = adpt_queue, 3333 3290 .eh_abort_handler = adpt_abort, ··· 3344 3297 .use_clustering = ENABLE_CLUSTERING, 3345 3298 .use_sg_chaining = ENABLE_SG_CHAINING, 3346 3299 }; 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); 3300 + #include "scsi_module.c" 3405 3301 MODULE_LICENSE("GPL");
+7 -2
drivers/scsi/dpti.h
··· 28 28 * SCSI interface function Prototypes 29 29 */ 30 30 31 + static int adpt_detect(struct scsi_host_template * sht); 31 32 static int adpt_queue(struct scsi_cmnd * cmd, void (*cmdcomplete) (struct scsi_cmnd *)); 32 33 static int adpt_abort(struct scsi_cmnd * cmd); 33 34 static int adpt_reset(struct scsi_cmnd* cmd); 35 + static int adpt_release(struct Scsi_Host *host); 34 36 static int adpt_slave_configure(struct scsi_device *); 35 37 36 38 static const char *adpt_info(struct Scsi_Host *pSHost); ··· 48 46 */ 49 47 50 48 #define DPT_DRIVER_NAME "Adaptec I2O RAID" 49 + 50 + #ifndef HOSTS_C 51 51 52 52 #include "dpt/sys_info.h" 53 53 #include <linux/wait.h> ··· 289 285 static s32 adpt_i2o_hrt_get(adpt_hba* pHba); 290 286 static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice); 291 287 static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd); 292 - static s32 adpt_scsi_register(adpt_hba* pHba); 288 + static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht); 293 289 static s32 adpt_hba_reset(adpt_hba* pHba); 294 290 static s32 adpt_i2o_reset_hba(adpt_hba* pHba); 295 291 static s32 adpt_rescan(adpt_hba* pHba); ··· 299 295 static void adpt_inquiry(adpt_hba* pHba); 300 296 static void adpt_fail_posted_scbs(adpt_hba* pHba); 301 297 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) ; 298 + static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) ; 303 299 static int adpt_i2o_online_hba(adpt_hba* pHba); 304 300 static void adpt_i2o_post_wait_complete(u32, int); 305 301 static int adpt_i2o_systab_send(adpt_hba* pHba); ··· 343 339 #define FW_DEBUG_BLED_OFFSET 8 344 340 345 341 #define FW_DEBUG_FLAGS_NO_HEADERS_B 0x01 342 + #endif /* !HOSTS_C */ 346 343 #endif /* _DPT_H */