if(scsi_device_get(STp->device)) { write_unlock(&st_dev_arr_lock); return (-ENXIO); } 
static int st_open(struct inode *inode, struct file *filp){	int i, retval = (-EIO);	struct scsi_tape *STp;	struct st_partstat *STps;	int dev = TAPE_NR(inode);	char *name;	/*	 * We really want to do nonseekable_open(inode, filp); here, but some	 * versions of tar incorrectly call lseek on tapes and bail out if that	 * fails.  So we disallow pread() and pwrite(), but permit lseeks.	 */	filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE);	write_lock(&st_dev_arr_lock);	if (dev >= st_dev_max || scsi_tapes == NULL ||	    ((STp = scsi_tapes[dev]) == NULL)) {		write_unlock(&st_dev_arr_lock);		return (-ENXIO);	}	filp->private_data = STp;	name = tape_name(STp);	if (STp->in_use) {		write_unlock(&st_dev_arr_lock);		DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); )		return (-EBUSY);	}	if(scsi_device_get(STp->device)) {		write_unlock(&st_dev_arr_lock);		return (-ENXIO);	}	STp->in_use = 1;	write_unlock(&st_dev_arr_lock);	STp->rew_at_close = STp->autorew_dev = (iminor(inode) & 0x80) == 0;	if (!scsi_block_when_processing_errors(STp->device)) {		retval = (-ENXIO);		goto err_out;	}	/* See that we have at least a one page buffer available */	if (!enlarge_buffer(STp->buffer, PAGE_SIZE, STp->restr_dma)) {		printk(KERN_WARNING "%s: Can't allocate one page tape buffer.\n",		       name);		retval = (-EOVERFLOW);		goto err_out;	}	(STp->buffer)->writing = 0;	(STp->buffer)->syscall_result = 0;	STp->write_prot = ((filp->f_flags & O_ACCMODE) == O_RDONLY);	STp->dirty = 0;	for (i = 0; i < ST_NBR_PARTITIONS; i++) {		STps = &(STp->ps[i]);		STps->rw = ST_IDLE;	}	STp->recover_count = 0;	DEB( STp->nbr_waits = STp->nbr_finished = 0;	     STp->nbr_requests = STp->nbr_dio = STp->nbr_pages = STp->nbr_combinable = 0; )	retval = check_tape(STp, filp);	if (retval < 0)		goto err_out;	if ((filp->f_flags & O_NONBLOCK) == 0 &&	    retval != CHKRES_READY) {		retval = (-EIO);		goto err_out;	}	return 0; err_out:	normalize_buffer(STp->buffer);	STp->in_use = 0;	scsi_device_put(STp->device);	return retval;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/f03a567054fea4f9d43c50ec91338266c0bd588d/st.c/clean/drivers/scsi/st.c