aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aic7xxx/aic79xx_osm.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2005-08-15 07:28:46 -0400
committerJames Bottomley <jejb@mulgrave.(none)>2005-08-15 10:18:55 -0400
commit85a46523ff68aa0e4d2477c51075ffd9fc7e7a14 (patch)
treec465c274ffe0e4118ed46ad4e0e09dca975aeb1f /drivers/scsi/aic7xxx/aic79xx_osm.c
parentd46b1d549e1414d673e0ec18219f4f5e30d5f3f5 (diff)
[SCSI] aic79xx: sane pci probing
remove ahd_tailq and do sane pci probing. ported over from aic7xxx. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/aic7xxx/aic79xx_osm.c')
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c108
1 files changed, 20 insertions, 88 deletions
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 2f158624c5d2..3feb739cd554 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -60,11 +60,6 @@ static struct scsi_transport_template *ahd_linux_transport_template = NULL;
60#include <linux/delay.h> /* For ssleep/msleep */ 60#include <linux/delay.h> /* For ssleep/msleep */
61 61
62/* 62/*
63 * Lock protecting manipulation of the ahd softc list.
64 */
65spinlock_t ahd_list_spinlock;
66
67/*
68 * Bucket size for counting good commands in between bad ones. 63 * Bucket size for counting good commands in between bad ones.
69 */ 64 */
70#define AHD_LINUX_ERR_THRESH 1000 65#define AHD_LINUX_ERR_THRESH 1000
@@ -303,13 +298,6 @@ static uint32_t aic79xx_pci_parity = ~0;
303uint32_t aic79xx_allow_memio = ~0; 298uint32_t aic79xx_allow_memio = ~0;
304 299
305/* 300/*
306 * aic79xx_detect() has been run, so register all device arrivals
307 * immediately with the system rather than deferring to the sorted
308 * attachment performed by aic79xx_detect().
309 */
310int aic79xx_detect_complete;
311
312/*
313 * So that we can set how long each device is given as a selection timeout. 301 * So that we can set how long each device is given as a selection timeout.
314 * The table of values goes like this: 302 * The table of values goes like this:
315 * 0 - 256ms 303 * 0 - 256ms
@@ -387,7 +375,9 @@ static void ahd_linux_setup_tag_info_global(char *p);
387static aic_option_callback_t ahd_linux_setup_tag_info; 375static aic_option_callback_t ahd_linux_setup_tag_info;
388static aic_option_callback_t ahd_linux_setup_iocell_info; 376static aic_option_callback_t ahd_linux_setup_iocell_info;
389static int aic79xx_setup(char *c); 377static int aic79xx_setup(char *c);
390static int ahd_linux_next_unit(void); 378
379static int ahd_linux_unit;
380
391 381
392/****************************** Inlines ***************************************/ 382/****************************** Inlines ***************************************/
393static __inline void ahd_linux_unmap_scb(struct ahd_softc*, struct scb*); 383static __inline void ahd_linux_unmap_scb(struct ahd_softc*, struct scb*);
@@ -418,50 +408,6 @@ ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb)
418 ((((cmd)->device->id << TID_SHIFT) & TID) | (ahd)->our_id) 408 ((((cmd)->device->id << TID_SHIFT) & TID) | (ahd)->our_id)
419 409
420/* 410/*
421 * Try to detect an Adaptec 79XX controller.
422 */
423static int
424ahd_linux_detect(struct scsi_host_template *template)
425{
426 struct ahd_softc *ahd;
427 int found;
428 int error = 0;
429
430 /*
431 * If we've been passed any parameters, process them now.
432 */
433 if (aic79xx)
434 aic79xx_setup(aic79xx);
435
436 template->proc_name = "aic79xx";
437
438 /*
439 * Initialize our softc list lock prior to
440 * probing for any adapters.
441 */
442 ahd_list_lockinit();
443
444#ifdef CONFIG_PCI
445 error = ahd_linux_pci_init();
446 if (error)
447 return error;
448#endif
449
450 /*
451 * Register with the SCSI layer all
452 * controllers we've found.
453 */
454 found = 0;
455 TAILQ_FOREACH(ahd, &ahd_tailq, links) {
456
457 if (ahd_linux_register_host(ahd, template) == 0)
458 found++;
459 }
460 aic79xx_detect_complete++;
461 return found;
462}
463
464/*
465 * Return a string describing the driver. 411 * Return a string describing the driver.
466 */ 412 */
467static const char * 413static const char *
@@ -760,6 +706,7 @@ ahd_linux_bus_reset(struct scsi_cmnd *cmd)
760struct scsi_host_template aic79xx_driver_template = { 706struct scsi_host_template aic79xx_driver_template = {
761 .module = THIS_MODULE, 707 .module = THIS_MODULE,
762 .name = "aic79xx", 708 .name = "aic79xx",
709 .proc_name = "aic79xx",
763 .proc_info = ahd_linux_proc_info, 710 .proc_info = ahd_linux_proc_info,
764 .info = ahd_linux_info, 711 .info = ahd_linux_info,
765 .queuecommand = ahd_linux_queue, 712 .queuecommand = ahd_linux_queue,
@@ -1072,7 +1019,7 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa
1072 host->max_lun = AHD_NUM_LUNS; 1019 host->max_lun = AHD_NUM_LUNS;
1073 host->max_channel = 0; 1020 host->max_channel = 0;
1074 host->sg_tablesize = AHD_NSEG; 1021 host->sg_tablesize = AHD_NSEG;
1075 ahd_set_unit(ahd, ahd_linux_next_unit()); 1022 ahd_set_unit(ahd, ahd_linux_unit++);
1076 sprintf(buf, "scsi%d", host->host_no); 1023 sprintf(buf, "scsi%d", host->host_no);
1077 new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT); 1024 new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
1078 if (new_name != NULL) { 1025 if (new_name != NULL) {
@@ -1101,29 +1048,6 @@ ahd_linux_get_memsize(void)
1101} 1048}
1102 1049
1103/* 1050/*
1104 * Find the smallest available unit number to use
1105 * for a new device. We don't just use a static
1106 * count to handle the "repeated hot-(un)plug"
1107 * scenario.
1108 */
1109static int
1110ahd_linux_next_unit(void)
1111{
1112 struct ahd_softc *ahd;
1113 int unit;
1114
1115 unit = 0;
1116retry:
1117 TAILQ_FOREACH(ahd, &ahd_tailq, links) {
1118 if (ahd->unit == unit) {
1119 unit++;
1120 goto retry;
1121 }
1122 }
1123 return (unit);
1124}
1125
1126/*
1127 * Place the SCSI bus into a known state by either resetting it, 1051 * Place the SCSI bus into a known state by either resetting it,
1128 * or forcing transfer negotiations on the next command to any 1052 * or forcing transfer negotiations on the next command to any
1129 * target. 1053 * target.
@@ -2755,23 +2679,31 @@ static struct spi_function_template ahd_linux_transport_functions = {
2755 .show_hold_mcs = 1, 2679 .show_hold_mcs = 1,
2756}; 2680};
2757 2681
2758
2759
2760static int __init 2682static int __init
2761ahd_linux_init(void) 2683ahd_linux_init(void)
2762{ 2684{
2763 ahd_linux_transport_template = spi_attach_transport(&ahd_linux_transport_functions); 2685 int error = 0;
2686
2687 /*
2688 * If we've been passed any parameters, process them now.
2689 */
2690 if (aic79xx)
2691 aic79xx_setup(aic79xx);
2692
2693 ahd_linux_transport_template =
2694 spi_attach_transport(&ahd_linux_transport_functions);
2764 if (!ahd_linux_transport_template) 2695 if (!ahd_linux_transport_template)
2765 return -ENODEV; 2696 return -ENODEV;
2697
2766 scsi_transport_reserve_target(ahd_linux_transport_template, 2698 scsi_transport_reserve_target(ahd_linux_transport_template,
2767 sizeof(struct ahd_linux_target)); 2699 sizeof(struct ahd_linux_target));
2768 scsi_transport_reserve_device(ahd_linux_transport_template, 2700 scsi_transport_reserve_device(ahd_linux_transport_template,
2769 sizeof(struct ahd_linux_device)); 2701 sizeof(struct ahd_linux_device));
2770 if (ahd_linux_detect(&aic79xx_driver_template) > 0)
2771 return 0;
2772 spi_release_transport(ahd_linux_transport_template);
2773 2702
2774 return -ENODEV; 2703 error = ahd_linux_pci_init();
2704 if (error)
2705 spi_release_transport(ahd_linux_transport_template);
2706 return error;
2775} 2707}
2776 2708
2777static void __exit 2709static void __exit