Remove the ioctl_count variable from the device. A reference is held to the

fp throughout the ioctl syscall, so the device can't be closed out from
    under us.
This commit is contained in:
Eric Anholt 2003-04-24 05:14:05 +00:00
parent bcd527ee71
commit af3bfdef26
4 changed files with 0 additions and 32 deletions

View file

@ -352,7 +352,6 @@ struct drm_device {
struct lock dev_lock; /* For others */
/* Usage Counters */
int open_count; /* Outstanding files open */
atomic_t ioctl_count; /* Outstanding IOCTLs pending */
int buf_use; /* Buffers in use -- cannot alloc */
atomic_t buf_alloc; /* Buffer allocation in progress */

View file

@ -424,7 +424,6 @@ static int DRM(setup)( drm_device_t *dev )
int i;
DRIVER_PRESETUP();
atomic_set( &dev->ioctl_count, 0 );
dev->buf_use = 0;
atomic_set( &dev->buf_alloc, 0 );
@ -1001,12 +1000,6 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p)
device_unbusy(dev->device);
#endif
if ( !--dev->open_count ) {
if (atomic_read(&dev->ioctl_count)) {
DRM_ERROR("Device busy: %ld\n",
(unsigned long)atomic_read( &dev->ioctl_count ));
DRM_SPINUNLOCK( &dev->count_lock );
return DRM_ERR(EBUSY);
}
DRM_SPINUNLOCK( &dev->count_lock );
return DRM(takedown)( dev );
}
@ -1027,7 +1020,6 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags,
int nr = DRM_IOCTL_NR(cmd);
DRM_PRIV;
atomic_inc( &dev->ioctl_count );
atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
++priv->ioctl_count;
@ -1041,21 +1033,17 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags,
switch (cmd) {
case FIONBIO:
atomic_dec(&dev->ioctl_count);
return 0;
case FIOASYNC:
atomic_dec(&dev->ioctl_count);
dev->flags |= FASYNC;
return 0;
#ifdef __FreeBSD__
case FIOSETOWN:
atomic_dec(&dev->ioctl_count);
return fsetown(*(int *)data, &dev->buf_sigio);
case FIOGETOWN:
atomic_dec(&dev->ioctl_count);
#if (__FreeBSD_version >= 500000)
*(int *) data = fgetown(&dev->buf_sigio);
#else
@ -1065,12 +1053,10 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags,
#endif /* __FreeBSD__ */
#ifdef __NetBSD__
case TIOCSPGRP:
atomic_dec(&dev->ioctl_count);
dev->buf_pgid = *(int *)data;
return 0;
case TIOCGPGRP:
atomic_dec(&dev->ioctl_count);
*(int *)data = dev->buf_pgid;
return 0;
#endif /* __NetBSD__ */
@ -1093,7 +1079,6 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags,
}
}
atomic_dec( &dev->ioctl_count );
return DRM_ERR(retcode);
}

View file

@ -352,7 +352,6 @@ struct drm_device {
struct lock dev_lock; /* For others */
/* Usage Counters */
int open_count; /* Outstanding files open */
atomic_t ioctl_count; /* Outstanding IOCTLs pending */
int buf_use; /* Buffers in use -- cannot alloc */
atomic_t buf_alloc; /* Buffer allocation in progress */

View file

@ -424,7 +424,6 @@ static int DRM(setup)( drm_device_t *dev )
int i;
DRIVER_PRESETUP();
atomic_set( &dev->ioctl_count, 0 );
dev->buf_use = 0;
atomic_set( &dev->buf_alloc, 0 );
@ -1001,12 +1000,6 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p)
device_unbusy(dev->device);
#endif
if ( !--dev->open_count ) {
if (atomic_read(&dev->ioctl_count)) {
DRM_ERROR("Device busy: %ld\n",
(unsigned long)atomic_read( &dev->ioctl_count ));
DRM_SPINUNLOCK( &dev->count_lock );
return DRM_ERR(EBUSY);
}
DRM_SPINUNLOCK( &dev->count_lock );
return DRM(takedown)( dev );
}
@ -1027,7 +1020,6 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags,
int nr = DRM_IOCTL_NR(cmd);
DRM_PRIV;
atomic_inc( &dev->ioctl_count );
atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
++priv->ioctl_count;
@ -1041,21 +1033,17 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags,
switch (cmd) {
case FIONBIO:
atomic_dec(&dev->ioctl_count);
return 0;
case FIOASYNC:
atomic_dec(&dev->ioctl_count);
dev->flags |= FASYNC;
return 0;
#ifdef __FreeBSD__
case FIOSETOWN:
atomic_dec(&dev->ioctl_count);
return fsetown(*(int *)data, &dev->buf_sigio);
case FIOGETOWN:
atomic_dec(&dev->ioctl_count);
#if (__FreeBSD_version >= 500000)
*(int *) data = fgetown(&dev->buf_sigio);
#else
@ -1065,12 +1053,10 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags,
#endif /* __FreeBSD__ */
#ifdef __NetBSD__
case TIOCSPGRP:
atomic_dec(&dev->ioctl_count);
dev->buf_pgid = *(int *)data;
return 0;
case TIOCGPGRP:
atomic_dec(&dev->ioctl_count);
*(int *)data = dev->buf_pgid;
return 0;
#endif /* __NetBSD__ */
@ -1093,7 +1079,6 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags,
}
}
atomic_dec( &dev->ioctl_count );
return DRM_ERR(retcode);
}