tpnt->buffer->last_SRpnt = NULL; 
static int st_probe(struct device *dev){	struct scsi_device *SDp = to_scsi_device(dev);	struct gendisk *disk = NULL;	struct cdev *cdev = NULL;	struct scsi_tape *tpnt = NULL;	struct st_modedef *STm;	struct st_partstat *STps;	struct st_buffer *buffer;	int i, j, mode, dev_num, error;	char *stp;	u64 bounce_limit;	if (SDp->type != TYPE_TAPE)		return -ENODEV;	if ((stp = st_incompatible(SDp))) {		printk(KERN_INFO		       "st: Found incompatible tape at scsi%d, channel %d, id %d, lun %d\n",		       SDp->host->host_no, SDp->channel, SDp->id, SDp->lun);		printk(KERN_INFO "st: The suggested driver is %s.\n", stp);		return -ENODEV;	}	i = SDp->host->sg_tablesize;	if (st_max_sg_segs < i)		i = st_max_sg_segs;	buffer = new_tape_buffer(1, (SDp->host)->unchecked_isa_dma, i);	if (buffer == NULL) {		printk(KERN_ERR		       "st: Can't allocate new tape buffer. Device not attached.\n");		goto out;	}	disk = alloc_disk(1);	if (!disk) {		printk(KERN_ERR "st: out of memory. Device not attached.\n");		goto out_buffer_free;	}	write_lock(&st_dev_arr_lock);	if (st_nr_dev >= st_dev_max) {		struct scsi_tape **tmp_da;		int tmp_dev_max;		tmp_dev_max = max(st_nr_dev * 2, 8);		if (tmp_dev_max > ST_MAX_TAPES)			tmp_dev_max = ST_MAX_TAPES;		if (tmp_dev_max <= st_nr_dev) {			write_unlock(&st_dev_arr_lock);			printk(KERN_ERR "st: Too many tape devices (max. %d).\n",			       ST_MAX_TAPES);			goto out_put_disk;		}		tmp_da = kmalloc(tmp_dev_max * sizeof(struct scsi_tape *), GFP_ATOMIC);		if (tmp_da == NULL) {			write_unlock(&st_dev_arr_lock);			printk(KERN_ERR "st: Can't extend device array.\n");			goto out_put_disk;		}		memset(tmp_da, 0, tmp_dev_max * sizeof(struct scsi_tape *));		if (scsi_tapes != NULL) {			memcpy(tmp_da, scsi_tapes,			       st_dev_max * sizeof(struct scsi_tape *));			kfree(scsi_tapes);		}		scsi_tapes = tmp_da;		st_dev_max = tmp_dev_max;	}	for (i = 0; i < st_dev_max; i++)		if (scsi_tapes[i] == NULL)			break;	if (i >= st_dev_max)		panic("scsi_devices corrupt (st)");	tpnt = kmalloc(sizeof(struct scsi_tape), GFP_ATOMIC);	if (tpnt == NULL) {		write_unlock(&st_dev_arr_lock);		printk(KERN_ERR "st: Can't allocate device descriptor.\n");		goto out_put_disk;	}	memset(tpnt, 0, sizeof(struct scsi_tape));	tpnt->disk = disk;	sprintf(disk->disk_name, "st%d", i);	disk->private_data = &tpnt->driver;	disk->queue = SDp->request_queue;	tpnt->driver = &st_template;	scsi_tapes[i] = tpnt;	dev_num = i;	tpnt->device = SDp;	if (SDp->scsi_level <= 2)		tpnt->tape_type = MT_ISSCSI1;	else		tpnt->tape_type = MT_ISSCSI2;	tpnt->buffer = buffer;	tpnt->inited = 0;	tpnt->dirty = 0;	tpnt->in_use = 0;	tpnt->drv_buffer = 1;	/* Try buffering if no mode sense */	tpnt->restr_dma = (SDp->host)->unchecked_isa_dma;	tpnt->use_pf = (SDp->scsi_level >= SCSI_2);	tpnt->density = 0;	tpnt->do_auto_lock = ST_AUTO_LOCK;	tpnt->can_bsr = (SDp->scsi_level > 2 ? 1 : ST_IN_FILE_POS); /* BSR mandatory in SCSI3 */	tpnt->can_partitions = 0;	tpnt->two_fm = ST_TWO_FM;	tpnt->fast_mteom = ST_FAST_MTEOM;	tpnt->scsi2_logical = ST_SCSI2LOGICAL;	tpnt->immediate = ST_NOWAIT;	tpnt->default_drvbuffer = 0xff;		/* No forced buffering */	tpnt->partition = 0;	tpnt->new_partition = 0;	tpnt->nbr_partitions = 0;	tpnt->device->timeout = ST_TIMEOUT;	tpnt->long_timeout = ST_LONG_TIMEOUT;	tpnt->try_dio = try_direct_io && !SDp->host->unchecked_isa_dma;	bounce_limit = scsi_calculate_bounce_limit(SDp->host) >> PAGE_SHIFT;	if (bounce_limit > ULONG_MAX)		bounce_limit = ULONG_MAX;	tpnt->max_pfn = bounce_limit;	for (i = 0; i < ST_NBR_MODES; i++) {		STm = &(tpnt->modes[i]);		STm->defined = 0;		STm->sysv = ST_SYSV;		STm->defaults_for_writes = 0;		STm->do_async_writes = ST_ASYNC_WRITES;		STm->do_buffer_writes = ST_BUFFER_WRITES;		STm->do_read_ahead = ST_READ_AHEAD;		STm->default_compression = ST_DONT_TOUCH;		STm->default_blksize = (-1);	/* No forced size */		STm->default_density = (-1);	/* No forced density */	}	for (i = 0; i < ST_NBR_PARTITIONS; i++) {		STps = &(tpnt->ps[i]);		STps->rw = ST_IDLE;		STps->eof = ST_NOEOF;		STps->at_sm = 0;		STps->last_block_valid = 0;		STps->drv_block = (-1);		STps->drv_file = (-1);	}	tpnt->current_mode = 0;	tpnt->modes[0].defined = 1;	tpnt->density_changed = tpnt->compression_changed =	    tpnt->blksize_changed = 0;	init_MUTEX(&tpnt->lock);	st_nr_dev++;	write_unlock(&st_dev_arr_lock);	for (mode = 0; mode < ST_NBR_MODES; ++mode) {		STm = &(tpnt->modes[mode]);		for (j=0; j < 2; j++) {			cdev = cdev_alloc();			if (!cdev) {				printk(KERN_ERR				       "st%d: out of memory. Device not attached.\n",				       dev_num);				goto out_free_tape;			}			cdev->owner = THIS_MODULE;			cdev->ops = &st_fops;			error = cdev_add(cdev,					 MKDEV(SCSI_TAPE_MAJOR, TAPE_MINOR(dev_num, mode, j)),					 1);			if (error) {				printk(KERN_ERR "st%d: Can't add %s-rewind mode %d\n",				       dev_num, j ? "non" : "auto", mode);				printk(KERN_ERR "st%d: Device not attached.\n", dev_num);				goto out_free_tape;			}			STm->cdevs[j] = cdev;		}		do_create_class_files(tpnt, dev_num, mode);	}	for (mode = 0; mode < ST_NBR_MODES; ++mode) {		/* Make sure that the minor numbers corresponding to the four		   first modes always get the same names */		i = mode << (4 - ST_NBR_MODE_BITS);		/*  Rewind entry  */		devfs_mk_cdev(MKDEV(SCSI_TAPE_MAJOR, TAPE_MINOR(dev_num, mode, 0)),			      S_IFCHR | S_IRUGO | S_IWUGO,			      "%s/mt%s", SDp->devfs_name, st_formats[i]);		/*  No-rewind entry  */		devfs_mk_cdev(MKDEV(SCSI_TAPE_MAJOR, TAPE_MINOR(dev_num, mode, 1)),			      S_IFCHR | S_IRUGO | S_IWUGO,			      "%s/mt%sn", SDp->devfs_name, st_formats[i]);	}	disk->number = devfs_register_tape(SDp->devfs_name);	printk(KERN_WARNING	"Attached scsi tape %s at scsi%d, channel %d, id %d, lun %d\n",	       tape_name(tpnt), SDp->host->host_no, SDp->channel, SDp->id, SDp->lun);	printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B), max page reachable by HBA %lu\n",	       tape_name(tpnt), tpnt->try_dio ? "yes" : "no",	       queue_dma_alignment(SDp->request_queue) + 1, tpnt->max_pfn);	return 0;out_free_tape:	for (mode=0; mode < ST_NBR_MODES; mode++) {		STm = &(tpnt->modes[mode]);		sysfs_remove_link(&tpnt->device->sdev_gendev.kobj,				  "tape");		for (j=0; j < 2; j++) {			if (STm->cdevs[j]) {				if (cdev == STm->cdevs[j])					cdev = NULL;				class_device_destroy(st_sysfs_class,						     MKDEV(SCSI_TAPE_MAJOR,							   TAPE_MINOR(i, mode, j)));				cdev_del(STm->cdevs[j]);			}		}	}	if (cdev)		cdev_del(cdev);	write_lock(&st_dev_arr_lock);	scsi_tapes[dev_num] = NULL;	st_nr_dev--;	write_unlock(&st_dev_arr_lock);out_put_disk:	put_disk(disk);	if (tpnt)		kfree(tpnt);out_buffer_free:	kfree(buffer);out:	return -ENODEV;};
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/f03a567054fea4f9d43c50ec91338266c0bd588d/st.c/clean/drivers/scsi/st.c