diff options
author | Eric Anholt <anholt@freebsd.org> | 2005-08-04 07:42:01 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2005-08-04 07:42:01 +0000 |
commit | b0da5df90a76e4e79c356fdbc90211a8e21f095c (patch) | |
tree | 8653e6b94291441a6b101a705fad88e4d11ec0ca /shared-core | |
parent | 49bbb6d86178890a03040d618a8c9c76c96d3d3f (diff) |
Fix the MGA driver on BSD by passing in the proper chipset flags to the
driver's preinit routine, and by using DRM_COPY_TO_USER_IOCTL when
copying out to an ioctl's data pointer. Pulled from the latest version
of my drm-hook-rename.diff and only compile-tested after that.
Diffstat (limited to 'shared-core')
-rw-r--r-- | shared-core/mga_dma.c | 38 | ||||
-rw-r--r-- | shared-core/mga_state.c | 10 |
2 files changed, 20 insertions, 28 deletions
diff --git a/shared-core/mga_dma.c b/shared-core/mga_dma.c index cb2b2561..70a1f1b3 100644 --- a/shared-core/mga_dma.c +++ b/shared-core/mga_dma.c @@ -723,6 +723,9 @@ int mga_dma_bootstrap(DRM_IOCTL_ARGS) DRM_DEVICE; drm_mga_dma_bootstrap_t bootstrap; int err; + static const int modes[] = { 0, 1, 2, 2, 4, 4, 4, 4 }; + const drm_mga_private_t * const dev_priv = + (drm_mga_private_t *) dev->dev_private; DRM_COPY_FROM_USER_IOCTL(bootstrap, @@ -730,31 +733,26 @@ int mga_dma_bootstrap(DRM_IOCTL_ARGS) sizeof(bootstrap)); err = mga_do_dma_bootstrap(dev, & bootstrap); - if (! err) { - static const int modes[] = { 0, 1, 2, 2, 4, 4, 4, 4 }; - const drm_mga_private_t * const dev_priv = - (drm_mga_private_t *) dev->dev_private; - - if (dev_priv->agp_textures != NULL) { - bootstrap.texture_handle = dev_priv->agp_textures->offset; - bootstrap.texture_size = dev_priv->agp_textures->size; - } - else { - bootstrap.texture_handle = 0; - bootstrap.texture_size = 0; - } + if (err) { + mga_do_cleanup_dma(dev); + return err; + } - bootstrap.agp_mode = modes[ bootstrap.agp_mode & 0x07 ]; - if (DRM_COPY_TO_USER( (void __user *) data, & bootstrap, - sizeof(bootstrap))) { - err = DRM_ERR(EFAULT); - } + if (dev_priv->agp_textures != NULL) { + bootstrap.texture_handle = dev_priv->agp_textures->offset; + bootstrap.texture_size = dev_priv->agp_textures->size; } else { - mga_do_cleanup_dma(dev); + bootstrap.texture_handle = 0; + bootstrap.texture_size = 0; } - return err; + bootstrap.agp_mode = modes[bootstrap.agp_mode & 0x07]; + + DRM_COPY_TO_USER_IOCTL((drm_mga_dma_bootstrap_t __user *)data, + bootstrap, sizeof(bootstrap)); + + return 0; } diff --git a/shared-core/mga_state.c b/shared-core/mga_state.c index 273854cd..704a67cb 100644 --- a/shared-core/mga_state.c +++ b/shared-core/mga_state.c @@ -1130,10 +1130,7 @@ static int mga_set_fence(DRM_IOCTL_ARGS) MGA_SOFTRAP, 0x00000000); ADVANCE_DMA(); - if (DRM_COPY_TO_USER( (u32 __user *) data, & temp, sizeof(u32))) { - DRM_ERROR("copy_to_user\n"); - return DRM_ERR(EFAULT); - } + DRM_COPY_TO_USER_IOCTL((u32 __user *)data, temp, sizeof(u32)); return 0; } @@ -1155,10 +1152,7 @@ static int mga_wait_fence(DRM_IOCTL_ARGS) mga_driver_fence_wait(dev, & fence); - if (DRM_COPY_TO_USER( (u32 __user *) data, & fence, sizeof(u32))) { - DRM_ERROR("copy_to_user\n"); - return DRM_ERR(EFAULT); - } + DRM_COPY_TO_USER_IOCTL((u32 __user *)data, fence, sizeof(u32)); return 0; } |