int segs, nbr, max_segs, b_size, priority, order, got; 
int segs, nbr, max_segs, b_size, order, got; gfp_t priority; 
static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma){	int segs, nbr, max_segs, b_size, priority, order, got;	if (STbuffer->buffer_size >= OS_FRAME_SIZE)		return 1;	if (STbuffer->sg_segs) {		printk(KERN_WARNING "osst :A: Buffer not previously normalized.\n");		normalize_buffer(STbuffer);	}	/* See how many segments we can use -- need at least two */	nbr = max_segs = STbuffer->use_sg;	if (nbr <= 2)		return 0;	priority = GFP_KERNEL /* | __GFP_NOWARN */;	if (need_dma)		priority |= GFP_DMA;	/* Try to allocate the first segment up to OS_DATA_SIZE and the others	   big enough to reach the goal (code assumes no segments in place) */	for (b_size = OS_DATA_SIZE, order = OSST_FIRST_ORDER; b_size >= PAGE_SIZE; order--, b_size /= 2) {		STbuffer->sg[0].page = alloc_pages(priority, order);		STbuffer->sg[0].offset = 0;		if (STbuffer->sg[0].page != NULL) {		    STbuffer->sg[0].length = b_size;		    STbuffer->b_data = page_address(STbuffer->sg[0].page);		    break;		}	}	if (STbuffer->sg[0].page == NULL) {		printk(KERN_NOTICE "osst :I: Can't allocate tape buffer main segment.\n");		return 0;	}	/* Got initial segment of 'bsize,order', continue with same size if possible, except for AUX */	for (segs=STbuffer->sg_segs=1, got=b_size;	     segs < max_segs && got < OS_FRAME_SIZE; ) {		STbuffer->sg[segs].page =				alloc_pages(priority, (OS_FRAME_SIZE - got <= PAGE_SIZE) ? 0 : order);		STbuffer->sg[segs].offset = 0;		if (STbuffer->sg[segs].page == NULL) {			if (OS_FRAME_SIZE - got <= (max_segs - segs) * b_size / 2 && order) {				b_size /= 2;  /* Large enough for the rest of the buffers */				order--;				continue;			}			printk(KERN_WARNING "osst :W: Failed to enlarge buffer to %d bytes.\n",						OS_FRAME_SIZE);#if DEBUG			STbuffer->buffer_size = got;#endif			normalize_buffer(STbuffer);			return 0;		}		STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size;		got += STbuffer->sg[segs].length;		STbuffer->buffer_size = got;		STbuffer->sg_segs = ++segs;	}#if DEBUG	if (debugging) {		printk(OSST_DEB_MSG			   "osst :D: Expanded tape buffer (%d bytes, %d->%d segments, dma: %d, at: %p).\n",			   got, STbuffer->orig_sg_segs, STbuffer->sg_segs, need_dma, STbuffer->b_data);		printk(OSST_DEB_MSG			   "osst :D: segment sizes: first %d at %p, last %d bytes at %p.\n",			   STbuffer->sg[0].length, page_address(STbuffer->sg[0].page),			   STbuffer->sg[segs-1].length, page_address(STbuffer->sg[segs-1].page));	}#endif	return 1;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/c53033f6b0bd7cc133b7f433083f0394cf29ac70/osst.c/clean/drivers/scsi/osst.c