Logo Search packages:      
Sourcecode: linux version File versions  Download package

static int drm_open_helper ( struct inode *  inode,
struct file *  filp,
struct drm_device *  dev 
) [static]

Called whenever a process opens /dev/drm.

Parameters:
inode device inode.
filp file pointer.
dev device.
Returns:
zero on success or a negative number on failure.
Creates and initializes a drm_file structure for the file private data in filp and add it into the double linked list in dev.

Definition at line 225 of file drm_fops.c.

References drm_cpu_valid().

Referenced by drm_open().

{
      int minor = iminor(inode);
      struct drm_file *priv;
      int ret;

      if (filp->f_flags & O_EXCL)
            return -EBUSY;    /* No exclusive opens */
      if (!drm_cpu_valid())
            return -EINVAL;

      DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor);

      priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES);
      if (!priv)
            return -ENOMEM;

      memset(priv, 0, sizeof(*priv));
      filp->private_data = priv;
      priv->filp = filp;
      priv->uid = current->euid;
      priv->pid = task_pid_nr(current);
      priv->minor = minor;
      priv->head = drm_heads[minor];
      priv->ioctl_count = 0;
      /* for compatibility root is always authenticated */
      priv->authenticated = capable(CAP_SYS_ADMIN);
      priv->lock_count = 0;

      INIT_LIST_HEAD(&priv->lhead);

      if (dev->driver->open) {
            ret = dev->driver->open(dev, priv);
            if (ret < 0)
                  goto out_free;
      }

      mutex_lock(&dev->struct_mutex);
      if (list_empty(&dev->filelist))
            priv->master = 1;

      list_add(&priv->lhead, &dev->filelist);
      mutex_unlock(&dev->struct_mutex);

#ifdef __alpha__
      /*
       * Default the hose
       */
      if (!dev->hose) {
            struct pci_dev *pci_dev;
            pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
            if (pci_dev) {
                  dev->hose = pci_dev->sysdata;
                  pci_dev_put(pci_dev);
            }
            if (!dev->hose) {
                  struct pci_bus *b = pci_bus_b(pci_root_buses.next);
                  if (b)
                        dev->hose = b->sysdata;
            }
      }
#endif

      return 0;
      out_free:
      drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
      filp->private_data = NULL;
      return ret;
}


Generated by  Doxygen 1.6.0   Back to index