diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-08-13 20:38:27 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-08-13 20:38:27 +0000 |
commit | 89b68f105acd0230f440792304a56eabe4796c4e (patch) | |
tree | b849bffc53e70dc56a8a805c5f53aabd0fdd73e4 /sys/dev/pci/drm | |
parent | b836f59f2bb98f50cbe6fcaf1ece40f5959a37b8 (diff) |
Kill file_priv->refs, it is always 1. Also move two things from the
softc into file_priv since otherwise the wrong value could rarely be
used.
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r-- | sys/dev/pci/drm/drmP.h | 25 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_bufs.c | 4 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_drv.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_fops.c | 67 |
4 files changed, 43 insertions, 58 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index 66655d09142..e073634c5be 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -384,16 +384,17 @@ typedef struct drm_buf_entry { typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t; struct drm_file { - TAILQ_ENTRY(drm_file) link; - int authenticated; - int master; - int minor; - pid_t pid; - uid_t uid; - int refs; - drm_magic_t magic; - unsigned long ioctl_count; - void *driver_priv; + TAILQ_ENTRY(drm_file) link; + void *driver_priv; + int authenticated; + unsigned long ioctl_count; + dev_t kdev; + drm_magic_t magic; + int flags; + int master; + int minor; + pid_t pid; + uid_t uid; }; struct drm_lock_data { @@ -610,13 +611,9 @@ struct drm_device { char *unique; /* Unique identifier: e.g., busid */ int unique_len; /* Length of unique field */ - dev_t kdev; /* used by uvm_mmap, this is just a placeholder */ struct vga_pci_softc *vga_softc; int if_version; /* Highest interface version set */ - - int flags; /* Flags to open(2) */ - /* Locks */ DRM_SPINTYPE dma_lock; /* protects dev->dma */ DRM_SPINTYPE irq_lock; /* protects irq condition checks */ diff --git a/sys/dev/pci/drm/drm_bufs.c b/sys/dev/pci/drm/drm_bufs.c index e9973ebef27..fdaa063c67e 100644 --- a/sys/dev/pci/drm/drm_bufs.c +++ b/sys/dev/pci/drm/drm_bufs.c @@ -311,7 +311,7 @@ drm_addmap_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) drm_local_map_t *map; int err; - if (!(dev->flags & (FREAD|FWRITE))) + if (!(file_priv->flags & (FREAD|FWRITE))) return EACCES; /* Require read/write */ DRM_LOCK(); @@ -1089,7 +1089,7 @@ drm_mapbufs(struct drm_device *dev, void *data, struct drm_file *file_priv) drm_buf_map_t *request = data; int i; - if (!vfinddev(dev->kdev, VCHR, &vn)) + if (!vfinddev(file_priv->kdev, VCHR, &vn)) return EINVAL; vms = DRM_CURPROC->p_vmspace; diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c index 9dc2fbc4e18..fff4dfbe004 100644 --- a/sys/dev/pci/drm/drm_drv.c +++ b/sys/dev/pci/drm/drm_drv.c @@ -492,8 +492,6 @@ drmopen(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p) if (dev == NULL) return (ENXIO); - dev->kdev = kdev; /* hack for now */ - DRM_DEBUG( "open_count = %d\n", dev->open_count ); retcode = drm_open_helper(kdev, flags, fmt, p, dev); @@ -528,9 +526,6 @@ drmclose(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p) goto done; } - if (--file_priv->refs != 0) - goto done; - if (dev->driver.preclose != NULL) dev->driver.preclose(dev, file_priv); diff --git a/sys/dev/pci/drm/drm_fops.c b/sys/dev/pci/drm/drm_fops.c index ebe0bd0140f..bc3b2e9b20e 100644 --- a/sys/dev/pci/drm/drm_fops.c +++ b/sys/dev/pci/drm/drm_fops.c @@ -59,53 +59,46 @@ drm_open_helper(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p, m = minor(kdev); if (flags & O_EXCL) - return EBUSY; /* No exclusive opens */ - dev->flags = flags; + return (EBUSY); /* No exclusive opens */ DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m); + priv = drm_calloc(1, sizeof(*priv), DRM_MEM_FILES); + if (priv == NULL) { + return (ENOMEM); + } + priv->uid = DRM_UID(p); + priv->pid = DRM_PID(p); + priv->kdev = kdev; + priv->flags = flags; + priv->minor = m; + + /* for compatibility root is always authenticated */ + priv->authenticated = DRM_SUSER(p); + DRM_LOCK(); - priv = drm_find_file_by_minor(dev, m); - if (priv) { - priv->refs++; - } else { - priv = drm_calloc(1, sizeof(*priv), DRM_MEM_FILES); - if (priv == NULL) { + if (dev->driver.open) { + /* shared code returns -errno */ + retcode = -dev->driver.open(dev, priv); + if (retcode != 0) { DRM_UNLOCK(); - return ENOMEM; - } - priv->uid = DRM_UID(p); - priv->pid = DRM_PID(p); - - priv->refs = 1; - priv->minor = m; - - /* for compatibility root is always authenticated */ - priv->authenticated = DRM_SUSER(p); - - if (dev->driver.open) { - /* shared code returns -errno */ - retcode = -dev->driver.open(dev, priv); - if (retcode != 0) { - drm_free(priv, sizeof(*priv), DRM_MEM_FILES); - DRM_UNLOCK(); - return retcode; - } - } - - /* first opener automatically becomes master if root */ - if (TAILQ_EMPTY(&dev->files) && !DRM_SUSER(p)) { drm_free(priv, sizeof(*priv), DRM_MEM_FILES); - DRM_UNLOCK(); - return (EPERM); + return (retcode); } + } - priv->master = TAILQ_EMPTY(&dev->files); - - TAILQ_INSERT_TAIL(&dev->files, priv, link); + /* first opener automatically becomes master if root */ + if (TAILQ_EMPTY(&dev->files) && !DRM_SUSER(p)) { + DRM_UNLOCK(); + drm_free(priv, sizeof(*priv), DRM_MEM_FILES); + return (EPERM); } + + priv->master = TAILQ_EMPTY(&dev->files); + + TAILQ_INSERT_TAIL(&dev->files, priv, link); DRM_UNLOCK(); - return 0; + return (0); } |