From 1587b7fc8724cc5f724b2a4a74abc8208e60ac4b Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Fri, 30 Oct 2009 16:12:28 +0000 Subject: [PATCH] MFC r196465 Clean up the handling of device minors --- sys/dev/drm/drmP.h | 1 - sys/dev/drm/drm_drv.c | 8 +++----- sys/dev/drm/drm_fops.c | 4 +--- sys/dev/drm/drm_sysctl.c | 7 ++++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sys/dev/drm/drmP.h b/sys/dev/drm/drmP.h index e630f861d576..9c5f4a470c6e 100644 --- a/sys/dev/drm/drmP.h +++ b/sys/dev/drm/drmP.h @@ -416,7 +416,6 @@ struct drm_file { struct drm_device *dev; int authenticated; int master; - int minor; pid_t pid; uid_t uid; drm_magic_t magic; diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c index 561afd5e8fb9..1fb8342d5671 100644 --- a/sys/dev/drm/drm_drv.c +++ b/sys/dev/drm/drm_drv.c @@ -53,9 +53,6 @@ static void drm_unload(struct drm_device *dev); static drm_pci_id_list_t *drm_find_description(int vendor, int device, drm_pci_id_list_t *idlist); -#define DRIVER_SOFTC(unit) \ - ((struct drm_device *)devclass_get_softc(drm_devclass, unit)) - MODULE_VERSION(drm, 1); MODULE_DEPEND(drm, agp, 1, 1, 1); MODULE_DEPEND(drm, pci, 1, 1, 1); @@ -210,11 +207,12 @@ int drm_attach(device_t kdev, drm_pci_id_list_t *idlist) dev->device = kdev; #endif dev->devnode = make_dev(&drm_cdevsw, - unit, + 0, DRM_DEV_UID, DRM_DEV_GID, DRM_DEV_MODE, "dri/card%d", unit); + dev->devnode->si_drv1 = dev; #if __FreeBSD_version >= 700053 dev->pci_domain = pci_get_domain(dev->device); @@ -606,7 +604,7 @@ int drm_open(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p) struct drm_device *dev = NULL; int retcode = 0; - dev = DRIVER_SOFTC(dev2unit(kdev)); + dev = kdev->si_drv1; DRM_DEBUG("open_count = %d\n", dev->open_count); diff --git a/sys/dev/drm/drm_fops.c b/sys/dev/drm/drm_fops.c index f766928d6515..3f743e04ca90 100644 --- a/sys/dev/drm/drm_fops.c +++ b/sys/dev/drm/drm_fops.c @@ -44,14 +44,13 @@ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, struct drm_device *dev) { struct drm_file *priv; - int m = dev2unit(kdev); int retcode; if (flags & O_EXCL) return EBUSY; /* No exclusive opens */ dev->flags = flags; - DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m); + DRM_DEBUG("pid = %d, device = %s\n", DRM_CURRENTPID, devtoname(kdev)); priv = malloc(sizeof(*priv), DRM_MEM_FILES, M_NOWAIT | M_ZERO); if (priv == NULL) { @@ -68,7 +67,6 @@ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, 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 */ diff --git a/sys/dev/drm/drm_sysctl.c b/sys/dev/drm/drm_sysctl.c index 0d59d485a99e..cc332833fd6d 100644 --- a/sys/dev/drm/drm_sysctl.c +++ b/sys/dev/drm/drm_sysctl.c @@ -298,12 +298,13 @@ static int drm_clients_info DRM_SYSCTL_HANDLER_ARGS DRM_UNLOCK(); - DRM_SYSCTL_PRINT("\na dev pid uid magic ioctls\n"); + DRM_SYSCTL_PRINT( + "\na dev pid uid magic ioctls\n"); for (i = 0; i < privcount; i++) { priv = &tempprivs[i]; - DRM_SYSCTL_PRINT("%c %3d %5d %5d %10u %10lu\n", + DRM_SYSCTL_PRINT("%c %-12s %5d %5d %10u %10lu\n", priv->authenticated ? 'y' : 'n', - priv->minor, + devtoname(priv->dev->devnode), priv->pid, priv->uid, priv->magic,