summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm/drm_fops.c
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2008-08-13 20:38:27 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2008-08-13 20:38:27 +0000
commit89b68f105acd0230f440792304a56eabe4796c4e (patch)
treeb849bffc53e70dc56a8a805c5f53aabd0fdd73e4 /sys/dev/pci/drm/drm_fops.c
parentb836f59f2bb98f50cbe6fcaf1ece40f5959a37b8 (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/drm_fops.c')
-rw-r--r--sys/dev/pci/drm/drm_fops.c67
1 files changed, 30 insertions, 37 deletions
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);
}