The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/drm/drm_fops.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* drm_fops.h -- File operations for DRM -*- linux-c -*-
    2  * Created: Mon Jan  4 08:58:31 1999 by faith@valinux.com */
    3 /*-
    4  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
    5  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
    6  * All Rights Reserved.
    7  *
    8  * Permission is hereby granted, free of charge, to any person obtaining a
    9  * copy of this software and associated documentation files (the "Software"),
   10  * to deal in the Software without restriction, including without limitation
   11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
   12  * and/or sell copies of the Software, and to permit persons to whom the
   13  * Software is furnished to do so, subject to the following conditions:
   14  *
   15  * The above copyright notice and this permission notice (including the next
   16  * paragraph) shall be included in all copies or substantial portions of the
   17  * Software.
   18  *
   19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   22  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   25  * OTHER DEALINGS IN THE SOFTWARE.
   26  *
   27  * Authors:
   28  *    Rickard E. (Rik) Faith <faith@valinux.com>
   29  *    Daryll Strauss <daryll@valinux.com>
   30  *    Gareth Hughes <gareth@valinux.com>
   31  *
   32  * $FreeBSD$
   33  */
   34 
   35 #include "dev/drm/drmP.h"
   36 
   37 drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p)
   38 {
   39 #if __FreeBSD_version >= 500021
   40         uid_t uid = p->td_ucred->cr_svuid;
   41         pid_t pid = p->td_proc->p_pid;
   42 #else
   43         uid_t uid = p->p_cred->p_svuid;
   44         pid_t pid = p->p_pid;
   45 #endif
   46         drm_file_t *priv;
   47 
   48         DRM_SPINLOCK_ASSERT(&dev->dev_lock);
   49 
   50         TAILQ_FOREACH(priv, &dev->files, link)
   51                 if (priv->pid == pid && priv->uid == uid)
   52                         return priv;
   53         return NULL;
   54 }
   55 
   56 /* DRM(open_helper) is called whenever a process opens /dev/drm. */
   57 int DRM(open_helper)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
   58                     drm_device_t *dev)
   59 {
   60         int          m = minor(kdev);
   61         drm_file_t   *priv;
   62 
   63         if (flags & O_EXCL)
   64                 return EBUSY; /* No exclusive opens */
   65         dev->flags = flags;
   66 
   67         DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m);
   68 
   69         DRM_LOCK();
   70         priv = DRM(find_file_by_proc)(dev, p);
   71         if (priv) {
   72                 priv->refs++;
   73         } else {
   74                 priv = (drm_file_t *) DRM(alloc)(sizeof(*priv), DRM_MEM_FILES);
   75                 if (priv == NULL) {
   76                         DRM_UNLOCK();
   77                         return DRM_ERR(ENOMEM);
   78                 }
   79                 bzero(priv, sizeof(*priv));
   80 #if __FreeBSD_version >= 500000
   81                 priv->uid               = p->td_ucred->cr_svuid;
   82                 priv->pid               = p->td_proc->p_pid;
   83 #else
   84                 priv->uid               = p->p_cred->p_svuid;
   85                 priv->pid               = p->p_pid;
   86 #endif
   87 
   88                 priv->refs              = 1;
   89                 priv->minor             = m;
   90                 priv->devXX             = dev;
   91                 priv->ioctl_count       = 0;
   92                 priv->authenticated     = !DRM_SUSER(p);
   93 
   94                 DRIVER_OPEN_HELPER( priv, dev );
   95 
   96                 TAILQ_INSERT_TAIL(&dev->files, priv, link);
   97         }
   98         DRM_UNLOCK();
   99 #ifdef __FreeBSD__
  100         kdev->si_drv1 = dev;
  101 #endif
  102         return 0;
  103 }
  104 
  105 
  106 /* The DRM(read) and DRM(poll) are stubs to prevent spurious errors
  107  * on older X Servers (4.3.0 and earlier) */
  108 
  109 int DRM(read)(struct cdev *kdev, struct uio *uio, int ioflag)
  110 {
  111         return 0;
  112 }
  113 
  114 int DRM(poll)(struct cdev *kdev, int events, DRM_STRUCTPROC *p)
  115 {
  116         return 0;
  117 }

Cache object: 9596e96c5d4bfec29362e7f8ec389da9


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.