Import 2.3.18pre1
[davej-history.git] / drivers / scsi / hosts.c
blob531c33b9f3002d095b69dfe622577872a6c6f34c
1 /*
2 * hosts.c Copyright (C) 1992 Drew Eckhardt
3 * Copyright (C) 1993, 1994, 1995 Eric Youngdale
5 * mid to lowlevel SCSI driver interface
6 * Initial versions: Drew Eckhardt
7 * Subsequent revisions: Eric Youngdale
9 * <drew@colorado.edu>
11 * Jiffies wrap fixes (host->resetting), 3 Dec 1998 Andrea Arcangeli
16 * This file contains the medium level SCSI
17 * host interface initialization, as well as the scsi_hosts array of SCSI
18 * hosts currently present in the system.
21 #define __NO_VERSION__
22 #include <linux/module.h>
24 #include <linux/config.h>
25 #include <linux/blk.h>
26 #include <linux/kernel.h>
27 #include <linux/string.h>
28 #include <linux/mm.h>
29 #include <linux/proc_fs.h>
30 #include <linux/init.h>
32 #define __KERNEL_SYSCALLS__
34 #include <linux/unistd.h>
36 #include "scsi.h"
38 #ifndef NULL
39 #define NULL 0L
40 #endif
42 #define HOSTS_C
44 #include "hosts.h"
46 #if defined(CONFIG_A4000T_SCSI) || \
47 defined(CONFIG_WARPENGINE_SCSI) || \
48 defined(CONFIG_A4091_SCSI) || \
49 defined (CONFIG_GVP_TURBO_SCSI) || \
50 defined (CONFIG_BLZ603EPLUS_SCSI)
51 #define AMIGA7XXCONFIG
52 #endif
54 #ifdef AMIGA7XXCONFIG
55 #include "amiga7xx.h"
56 #endif
58 #ifdef CONFIG_MVME16x_SCSI
59 #include "mvme16x.h"
60 #endif
62 #ifdef CONFIG_BVME6000_SCSI
63 #include "bvme6000.h"
64 #endif
66 #ifdef CONFIG_A3000_SCSI
67 #include "a3000.h"
68 #endif
70 #ifdef CONFIG_A2091_SCSI
71 #include "a2091.h"
72 #endif
74 #ifdef CONFIG_GVP11_SCSI
75 #include "gvp11.h"
76 #endif
78 #ifdef CONFIG_CYBERSTORM_SCSI
79 #include "cyberstorm.h"
80 #endif
82 #ifdef CONFIG_CYBERSTORMII_SCSI
83 #include "cyberstormII.h"
84 #endif
86 #ifdef CONFIG_BLZ2060_SCSI
87 #include "blz2060.h"
88 #endif
90 #ifdef CONFIG_BLZ1230_SCSI
91 #include "blz1230.h"
92 #endif
94 #ifdef CONFIG_FASTLANE_SCSI
95 #include "fastlane.h"
96 #endif
98 #ifdef CONFIG_OKTAGON_SCSI
99 #include "oktagon_esp.h"
100 #endif
102 #ifdef CONFIG_ATARI_SCSI
103 #include "atari_scsi.h"
104 #endif
106 #ifdef CONFIG_MAC_SCSI_OLD
107 #include "mac_scsi.h"
108 #endif
110 #ifdef CONFIG_MAC_SCSI
111 #include "mac_scsinew.h"
112 #endif
114 #ifdef CONFIG_SCSI_MAC_ESP
115 #include "mac_esp.h"
116 #endif
118 #ifdef CONFIG_SCSI_ADVANSYS
119 #include "advansys.h"
120 #endif
122 #ifdef CONFIG_SCSI_AHA152X
123 #include "aha152x.h"
124 #endif
126 #ifdef CONFIG_SCSI_AHA1542
127 #include "aha1542.h"
128 #endif
130 #ifdef CONFIG_SCSI_AHA1740
131 #include "aha1740.h"
132 #endif
134 #ifdef CONFIG_SCSI_AIC7XXX
135 #include "aic7xxx.h"
136 #endif
138 #ifdef CONFIG_SCSI_IPS
139 #include "ips.h"
140 #endif
142 #ifdef CONFIG_SCSI_BUSLOGIC
143 #include "BusLogic.h"
144 #endif
146 #ifdef CONFIG_SCSI_EATA_DMA
147 #include "eata_dma.h"
148 #endif
150 #ifdef CONFIG_SCSI_EATA_PIO
151 #include "eata_pio.h"
152 #endif
154 #ifdef CONFIG_SCSI_U14_34F
155 #include "u14-34f.h"
156 #endif
158 #ifdef CONFIG_SCSI_FD_MCS
159 #include "fd_mcs.h"
160 #endif
162 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
163 #include "fdomain.h"
164 #endif
166 #ifdef CONFIG_SCSI_GENERIC_NCR5380
167 #include "g_NCR5380.h"
168 #endif
170 #ifdef CONFIG_SCSI_IN2000
171 #include "in2000.h"
172 #endif
174 #ifdef CONFIG_SCSI_PAS16
175 #include "pas16.h"
176 #endif
178 #ifdef CONFIG_SCSI_QLOGIC_FAS
179 #include "qlogicfas.h"
180 #endif
182 #ifdef CONFIG_SCSI_QLOGIC_ISP
183 #include "qlogicisp.h"
184 #endif
186 #ifdef CONFIG_SCSI_QLOGIC_FC
187 #include "qlogicfc.h"
188 #endif
190 #ifdef CONFIG_SCSI_SEAGATE
191 #include "seagate.h"
192 #endif
194 #ifdef CONFIG_SCSI_T128
195 #include "t128.h"
196 #endif
198 #ifdef CONFIG_SCSI_DTC3280
199 #include "dtc.h"
200 #endif
202 #ifdef CONFIG_SCSI_NCR53C7xx
203 #include "53c7,8xx.h"
204 #endif
206 #ifdef CONFIG_SCSI_SYM53C8XX
207 #include "sym53c8xx.h"
208 #endif
210 #ifdef CONFIG_SCSI_NCR53C8XX
211 #include "ncr53c8xx.h"
212 #endif
214 #ifdef CONFIG_SCSI_ULTRASTOR
215 #include "ultrastor.h"
216 #endif
218 #ifdef CONFIG_SCSI_7000FASST
219 #include "wd7000.h"
220 #endif
222 #ifdef CONFIG_SCSI_MCA_53C9X
223 #include "mca_53c9x.h"
224 #endif
226 #ifdef CONFIG_SCSI_IBMMCA
227 #include "ibmmca.h"
228 #endif
230 #ifdef CONFIG_SCSI_EATA
231 #include "eata.h"
232 #endif
234 #ifdef CONFIG_SCSI_NCR53C406A
235 #include "NCR53c406a.h"
236 #endif
238 #ifdef CONFIG_SCSI_SYM53C416
239 #include "sym53c416.h"
240 #endif
242 #ifdef CONFIG_SCSI_DC390T
243 #include "dc390.h"
244 #endif
246 #ifdef CONFIG_SCSI_AM53C974
247 #include "AM53C974.h"
248 #endif
250 #ifdef CONFIG_SCSI_MEGARAID
251 #include "megaraid.h"
252 #endif
254 #ifdef CONFIG_SCSI_ACARD
255 #include "atp870u.h"
256 #endif
258 #ifdef CONFIG_SCSI_SUNESP
259 #include "esp.h"
260 #endif
262 #ifdef CONFIG_SCSI_QLOGICPTI
263 #include "qlogicpti.h"
264 #endif
266 #ifdef CONFIG_BLK_DEV_IDESCSI
267 #include "ide-scsi.h"
268 #endif
270 #ifdef CONFIG_SCSI_MESH
271 #include "mesh.h"
272 #endif
274 #ifdef CONFIG_SCSI_MAC53C94
275 #include "mac53c94.h"
276 #endif
278 #ifdef CONFIG_SCSI_GDTH
279 #include "gdth.h"
280 #endif
282 #ifdef CONFIG_SCSI_PCI2000
283 #include "pci2000.h"
284 #endif
286 #ifdef CONFIG_SCSI_PCI2220I
287 #include "pci2220i.h"
288 #endif
290 #ifdef CONFIG_SCSI_PSI240I
291 #include "psi240i.h"
292 #endif
294 #ifdef CONFIG_SCSI_PLUTO
295 #include "pluto.h"
296 #endif
298 #ifdef CONFIG_SCSI_INITIO
299 #include "ini9100u.h"
300 #endif
302 #ifdef CONFIG_SCSI_INIA100
303 #include "inia100.h"
304 #endif
306 #ifdef CONFIG_SCSI_DEBUG
307 #include "scsi_debug.h"
308 #endif
310 #ifdef CONFIG_SCSI_ACORNSCSI_3
311 #include "../acorn/scsi/acornscsi.h"
312 #endif
314 #ifdef CONFIG_SCSI_CUMANA_1
315 #include "../acorn/scsi/cumana_1.h"
316 #endif
318 #ifdef CONFIG_SCSI_CUMANA_2
319 #include "../acorn/scsi/cumana_2.h"
320 #endif
322 #ifdef CONFIG_SCSI_ECOSCSI
323 #include "../acorn/scsi/ecoscsi.h"
324 #endif
326 #ifdef CONFIG_SCSI_OAK1
327 #include "../acorn/scsi/oak.h"
328 #endif
330 #ifdef CONFIG_SCSI_POWERTECSCSI
331 #include "../acorn/scsi/powertec.h"
332 #endif
334 #ifdef CONFIG_JAZZ_ESP
335 #include "jazz_esp.h"
336 #endif
338 #ifdef CONFIG_SUN3X_ESP
339 #include "sun3x_esp.h"
340 #endif
342 #ifdef CONFIG_IPHASE5526
343 #include "../net/fc/iph5526_scsi.h"
344 #endif
347 * Moved ppa driver to the end of the probe list
348 * since it is a removable host adapter.
349 * This means the parallel ZIP drive will not bump
350 * the order of the /dev/sd devices - campbell@torque.net
352 #ifdef CONFIG_SCSI_PPA
353 #include "ppa.h"
354 #endif
356 #ifdef CONFIG_SCSI_IMM
357 #include "imm.h"
358 #endif
361 static const char RCSid[] = "$Header: /vger/u4/cvs/linux/drivers/scsi/hosts.c,v 1.20 1996/12/12 19:18:32 davem Exp $";
365 * The scsi host entries should be in the order you wish the
366 * cards to be detected. A driver may appear more than once IFF
367 * it can deal with being detected (and therefore initialized)
368 * with more than one simultaneous host number, can handle being
369 * reentrant, etc.
371 * They may appear in any order, as each SCSI host is told which host
372 * number it is during detection.
375 /* This is a placeholder for controllers that are not configured into
376 * the system - we do this to ensure that the controller numbering is
377 * always consistent, no matter how the kernel is configured. */
379 #define NO_CONTROLLER {NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
380 NULL, NULL, 0, 0, 0, 0, 0, 0}
383 * When figure is run, we don't want to link to any object code. Since
384 * the macro for each host will contain function pointers, we cannot
385 * use it and instead must use a "blank" that does no such
386 * idiocy.
389 Scsi_Host_Template * scsi_hosts = NULL;
391 static Scsi_Host_Template builtin_scsi_hosts[] =
393 #ifdef CONFIG_AMIGA
394 #ifdef AMIGA7XXCONFIG
395 AMIGA7XX_SCSI,
396 #endif
397 #ifdef CONFIG_A3000_SCSI
398 A3000_SCSI,
399 #endif
400 #ifdef CONFIG_A2091_SCSI
401 A2091_SCSI,
402 #endif
403 #ifdef CONFIG_GVP11_SCSI
404 GVP11_SCSI,
405 #endif
406 #ifdef CONFIG_CYBERSTORM_SCSI
407 SCSI_CYBERSTORM,
408 #endif
409 #ifdef CONFIG_CYBERSTORMII_SCSI
410 SCSI_CYBERSTORMII,
411 #endif
412 #ifdef CONFIG_BLZ2060_SCSI
413 SCSI_BLZ2060,
414 #endif
415 #ifdef CONFIG_BLZ1230_SCSI
416 SCSI_BLZ1230,
417 #endif
418 #ifdef CONFIG_FASTLANE_SCSI
419 SCSI_FASTLANE,
420 #endif
421 #ifdef CONFIG_OKTAGON_SCSI
422 SCSI_OKTAGON_ESP,
423 #endif
424 #endif
426 #ifdef CONFIG_ATARI
427 #ifdef CONFIG_ATARI_SCSI
428 ATARI_SCSI,
429 #endif
430 #endif
432 #ifdef CONFIG_MAC
433 #ifdef CONFIG_MAC_SCSI_OLD
434 MAC_SCSI,
435 #endif
436 #ifdef CONFIG_SCSI_MAC_ESP
437 SCSI_MAC_ESP,
438 #endif
439 #ifdef CONFIG_MAC_SCSI
440 MAC_NCR5380,
441 #endif
442 #endif
444 #ifdef CONFIG_MVME16x_SCSI
445 MVME16x_SCSI,
446 #endif
447 #ifdef CONFIG_BVME6000_SCSI
448 BVME6000_SCSI,
449 #endif
450 #ifdef CONFIG_SCSI_ADVANSYS
451 ADVANSYS,
452 #endif
454 #ifdef CONFIG_SCSI_PCI2000
455 PCI2000,
456 #endif
457 #ifdef CONFIG_SCSI_PCI2220I
458 PCI2220I,
459 #endif
460 #ifdef CONFIG_SCSI_PSI240I
461 PSI240I,
462 #endif
464 /* BusLogic must come before aha1542.c */
465 #ifdef CONFIG_SCSI_BUSLOGIC
466 BUSLOGIC,
467 #endif
468 #ifdef CONFIG_SCSI_U14_34F
469 ULTRASTOR_14_34F,
470 #endif
471 #ifdef CONFIG_SCSI_ULTRASTOR
472 ULTRASTOR_14F,
473 #endif
474 #ifdef CONFIG_SCSI_AHA152X
475 AHA152X,
476 #endif
477 #ifdef CONFIG_SCSI_AHA1542
478 AHA1542,
479 #endif
480 #ifdef CONFIG_SCSI_AHA1740
481 AHA1740,
482 #endif
483 #ifdef CONFIG_SCSI_AIC7XXX
484 AIC7XXX,
485 #endif
486 #ifdef CONFIG_SCSI_IPS
487 IPS,
488 #endif
489 #ifdef CONFIG_SCSI_FD_MCS
490 FD_MCS,
491 #endif
492 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
493 FDOMAIN_16X0,
494 #endif
495 #ifdef CONFIG_SCSI_IN2000
496 IN2000,
497 #endif
498 #ifdef CONFIG_SCSI_GENERIC_NCR5380
499 GENERIC_NCR5380,
500 #endif
501 #ifdef CONFIG_SCSI_NCR53C406A /* 53C406A should come before QLOGIC */
502 NCR53c406a,
503 #endif
504 #ifdef CONFIG_SCSI_SYM53C416
505 SYM53C416,
506 #endif
507 #ifdef CONFIG_SCSI_QLOGIC_FAS
508 QLOGICFAS,
509 #endif
510 #ifdef CONFIG_SCSI_QLOGIC_ISP
511 QLOGICISP,
512 #endif
513 #ifdef CONFIG_SCSI_QLOGIC_FC
514 QLOGICFC,
515 #endif
516 #ifdef CONFIG_SCSI_PAS16
517 MV_PAS16,
518 #endif
519 #ifdef CONFIG_SCSI_SEAGATE
520 SEAGATE_ST0X,
521 #endif
522 #ifdef CONFIG_SCSI_T128
523 TRANTOR_T128,
524 #endif
525 #ifdef CONFIG_SCSI_DTC3280
526 DTC3x80,
527 #endif
528 #ifdef CONFIG_SCSI_NCR53C7xx
529 NCR53c7xx,
530 #endif
531 #ifdef CONFIG_SCSI_SYM53C8XX
532 SYM53C8XX,
533 #endif
534 #ifdef CONFIG_SCSI_NCR53C8XX
535 NCR53C8XX,
536 #endif
537 #ifdef CONFIG_SCSI_EATA_DMA
538 EATA_DMA,
539 #endif
540 #ifdef CONFIG_SCSI_EATA_PIO
541 EATA_PIO,
542 #endif
543 #ifdef CONFIG_SCSI_7000FASST
544 WD7000,
545 #endif
546 #ifdef CONFIG_SCSI_MCA_53C9X
547 MCA_53C9X,
548 #endif
549 #ifdef CONFIG_SCSI_IBMMCA
550 IBMMCA,
551 #endif
552 #ifdef CONFIG_SCSI_EATA
553 EATA,
554 #endif
555 #ifdef CONFIG_SCSI_DC390T
556 DC390_T,
557 #endif
558 #ifdef CONFIG_SCSI_AM53C974
559 AM53C974,
560 #endif
561 #ifdef CONFIG_SCSI_MEGARAID
562 MEGARAID,
563 #endif
564 #ifdef CONFIG_SCSI_ACARD
565 ATP870U,
566 #endif
567 #ifdef CONFIG_SCSI_SUNESP
568 SCSI_SPARC_ESP,
569 #endif
570 #ifdef CONFIG_SCSI_GDTH
571 GDTH,
572 #endif
573 #ifdef CONFIG_SCSI_INITIO
574 INI9100U,
575 #endif
576 #ifdef CONFIG_SCSI_INIA100
577 INIA100,
578 #endif
579 #ifdef CONFIG_SCSI_QLOGICPTI
580 QLOGICPTI,
581 #endif
582 #ifdef CONFIG_BLK_DEV_IDESCSI
583 IDESCSI,
584 #endif
585 #ifdef CONFIG_SCSI_MESH
586 SCSI_MESH,
587 #endif
588 #ifdef CONFIG_SCSI_MAC53C94
589 SCSI_MAC53C94,
590 #endif
591 #ifdef CONFIG_SCSI_PLUTO
592 PLUTO,
593 #endif
594 #ifdef CONFIG_ARCH_ACORN
595 #ifdef CONFIG_SCSI_ACORNSCSI_3
596 ACORNSCSI_3,
597 #endif
598 #ifdef CONFIG_SCSI_CUMANA_1
599 CUMANA_NCR5380,
600 #endif
601 #ifdef CONFIG_SCSI_CUMANA_2
602 CUMANA_FAS216,
603 #endif
604 #ifdef CONFIG_SCSI_ECOSCSI
605 ECOSCSI_NCR5380,
606 #endif
607 #ifdef CONFIG_SCSI_OAK1
608 OAK_NCR5380,
609 #endif
610 #ifdef CONFIG_SCSI_POWERTECSCSI
611 POWERTECSCSI,
612 #endif
613 #endif
614 #ifdef CONFIG_IPHASE5526
615 IPH5526_SCSI_FC,
616 #endif
617 /* "Removable host adapters" below this line (Parallel Port/USB/other) */
618 #ifdef CONFIG_SCSI_PPA
619 PPA,
620 #endif
621 #ifdef CONFIG_SCSI_IMM
622 IMM,
623 #endif
624 #ifdef CONFIG_SUN3X_ESP
625 SCSI_SUN3X_ESP,
626 #endif
627 #ifdef CONFIG_SCSI_DEBUG
628 SCSI_DEBUG,
629 #endif
632 #define MAX_SCSI_HOSTS (sizeof(builtin_scsi_hosts) / sizeof(Scsi_Host_Template))
636 * Our semaphores and timeout counters, where size depends on
637 * MAX_SCSI_HOSTS here.
640 struct Scsi_Host * scsi_hostlist = NULL;
641 struct Scsi_Device_Template * scsi_devicelist = NULL;
643 int max_scsi_hosts = 0;
644 int next_scsi_host = 0;
646 void
647 scsi_unregister(struct Scsi_Host * sh){
648 struct Scsi_Host * shpnt;
650 if(scsi_hostlist == sh)
651 scsi_hostlist = sh->next;
652 else {
653 shpnt = scsi_hostlist;
654 while(shpnt->next != sh) shpnt = shpnt->next;
655 shpnt->next = shpnt->next->next;
658 /* If we are removing the last host registered, it is safe to reuse
659 * its host number (this avoids "holes" at boot time) (DB)
660 * It is also safe to reuse those of numbers directly below which have
661 * been released earlier (to avoid some holes in numbering).
663 if(sh->host_no == max_scsi_hosts - 1) {
664 while(--max_scsi_hosts >= next_scsi_host) {
665 shpnt = scsi_hostlist;
666 while(shpnt && shpnt->host_no != max_scsi_hosts - 1)
667 shpnt = shpnt->next;
668 if(shpnt)
669 break;
672 next_scsi_host--;
673 scsi_init_free((char *) sh, sizeof(struct Scsi_Host) + sh->extra_bytes);
676 /* We call this when we come across a new host adapter. We only do this
677 * once we are 100% sure that we want to use this host adapter - it is a
678 * pain to reverse this, so we try to avoid it
681 struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){
682 struct Scsi_Host * retval, *shpnt;
683 retval = (struct Scsi_Host *)scsi_init_malloc(sizeof(struct Scsi_Host) + j,
684 (tpnt->unchecked_isa_dma && j ? GFP_DMA : 0) | GFP_ATOMIC);
685 atomic_set(&retval->host_active,0);
686 retval->host_busy = 0;
687 retval->host_failed = 0;
688 retval->block = NULL;
689 retval->wish_block = 0;
690 if(j > 0xffff) panic("Too many extra bytes requested\n");
691 retval->extra_bytes = j;
692 retval->loaded_as_module = scsi_loadable_module_flag;
693 retval->host_no = max_scsi_hosts++; /* never reuse host_no (DB) */
694 next_scsi_host++;
695 retval->host_queue = NULL;
696 init_waitqueue_head(&retval->host_wait);
697 retval->resetting = 0;
698 retval->last_reset = 0;
699 retval->irq = 0;
700 retval->dma_channel = 0xff;
702 /* These three are default values which can be overridden */
703 retval->max_channel = 0;
704 retval->max_id = 8;
705 retval->max_lun = 8;
707 retval->unique_id = 0;
708 retval->io_port = 0;
709 retval->hostt = tpnt;
710 retval->next = NULL;
711 retval->in_recovery = 0;
712 retval->ehandler = NULL; /* Initial value until the thing starts up. */
713 retval->eh_notify = NULL; /* Who we notify when we exit. */
716 * Initialize the fields used for mid-level queueing.
718 retval->pending_commands = NULL;
719 retval->host_busy = FALSE;
721 #ifdef DEBUG
722 printk("Register %x %x: %d\n", (int)retval, (int)retval->hostt, j);
723 #endif
725 /* The next six are the default values which can be overridden
726 * if need be */
727 retval->this_id = tpnt->this_id;
728 retval->can_queue = tpnt->can_queue;
729 retval->sg_tablesize = tpnt->sg_tablesize;
730 retval->cmd_per_lun = tpnt->cmd_per_lun;
731 retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
732 retval->use_clustering = tpnt->use_clustering;
734 retval->select_queue_depths = NULL;
736 if(!scsi_hostlist)
737 scsi_hostlist = retval;
738 else
740 shpnt = scsi_hostlist;
741 while(shpnt->next) shpnt = shpnt->next;
742 shpnt->next = retval;
745 return retval;
749 scsi_register_device(struct Scsi_Device_Template * sdpnt)
751 if(sdpnt->next) panic("Device already registered");
752 sdpnt->next = scsi_devicelist;
753 scsi_devicelist = sdpnt;
754 return 0;
758 * Why is this a separate function? Because the kernel_thread code
759 * effectively does a fork, and there is a builtin exit() call when
760 * the child returns. The difficulty is that scsi_init() is
761 * marked __init, which means the memory is unmapped after bootup
762 * is complete, which means that the thread's exit() call gets wiped.
764 * The lesson is to *NEVER*, *NEVER* call kernel_thread() from an
765 * __init function, if that function could ever return.
767 static void launch_error_handler_thread(struct Scsi_Host * shpnt)
769 DECLARE_MUTEX_LOCKED(sem);
771 shpnt->eh_notify = &sem;
773 kernel_thread((int (*)(void *))scsi_error_handler,
774 (void *) shpnt, 0);
776 * Now wait for the kernel error thread to initialize itself
777 * as it might be needed when we scan the bus.
779 down (&sem);
780 shpnt->eh_notify = NULL;
783 unsigned int __init scsi_init(void)
785 static int called = 0;
786 int i, pcount;
787 unsigned long flags;
788 Scsi_Host_Template * tpnt;
789 struct Scsi_Host * shpnt;
790 const char * name;
792 if(called) return 0;
794 called = 1;
795 for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
798 * Initialize our semaphores. -1 is interpreted to mean
799 * "inactive" - where as 0 will indicate a time out condition.
802 pcount = next_scsi_host;
803 if (tpnt->detect) {
805 /* The detect routine must carefully spinunlock/spinlock if
806 it enables interrupts, since all interrupt handlers do
807 spinlock as well.
808 All lame drivers are going to fail due to the following
809 spinlock. For the time beeing let's use it only for drivers
810 using the new scsi code. NOTE: the detect routine could
811 redefine the value tpnt->use_new_eh_code. (DB, 13 May 1998) */
813 if (tpnt->use_new_eh_code) {
814 spin_lock_irqsave(&io_request_lock, flags);
815 tpnt->present = tpnt->detect(tpnt);
816 spin_unlock_irqrestore(&io_request_lock, flags);
818 else
819 tpnt->present = tpnt->detect(tpnt);
823 if (tpnt->detect && tpnt->present)
825 /* The only time this should come up is when people use
826 * some kind of patched driver of some kind or another. */
827 if(pcount == next_scsi_host) {
828 if(tpnt->present > 1)
829 panic("Failure to register low-level scsi driver");
830 /* The low-level driver failed to register a driver. We
831 * can do this now. */
832 scsi_register(tpnt,0);
834 tpnt->next = scsi_hosts;
835 scsi_hosts = tpnt;
837 /* Add the driver to /proc/scsi */
838 #if CONFIG_PROC_FS
839 build_proc_dir_entries(tpnt);
840 #endif
844 for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next)
846 if(shpnt->hostt->info)
847 name = shpnt->hostt->info(shpnt);
848 else
849 name = shpnt->hostt->name;
850 printk ("scsi%d : %s\n", /* And print a little message */
851 shpnt->host_no, name);
854 * Now start the error recovery thread for the host.
856 if( shpnt->hostt->use_new_eh_code )
858 launch_error_handler_thread(shpnt);
862 printk ("scsi : %d host%s.\n", next_scsi_host,
863 (next_scsi_host == 1) ? "" : "s");
865 scsi_make_blocked_list();
867 /* Now attach the high level drivers */
868 #ifdef CONFIG_BLK_DEV_SD
869 scsi_register_device(&sd_template);
870 #endif
871 #ifdef CONFIG_BLK_DEV_SR
872 scsi_register_device(&sr_template);
873 #endif
874 #ifdef CONFIG_CHR_DEV_ST
875 scsi_register_device(&st_template);
876 #endif
877 #ifdef CONFIG_CHR_DEV_SG
878 scsi_register_device(&sg_template);
879 #endif
881 #if 0
882 max_scsi_hosts = next_scsi_host;
883 #endif
884 return 0;
888 * Overrides for Emacs so that we follow Linus's tabbing style.
889 * Emacs will notice this stuff at the end of the file and automatically
890 * adjust the settings for this buffer only. This must remain at the end
891 * of the file.
892 * ---------------------------------------------------------------------------
893 * Local variables:
894 * c-indent-level: 4
895 * c-brace-imaginary-offset: 0
896 * c-brace-offset: -4
897 * c-argdecl-indent: 4
898 * c-label-offset: -4
899 * c-continued-statement-offset: 4
900 * c-continued-brace-offset: 0
901 * indent-tabs-mode: nil
902 * tab-width: 8
903 * End: