summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux/mach64_drv.h17
-rw-r--r--linux/mach64_state.c12
2 files changed, 19 insertions, 10 deletions
diff --git a/linux/mach64_drv.h b/linux/mach64_drv.h
index af6855ab..099e8ea4 100644
--- a/linux/mach64_drv.h
+++ b/linux/mach64_drv.h
@@ -377,6 +377,23 @@ extern int mach64_dma_swap( struct inode *inode, struct file *filp,
#define MMSELECT1(r) (((((r) & 0xff) << 2) + DWMREG1))
#define MMSELECT(r) (ISMMREG0(r) ? MMSELECT0(r) : MMSELECT1(r))
+/* ================================================================
+ * Misc helper macros
+ */
+
+#define LOCK_TEST_WITH_RETURN( dev ) \
+do { \
+ if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
+ dev->lock.pid != current->pid ) { \
+ DRM_ERROR( "%s called without lock held\n", \
+ __FUNCTION__ ); \
+ return -EINVAL; \
+ } \
+} while (0)
+
+/* ================================================================
+ * DMA macros
+ */
#define DMA_FRAME_BUF_OFFSET 0
#define DMA_SYS_MEM_ADDR 1
diff --git a/linux/mach64_state.c b/linux/mach64_state.c
index 1a0ccb32..08bd082a 100644
--- a/linux/mach64_state.c
+++ b/linux/mach64_state.c
@@ -298,11 +298,7 @@ int mach64_dma_clear( struct inode *inode, struct file *filp,
drm_mach64_clear_t clear;
DRM_DEBUG( "%s\n", __FUNCTION__ );
- if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) ||
- dev->lock.pid != current->pid ) {
- DRM_ERROR( "mach64_cce_clear called without lock held\n" );
- return -EINVAL;
- }
+ LOCK_TEST_WITH_RETURN( dev );
if ( copy_from_user( &clear, (drm_mach64_clear_t *) arg,
sizeof(clear) ) )
@@ -331,11 +327,7 @@ int mach64_dma_swap( struct inode *inode, struct file *filp,
drm_mach64_sarea_t *sarea_priv = dev_priv->sarea_priv;
DRM_DEBUG( "%s\n", __FUNCTION__ );
- if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) ||
- dev->lock.pid != current->pid ) {
- DRM_ERROR( "mach64_cce_swap called without lock held\n" );
- return -EINVAL;
- }
+ LOCK_TEST_WITH_RETURN( dev );
if ( sarea_priv->nbox > MACH64_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = MACH64_NR_SAREA_CLIPRECTS;