From 2649103bf9c4eb471a10800f4a3161dca6249086 Mon Sep 17 00:00:00 2001 From: vehemens Date: Fri, 29 Aug 2008 13:18:54 -0400 Subject: [FreeBSD] Convert drm_driver to a pointer like linux. Signed-off-by: Robert Noland --- bsd-core/drm_fops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bsd-core/drm_fops.c') diff --git a/bsd-core/drm_fops.c b/bsd-core/drm_fops.c index 062b1d59..248e7937 100644 --- a/bsd-core/drm_fops.c +++ b/bsd-core/drm_fops.c @@ -94,9 +94,9 @@ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, /* for compatibility root is always authenticated */ priv->authenticated = DRM_SUSER(p); - if (dev->driver.open) { + if (dev->driver->open) { /* shared code returns -errno */ - retcode = -dev->driver.open(dev, priv); + retcode = -dev->driver->open(dev, priv); if (retcode != 0) { free(priv, M_DRM); DRM_UNLOCK(); -- cgit v1.2.3 From 973c634eaa54ee4085a72102c690bc643cb2d7a8 Mon Sep 17 00:00:00 2001 From: vehemens Date: Mon, 8 Sep 2008 22:06:09 -0700 Subject: Remove incomplete and obsolete free/net/open code. Signed-off-by: Robert Noland --- bsd-core/drm_fops.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'bsd-core/drm_fops.c') diff --git a/bsd-core/drm_fops.c b/bsd-core/drm_fops.c index 248e7937..a002d259 100644 --- a/bsd-core/drm_fops.c +++ b/bsd-core/drm_fops.c @@ -38,13 +38,8 @@ drm_file_t *drm_find_file_by_proc(struct drm_device *dev, DRM_STRUCTPROC *p) { -#if __FreeBSD_version >= 500021 uid_t uid = p->td_ucred->cr_svuid; pid_t pid = p->td_proc->p_pid; -#else - uid_t uid = p->p_cred->p_svuid; - pid_t pid = p->p_pid; -#endif drm_file_t *priv; DRM_SPINLOCK_ASSERT(&dev->dev_lock); @@ -79,14 +74,8 @@ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, DRM_UNLOCK(); return ENOMEM; } -#if __FreeBSD_version >= 500000 priv->uid = p->td_ucred->cr_svuid; priv->pid = p->td_proc->p_pid; -#else - priv->uid = p->p_cred->p_svuid; - priv->pid = p->p_pid; -#endif - priv->refs = 1; priv->minor = m; priv->ioctl_count = 0; @@ -110,9 +99,7 @@ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, TAILQ_INSERT_TAIL(&dev->files, priv, link); } DRM_UNLOCK(); -#ifdef __FreeBSD__ kdev->si_drv1 = dev; -#endif return 0; } -- cgit v1.2.3 From 8ca06eb492f861dbf049a2e104e4e2a5ba814c13 Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Wed, 17 Sep 2008 23:10:15 -0400 Subject: [FreeBSD] Convert to using cdevpriv for file_priv tracking --- bsd-core/drm_fops.c | 78 +++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 45 deletions(-) (limited to 'bsd-core/drm_fops.c') diff --git a/bsd-core/drm_fops.c b/bsd-core/drm_fops.c index a002d259..6850f489 100644 --- a/bsd-core/drm_fops.c +++ b/bsd-core/drm_fops.c @@ -36,26 +36,12 @@ #include "drmP.h" -drm_file_t *drm_find_file_by_proc(struct drm_device *dev, DRM_STRUCTPROC *p) -{ - uid_t uid = p->td_ucred->cr_svuid; - pid_t pid = p->td_proc->p_pid; - drm_file_t *priv; - - DRM_SPINLOCK_ASSERT(&dev->dev_lock); - - TAILQ_FOREACH(priv, &dev->files, link) - if (priv->pid == pid && priv->uid == uid) - return priv; - return NULL; -} - /* drm_open_helper is called whenever a process opens /dev/drm. */ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, struct drm_device *dev) { - int m = minor(kdev); - drm_file_t *priv; + struct drm_file *priv; + int m = minor(kdev); int retcode; if (flags & O_EXCL) @@ -64,40 +50,42 @@ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m); + priv = malloc(sizeof(*priv), M_DRM, M_NOWAIT | M_ZERO); + if (priv == NULL) { + return ENOMEM; + } + + retcode = devfs_set_cdevpriv(priv, drm_close); + if (retcode != 0) { + free(priv, M_DRM); + return retcode; + } + DRM_LOCK(); - priv = drm_find_file_by_proc(dev, p); - if (priv) { - priv->refs++; - } else { - priv = malloc(sizeof(*priv), M_DRM, M_NOWAIT | M_ZERO); - if (priv == NULL) { + priv->dev = dev; + priv->uid = p->td_ucred->cr_svuid; + priv->pid = p->td_proc->p_pid; + priv->minor = m; + priv->ioctl_count = 0; + + /* 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) { + devfs_clear_cdevpriv(); + free(priv, M_DRM); DRM_UNLOCK(); - return ENOMEM; - } - priv->uid = p->td_ucred->cr_svuid; - priv->pid = p->td_proc->p_pid; - priv->refs = 1; - priv->minor = m; - priv->ioctl_count = 0; - - /* 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) { - free(priv, M_DRM); - DRM_UNLOCK(); - return retcode; - } + return retcode; } + } - /* first opener automatically becomes master */ - priv->master = TAILQ_EMPTY(&dev->files); + /* first opener automatically becomes master */ + priv->master = TAILQ_EMPTY(&dev->files); - TAILQ_INSERT_TAIL(&dev->files, priv, link); - } + TAILQ_INSERT_TAIL(&dev->files, priv, link); DRM_UNLOCK(); kdev->si_drv1 = dev; return 0; -- cgit v1.2.3