#include "drmP.h"
-#if !__HAVE_CTX_BITMAP
-#error "__HAVE_CTX_BITMAP must be defined"
-#endif
-
-
/******************************************************************/
/** \name Context bitmap support */
/*@{*/
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
+ drm_ctx_priv_map_t __user *argp = (void __user *)arg;
drm_ctx_priv_map_t request;
drm_map_t *map;
- if (copy_from_user(&request,
- (drm_ctx_priv_map_t *)arg,
- sizeof(request)))
+ if (copy_from_user(&request, argp, sizeof(request)))
return -EFAULT;
down(&dev->struct_sem);
up(&dev->struct_sem);
request.handle = map->handle;
- if (copy_to_user((drm_ctx_priv_map_t *)arg, &request, sizeof(request)))
+ if (copy_to_user(argp, &request, sizeof(request)))
return -EFAULT;
return 0;
}
struct list_head *list;
if (copy_from_user(&request,
- (drm_ctx_priv_map_t *)arg,
+ (drm_ctx_priv_map_t __user *)arg,
sizeof(request)))
return -EFAULT;
unsigned int cmd, unsigned long arg )
{
drm_ctx_res_t res;
+ drm_ctx_t __user *argp = (void __user *)arg;
drm_ctx_t ctx;
int i;
- if ( copy_from_user( &res, (drm_ctx_res_t *)arg, sizeof(res) ) )
+ if ( copy_from_user( &res, argp, sizeof(res) ) )
return -EFAULT;
if ( res.count >= DRM_RESERVED_CONTEXTS ) {
}
res.count = DRM_RESERVED_CONTEXTS;
- if ( copy_to_user( (drm_ctx_res_t *)arg, &res, sizeof(res) ) )
+ if ( copy_to_user( argp, &res, sizeof(res) ) )
return -EFAULT;
return 0;
}
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
drm_ctx_list_t * ctx_entry;
+ drm_ctx_t __user *argp = (void __user *)arg;
drm_ctx_t ctx;
- if ( copy_from_user( &ctx, (drm_ctx_t *)arg, sizeof(ctx) ) )
+ if ( copy_from_user( &ctx, argp, sizeof(ctx) ) )
return -EFAULT;
ctx.handle = DRM(ctxbitmap_next)( dev );
/* Should this return -EBUSY instead? */
return -ENOMEM;
}
-#ifdef DRIVER_CTX_CTOR
+
if ( ctx.handle != DRM_KERNEL_CONTEXT )
- DRIVER_CTX_CTOR(ctx.handle); /* XXX: also pass dev ? */
-#endif
+ {
+ if (dev->fn_tbl.context_ctor)
+ dev->fn_tbl.context_ctor(dev, ctx.handle);
+ }
+
ctx_entry = DRM(alloc)( sizeof(*ctx_entry), DRM_MEM_CTXLIST );
if ( !ctx_entry ) {
DRM_DEBUG("out of memory\n");
++dev->ctx_count;
up( &dev->ctxlist_sem );
- if ( copy_to_user( (drm_ctx_t *)arg, &ctx, sizeof(ctx) ) )
+ if ( copy_to_user( argp, &ctx, sizeof(ctx) ) )
return -EFAULT;
return 0;
}
int DRM(getctx)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
+ drm_ctx_t __user *argp = (void __user *)arg;
drm_ctx_t ctx;
- if ( copy_from_user( &ctx, (drm_ctx_t*)arg, sizeof(ctx) ) )
+ if ( copy_from_user( &ctx, argp, sizeof(ctx) ) )
return -EFAULT;
/* This is 0, because we don't handle any context flags */
ctx.flags = 0;
- if ( copy_to_user( (drm_ctx_t*)arg, &ctx, sizeof(ctx) ) )
+ if ( copy_to_user( argp, &ctx, sizeof(ctx) ) )
return -EFAULT;
return 0;
}
drm_device_t *dev = priv->dev;
drm_ctx_t ctx;
- if ( copy_from_user( &ctx, (drm_ctx_t *)arg, sizeof(ctx) ) )
+ if ( copy_from_user( &ctx, (drm_ctx_t __user *)arg, sizeof(ctx) ) )
return -EFAULT;
DRM_DEBUG( "%d\n", ctx.handle );
drm_device_t *dev = priv->dev;
drm_ctx_t ctx;
- if ( copy_from_user( &ctx, (drm_ctx_t *)arg, sizeof(ctx) ) )
+ if ( copy_from_user( &ctx, (drm_ctx_t __user *)arg, sizeof(ctx) ) )
return -EFAULT;
DRM_DEBUG( "%d\n", ctx.handle );
drm_device_t *dev = priv->dev;
drm_ctx_t ctx;
- if ( copy_from_user( &ctx, (drm_ctx_t *)arg, sizeof(ctx) ) )
+ if ( copy_from_user( &ctx, (drm_ctx_t __user *)arg, sizeof(ctx) ) )
return -EFAULT;
DRM_DEBUG( "%d\n", ctx.handle );
priv->remove_auth_on_close = 1;
}
if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
-#ifdef DRIVER_CTX_DTOR
- DRIVER_CTX_DTOR(ctx.handle); /* XXX: also pass dev ? */
-#endif
+ if (dev->fn_tbl.context_dtor)
+ dev->fn_tbl.context_dtor(dev, ctx.handle);
DRM(ctxbitmap_free)( dev, ctx.handle );
}
}
/*@}*/
+