int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_sis_mem_t fb; struct sis_memreq req; int retval = 0; if (copy_from_user(&fb, (drm_sis_mem_t *)arg, sizeof(fb))) return -EFAULT; req.size = fb.size; sis_malloc(&req); if(req.offset){ /* TODO */ fb.offset = req.offset; fb.free = req.offset; if(!add_alloc_set(fb.context, VIDEO_TYPE, fb.free)){ DRM_DEBUG("adding to allocation set fails\n"); sis_free(req.offset); retval = -1; } } else{ fb.offset = 0; fb.size = 0; fb.free = 0; } if (copy_to_user((drm_sis_mem_t *)arg, &fb, sizeof(fb))) return -EFAULT; DRM_DEBUG("alloc fb, size = %d, offset = %ld\n", fb.size, req.offset); return retval; }
static int sis_fb_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_sis_mem_t *fb = data; struct sis_memreq req; int retval = 0; req.size = fb->size; sis_malloc(&req); if (req.offset) { /* TODO */ fb->offset = req.offset; fb->free = req.offset; if (!add_alloc_set(fb->context, VIDEO_TYPE, fb->free)) { DRM_DEBUG("adding to allocation set fails\n"); sis_free(req.offset); retval = -EINVAL; } } else { fb->offset = 0; fb->size = 0; fb->free = 0; } DRM_DEBUG("alloc fb, size = %d, offset = %ld\n", fb->size, req.offset); return retval; }
int sis_fb_alloc( DRM_IOCTL_ARGS ) { drm_sis_mem_t fb; struct sis_memreq req; int retval = 0; DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_mem_t *)data, sizeof(fb)); req.size = fb.size; sis_malloc(&req); if (req.offset) { /* TODO */ fb.offset = req.offset; fb.free = req.offset; if (!add_alloc_set(fb.context, VIDEO_TYPE, fb.free)) { DRM_DEBUG("adding to allocation set fails\n"); sis_free(req.offset); retval = DRM_ERR(EINVAL); } } else { fb.offset = 0; fb.size = 0; fb.free = 0; } DRM_COPY_TO_USER_IOCTL((drm_sis_mem_t *)data, fb, sizeof(fb)); DRM_DEBUG("alloc fb, size = %d, offset = %ld\n", fb.size, req.offset); return retval; }