summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Teira <mteira@users.sourceforge.net>2001-10-28 20:33:05 +0000
committerManuel Teira <mteira@users.sourceforge.net>2001-10-28 20:33:05 +0000
commit5746763035e485153e8ee77c66d184539f9825eb (patch)
tree454addd71d6a744ae9d3df92a7ade3e2b22e1faa
parent67cae4cf1e60c3af7496af391a1e74fc6c125524 (diff)
Leif's macros from DRM and Manuel fixes for the lockingmach64-0-0-2-branch
-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;