summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2003-02-17 01:58:46 +0000
committerEric Anholt <anholt@freebsd.org>2003-02-17 01:58:46 +0000
commita44670395a1c74e8de100f1a836d816a5dbcbaf7 (patch)
treec5fa532d6ab1d7e603b3e89f3fde4ebd3399ff53 /shared
parent052bbb84fd107b9b5a8f581f23b22f4c009c2cec (diff)
os-independence changes (DRM_IOCTL_ARGS, DRM_DEVICE, DRM_COPY*USER_IOCTL)
Diffstat (limited to 'shared')
-rw-r--r--shared/mach64_dma.c44
-rw-r--r--shared/mach64_drv.h30
-rw-r--r--shared/mach64_state.c50
3 files changed, 42 insertions, 82 deletions
diff --git a/shared/mach64_dma.c b/shared/mach64_dma.c
index fa6fc394..0d1ffb35 100644
--- a/shared/mach64_dma.c
+++ b/shared/mach64_dma.c
@@ -1089,17 +1089,15 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
* IOCTL handlers
*/
-int mach64_dma_init( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
+int mach64_dma_init( DRM_IOCTL_ARGS )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ DRM_DEVICE;
drm_mach64_init_t init;
DRM_DEBUG( "%s\n", __FUNCTION__ );
- if ( copy_from_user( &init, (drm_mach64_init_t *)arg, sizeof(init) ) )
- return -EFAULT;
+ DRM_COPY_FROM_USER_IOCTL( init, (drm_mach64_init_t *)data,
+ sizeof(init) );
switch ( init.func ) {
case DRM_MACH64_INIT_DMA:
@@ -1111,11 +1109,9 @@ int mach64_dma_init( struct inode *inode, struct file *filp,
return -EINVAL;
}
-int mach64_dma_idle( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
+int mach64_dma_idle( DRM_IOCTL_ARGS )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ DRM_DEVICE;
drm_mach64_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "%s\n", __FUNCTION__ );
@@ -1125,11 +1121,9 @@ int mach64_dma_idle( struct inode *inode, struct file *filp,
return mach64_do_dma_idle( dev_priv );
}
-int mach64_dma_flush( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
+int mach64_dma_flush( DRM_IOCTL_ARGS )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ DRM_DEVICE;
drm_mach64_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "%s\n", __FUNCTION__ );
@@ -1139,11 +1133,9 @@ int mach64_dma_flush( struct inode *inode, struct file *filp,
return mach64_do_dma_flush( dev_priv );
}
-int mach64_engine_reset( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
+int mach64_engine_reset( DRM_IOCTL_ARGS )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ DRM_DEVICE;
drm_mach64_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "%s\n", __FUNCTION__ );
@@ -1367,21 +1359,16 @@ static int mach64_dma_get_buffers( drm_device_t *dev, drm_dma_t *d )
return 0;
}
-int mach64_dma_buffers( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
+int mach64_dma_buffers( DRM_IOCTL_ARGS )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
drm_dma_t d;
int ret = 0;
LOCK_TEST_WITH_RETURN( dev );
- if ( copy_from_user( &d, (drm_dma_t *)arg, sizeof(d) ) )
- {
- return -EFAULT;
- }
+ DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *)data, sizeof(d) );
/* Please don't send us buffers.
*/
@@ -1408,10 +1395,7 @@ int mach64_dma_buffers( struct inode *inode, struct file *filp,
ret = mach64_dma_get_buffers( dev, &d );
}
- if ( copy_to_user( (drm_dma_t *)arg, &d, sizeof(d) ) )
- {
- ret = -EFAULT;
- }
+ DRM_COPY_TO_USER_IOCTL( (drm_dma_t *)data, d, sizeof(d) );
return ret;
}
diff --git a/shared/mach64_drv.h b/shared/mach64_drv.h
index 3a54b940..1e52e5c3 100644
--- a/shared/mach64_drv.h
+++ b/shared/mach64_drv.h
@@ -113,16 +113,11 @@ typedef struct drm_mach64_private {
} drm_mach64_private_t;
/* mach64_dma.c */
-extern int mach64_dma_init( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg );
-extern int mach64_dma_idle( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg );
-extern int mach64_dma_flush( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg );
-extern int mach64_engine_reset( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg );
-extern int mach64_dma_buffers( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg );
+extern int mach64_dma_init( DRM_IOCTL_ARGS );
+extern int mach64_dma_idle( DRM_IOCTL_ARGS );
+extern int mach64_dma_flush( DRM_IOCTL_ARGS );
+extern int mach64_engine_reset( DRM_IOCTL_ARGS );
+extern int mach64_dma_buffers( DRM_IOCTL_ARGS );
extern int mach64_init_freelist( drm_device_t *dev );
extern void mach64_destroy_freelist( drm_device_t *dev );
@@ -143,16 +138,11 @@ extern int mach64_do_dma_flush( drm_mach64_private_t *dev_priv );
extern int mach64_do_cleanup_dma( drm_device_t *dev );
/* mach64_state.c */
-extern int mach64_dma_clear( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg );
-extern int mach64_dma_swap( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg );
-extern int mach64_dma_vertex( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg );
-extern int mach64_dma_blit( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg );
-extern int mach64_get_param( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg );
+extern int mach64_dma_clear( DRM_IOCTL_ARGS );
+extern int mach64_dma_swap( DRM_IOCTL_ARGS );
+extern int mach64_dma_vertex( DRM_IOCTL_ARGS );
+extern int mach64_dma_blit( DRM_IOCTL_ARGS );
+extern int mach64_get_param( DRM_IOCTL_ARGS );
/* ================================================================
* Registers
diff --git a/shared/mach64_state.c b/shared/mach64_state.c
index e75b985e..5c070dd5 100644
--- a/shared/mach64_state.c
+++ b/shared/mach64_state.c
@@ -718,11 +718,9 @@ static int mach64_dma_dispatch_blit( drm_device_t *dev,
* IOCTL functions
*/
-int mach64_dma_clear( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
+int mach64_dma_clear( DRM_IOCTL_ARGS )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ DRM_DEVICE;
drm_mach64_private_t *dev_priv = dev->dev_private;
drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_mach64_clear_t clear;
@@ -732,9 +730,8 @@ int mach64_dma_clear( struct inode *inode, struct file *filp,
LOCK_TEST_WITH_RETURN( dev );
- if ( copy_from_user( &clear, (drm_mach64_clear_t *) arg,
- sizeof(clear) ) )
- return -EFAULT;
+ DRM_COPY_FROM_USER_IOCTL( clear, (drm_mach64_clear_t *)data,
+ sizeof(clear) );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -752,11 +749,9 @@ int mach64_dma_clear( struct inode *inode, struct file *filp,
return ret;
}
-int mach64_dma_swap( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
+int mach64_dma_swap( DRM_IOCTL_ARGS )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ DRM_DEVICE;
drm_mach64_private_t *dev_priv = dev->dev_private;
drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
int ret;
@@ -779,11 +774,9 @@ int mach64_dma_swap( struct inode *inode, struct file *filp,
return ret;
}
-int mach64_dma_vertex( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
+int mach64_dma_vertex( DRM_IOCTL_ARGS )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ DRM_DEVICE;
drm_mach64_private_t *dev_priv = dev->dev_private;
drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_mach64_vertex_t vertex;
@@ -795,9 +788,8 @@ int mach64_dma_vertex( struct inode *inode, struct file *filp,
return -EINVAL;
}
- if ( copy_from_user( &vertex, (drm_mach64_vertex_t *)arg,
- sizeof(vertex) ) )
- return -EFAULT;
+ DRM_COPY_FROM_USER_IOCTL( vertex, (drm_mach64_vertex_t *)data,
+ sizeof(vertex) );
DRM_DEBUG( "%s: pid=%d buf=%p used=%lu discard=%d\n",
__FUNCTION__, current->pid,
@@ -823,11 +815,9 @@ int mach64_dma_vertex( struct inode *inode, struct file *filp,
vertex.used, vertex.discard );
}
-int mach64_dma_blit( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
+int mach64_dma_blit( DRM_IOCTL_ARGS )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
drm_mach64_private_t *dev_priv = dev->dev_private;
drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
@@ -836,9 +826,8 @@ int mach64_dma_blit( struct inode *inode, struct file *filp,
LOCK_TEST_WITH_RETURN( dev );
- if ( copy_from_user( &blit, (drm_mach64_blit_t *)arg,
- sizeof(blit) ) )
- return -EFAULT;
+ DRM_COPY_FROM_USER_IOCTL( blit, (drm_mach64_blit_t *)data,
+ sizeof(blit) );
DRM_DEBUG( "%s: pid=%d index=%d\n",
__FUNCTION__, current->pid, blit.idx );
@@ -862,11 +851,9 @@ int mach64_dma_blit( struct inode *inode, struct file *filp,
return ret;
}
-int mach64_get_param( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
+int mach64_get_param( DRM_IOCTL_ARGS )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
+ DRM_DEVICE;
drm_mach64_private_t *dev_priv = dev->dev_private;
drm_mach64_getparam_t param;
int value;
@@ -875,9 +862,8 @@ int mach64_get_param( struct inode *inode, struct file *filp,
LOCK_TEST_WITH_RETURN( dev );
- if ( copy_from_user( &param, (drm_mach64_getparam_t *)arg,
- sizeof(param) ) )
- return -EFAULT;
+ DRM_COPY_FROM_USER_IOCTL( param, (drm_mach64_getparam_t *)data,
+ sizeof(param) );
switch ( param.param ) {
case MACH64_PARAM_FRAMES_QUEUED: