summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2008-09-29 22:48:25 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2008-09-29 22:48:25 +0000
commit44983511ebf223837fdc281cd6b1685671c562d1 (patch)
tree2a99548e29f6e512e8d3cefaafba6aeb20524902 /sys/dev/pci
parent23072936ecea224e6d49c2134f7820b6cfd28f93 (diff)
Fix mmap to always return the right value in the error path. While i'm
here rework it a little bit to remove a shadowed variable.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/drm/drm_vm.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/sys/dev/pci/drm/drm_vm.c b/sys/dev/pci/drm/drm_vm.c
index 19e903910cc..f9d3d13da7c 100644
--- a/sys/dev/pci/drm/drm_vm.c
+++ b/sys/dev/pci/drm/drm_vm.c
@@ -35,18 +35,17 @@ drmmmap(dev_t kdev, off_t offset, int prot)
drm_local_map_t *map;
struct drm_file *priv;
enum drm_map_type type;
- paddr_t phys;
DRM_LOCK();
priv = drm_find_file_by_minor(dev, minor(kdev));
DRM_UNLOCK();
if (priv == NULL) {
DRM_ERROR("can't find authenticator\n");
- return (EINVAL);
+ return (-1);
}
if (!priv->authenticated)
- return (EACCES);
+ return (-1);
if (dev->dma && offset >= 0 && offset < ptoa(dev->dma->page_count)) {
drm_device_dma_t *dma = dev->dma;
@@ -54,8 +53,7 @@ drmmmap(dev_t kdev, off_t offset, int prot)
DRM_SPINLOCK(&dev->dma_lock);
if (dma->pagelist != NULL) {
- unsigned long page = offset >> PAGE_SHIFT;
- unsigned long phys = dma->pagelist[page];
+ paddr_t phys = dma->pagelist[offset >> PAGE_SHIFT];
DRM_SPINUNLOCK(&dev->dma_lock);
return (atop(phys));
@@ -100,7 +98,7 @@ drmmmap(dev_t kdev, off_t offset, int prot)
case _DRM_FRAME_BUFFER:
case _DRM_REGISTERS:
case _DRM_AGP:
- phys = offset + map->offset;
+ return (atop(offset + map->offset));
break;
/* XXX unify all the bus_dmamem_mmap bits */
case _DRM_SCATTER_GATHER:
@@ -115,7 +113,6 @@ drmmmap(dev_t kdev, off_t offset, int prot)
DRM_ERROR("bad map type %d\n", type);
return (-1); /* This should never happen. */
}
-
- return (atop(phys));
+ /* NOTREACHED */
}