mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
drm: add core support for unplugging a device (v2)
Two parts to this, one is simple unplug from sysfs for the device node. The second adds an unplugged state, if we have device opens, we just set the unplugged state and return, if we have no device opens we drop the drm device. If after a lastclose we discover we are unplugged we then drop the drm device. v2: use an atomic for unplugged and wrap it for users, add checks on open + mmap + ioctl entry points. Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
@@ -133,6 +133,9 @@ int drm_open(struct inode *inode, struct file *filp)
|
||||
if (!(dev = minor->dev))
|
||||
return -ENODEV;
|
||||
|
||||
if (drm_device_is_unplugged(dev))
|
||||
return -ENODEV;
|
||||
|
||||
retcode = drm_open_helper(inode, filp, dev);
|
||||
if (!retcode) {
|
||||
atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
|
||||
@@ -181,6 +184,9 @@ int drm_stub_open(struct inode *inode, struct file *filp)
|
||||
if (!(dev = minor->dev))
|
||||
goto out;
|
||||
|
||||
if (drm_device_is_unplugged(dev))
|
||||
goto out;
|
||||
|
||||
old_fops = filp->f_op;
|
||||
filp->f_op = fops_get(dev->driver->fops);
|
||||
if (filp->f_op == NULL) {
|
||||
@@ -579,6 +585,8 @@ int drm_release(struct inode *inode, struct file *filp)
|
||||
retcode = -EBUSY;
|
||||
} else
|
||||
retcode = drm_lastclose(dev);
|
||||
if (drm_device_is_unplugged(dev))
|
||||
drm_put_dev(dev);
|
||||
}
|
||||
mutex_unlock(&drm_global_mutex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user