sclp->page = virt_to_page(p); sclp->offset = offset_in_page(p); sclp->length = ret_sz; 
sg_set_buf(sclp, p, ret_sz); 
sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size){	int ret_sz;	int blk_size = buff_size;	unsigned char *p = NULL;	if ((blk_size < 0) || (!sfp))		return -EFAULT;	if (0 == blk_size)		++blk_size;	/* don't know why *//* round request up to next highest SG_SECTOR_SZ byte boundary */	blk_size = (blk_size + SG_SECTOR_MSK) & (~SG_SECTOR_MSK);	SCSI_LOG_TIMEOUT(4, printk("sg_build_indirect: buff_size=%d, blk_size=%d\n",				   buff_size, blk_size));	if (blk_size <= SG_SCATTER_SZ) {		p = sg_page_malloc(blk_size, sfp->low_dma, &ret_sz);		if (!p)			return -ENOMEM;		if (blk_size == ret_sz) {	/* got it on the first attempt */			schp->k_use_sg = 0;			schp->buffer = p;			schp->bufflen = blk_size;			schp->b_malloc_len = blk_size;			return 0;		}	} else {		p = sg_page_malloc(SG_SCATTER_SZ, sfp->low_dma, &ret_sz);		if (!p)			return -ENOMEM;	}/* Want some local declarations, so start new block ... */	{			/* lets try and build a scatter gather list */		struct scatterlist *sclp;		int k, rem_sz, num;		int mx_sc_elems;		int sg_tablesize = sfp->parentdp->sg_tablesize;		int first = 1;		/* N.B. ret_sz carried into this block ... */		mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize);		if (mx_sc_elems < 0)			return mx_sc_elems;	/* most likely -ENOMEM */		for (k = 0, sclp = schp->buffer, rem_sz = blk_size;		     (rem_sz > 0) && (k < mx_sc_elems);		     ++k, rem_sz -= ret_sz, ++sclp) {			if (first)				first = 0;			else {				num =				    (rem_sz >				     SG_SCATTER_SZ) ? SG_SCATTER_SZ : rem_sz;				p = sg_page_malloc(num, sfp->low_dma, &ret_sz);				if (!p)					break;			}			sclp->page = virt_to_page(p);			sclp->offset = offset_in_page(p);			sclp->length = ret_sz;			SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n",					  k, sg_scatg2virt(sclp), ret_sz));		}		/* end of for loop */		schp->k_use_sg = k;		SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, rem_sz=%d\n", k, rem_sz));		schp->bufflen = blk_size;		if (rem_sz > 0)	/* must have failed */			return -ENOMEM;	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/378f058cc49bcda7fa63d3cd86d2f9a0a5188b1c/sg.c/clean/drivers/scsi/sg.c