if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP)) || (drm_core_check_feature(dev, DRIVER_SG) && (dma->flags & _DRM_DMA_USE_SG)) ) { 
if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP)) || (drm_core_check_feature(dev, DRIVER_SG) && (dma->flags & _DRM_DMA_USE_SG)) || (drm_core_check_feature(dev, DRIVER_FB_DMA) && (dma->flags & _DRM_DMA_USE_FB))) { 
int drm_mapbufs( struct inode *inode, struct file *filp,		  unsigned int cmd, unsigned long arg ){	drm_file_t *priv = filp->private_data;	drm_device_t *dev = priv->head->dev;	drm_device_dma_t *dma = dev->dma;	drm_buf_map_t __user *argp = (void __user *)arg;	int retcode = 0;	const int zero = 0;	unsigned long virtual;	unsigned long address;	drm_buf_map_t request;	int i;	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))		return -EINVAL;	if ( !dma ) return -EINVAL;	spin_lock( &dev->count_lock );	if ( atomic_read( &dev->buf_alloc ) ) {		spin_unlock( &dev->count_lock );		return -EBUSY;	}	dev->buf_use++;		/* Can't allocate more after this call */	spin_unlock( &dev->count_lock );	if ( copy_from_user( &request, argp, sizeof(request) ) )		return -EFAULT;	if ( request.count >= dma->buf_count ) {		if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP)) ||		    (drm_core_check_feature(dev, DRIVER_SG) && (dma->flags & _DRM_DMA_USE_SG)) ) {			drm_map_t *map = dev->agp_buffer_map;			if ( !map ) {				retcode = -EINVAL;				goto done;			}#if LINUX_VERSION_CODE <= 0x020402			down( &current->mm->mmap_sem );#else			down_write( &current->mm->mmap_sem );#endif			virtual = do_mmap( filp, 0, map->size,					   PROT_READ | PROT_WRITE,					   MAP_SHARED,					   (unsigned long)map->offset );#if LINUX_VERSION_CODE <= 0x020402			up( &current->mm->mmap_sem );#else			up_write( &current->mm->mmap_sem );#endif		} else {#if LINUX_VERSION_CODE <= 0x020402			down( &current->mm->mmap_sem );#else			down_write( &current->mm->mmap_sem );#endif			virtual = do_mmap( filp, 0, dma->byte_count,					   PROT_READ | PROT_WRITE,					   MAP_SHARED, 0 );#if LINUX_VERSION_CODE <= 0x020402			up( &current->mm->mmap_sem );#else			up_write( &current->mm->mmap_sem );#endif		}		if ( virtual > -1024UL ) {			/* Real error */			retcode = (signed long)virtual;			goto done;		}		request.virtual = (void __user *)virtual;		for ( i = 0 ; i < dma->buf_count ; i++ ) {			if ( copy_to_user( &request.list[i].idx,					   &dma->buflist[i]->idx,					   sizeof(request.list[0].idx) ) ) {				retcode = -EFAULT;				goto done;			}			if ( copy_to_user( &request.list[i].total,					   &dma->buflist[i]->total,					   sizeof(request.list[0].total) ) ) {				retcode = -EFAULT;				goto done;			}			if ( copy_to_user( &request.list[i].used,					   &zero,					   sizeof(zero) ) ) {				retcode = -EFAULT;				goto done;			}			address = virtual + dma->buflist[i]->offset; /* *** */			if ( copy_to_user( &request.list[i].address,					   &address,					   sizeof(address) ) ) {				retcode = -EFAULT;				goto done;			}		}	} done:	request.count = dma->buf_count;	DRM_DEBUG( "%d buffers, retcode = %d\n", request.count, retcode );	if ( copy_to_user( argp, &request, sizeof(request) ) )		return -EFAULT;	return retcode;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/b84397d6390ef04e8080d66bf528418ab5e75dc0/drm_bufs.c/clean/drivers/char/drm/drm_bufs.c