host->transportt = ahc_linux_transport_template;  
ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template){	char	 buf[80];	struct	 Scsi_Host *host;	char	*new_name;	u_long	 s;	u_int	 targ_offset;	template->name = ahc->description;	host = scsi_host_alloc(template, sizeof(struct ahc_softc *));	if (host == NULL)		return (ENOMEM);	*((struct ahc_softc **)host->hostdata) = ahc;	ahc_lock(ahc, &s);#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)	scsi_assign_lock(host, &ahc->platform_data->spin_lock);#elif AHC_SCSI_HAS_HOST_LOCK != 0	host->lock = &ahc->platform_data->spin_lock;#endif	ahc->platform_data->host = host;	host->can_queue = AHC_MAX_QUEUE;	host->cmd_per_lun = 2;	/* XXX No way to communicate the ID for multiple channels */	host->this_id = ahc->our_id;	host->irq = ahc->platform_data->irq;	host->max_id = (ahc->features & AHC_WIDE) ? 16 : 8;	host->max_lun = AHC_NUM_LUNS;	host->max_channel = (ahc->features & AHC_TWIN) ? 1 : 0;	host->sg_tablesize = AHC_NSEG;	ahc_set_unit(ahc, ahc_linux_next_unit());	sprintf(buf, "scsi%d", host->host_no);	new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);	if (new_name != NULL) {		strcpy(new_name, buf);		ahc_set_name(ahc, new_name);	}	host->unique_id = ahc->unit;#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)	scsi_set_pci_device(host, ahc->dev_softc);#endif	ahc_linux_initialize_scsi_bus(ahc);	ahc_unlock(ahc, &s);	ahc->platform_data->dv_pid = kernel_thread(ahc_linux_dv_thread, ahc, 0);	ahc_lock(ahc, &s);	if (ahc->platform_data->dv_pid < 0) {		printf("%s: Failed to create DV thread, error= %d\n",		       ahc_name(ahc), ahc->platform_data->dv_pid);		return (-ahc->platform_data->dv_pid);	}	/*	 * Initially allocate *all* of our linux target objects	 * so that the DV thread will scan them all in parallel	 * just after driver initialization.  Any device that	 * does not exist will have its target object destroyed	 * by the selection timeout handler.  In the case of a	 * device that appears after the initial DV scan, async	 * negotiation will occur for the first command, and DV	 * will comence should that first command be successful.	 */	for (targ_offset = 0;	     targ_offset < host->max_id * (host->max_channel + 1);	     targ_offset++) {		u_int channel;		u_int target;		channel = 0;		target = targ_offset;		if (target > 7		 && (ahc->features & AHC_TWIN) != 0) {			channel = 1;			target &= 0x7;		}		/*		 * Skip our own ID.  Some Compaq/HP storage devices		 * have enclosure management devices that respond to		 * single bit selection (i.e. selecting ourselves).		 * It is expected that either an external application		 * or a modified kernel will be used to probe this		 * ID if it is appropriate.  To accommodate these		 * installations, ahc_linux_alloc_target() will allocate		 * for our ID if asked to do so.		 */		if ((channel == 0 && target == ahc->our_id)		 || (channel == 1 && target == ahc->our_id_b))			continue;		ahc_linux_alloc_target(ahc, channel, target);	}	ahc_intr_enable(ahc, TRUE);	ahc_linux_start_dv(ahc);	ahc_unlock(ahc, &s);#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)	scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */	scsi_scan_host(host);#endif	return (0);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/92d161c373b45be158b73a162bedebb5293a73d3/aic7xxx_osm.c/buggy/drivers/scsi/aic7xxx/aic7xxx_osm.c