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 {
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 */
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();
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;
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);
goto done;
}
- if (--file_priv->refs != 0)
- goto done;
-
if (dev->driver.preclose != NULL)
dev->driver.preclose(dev, file_priv);
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);
}