aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_fops.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_fops.c')
-rw-r--r--drivers/gpu/drm/drm_fops.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 3f84277d7036..22d14ecbd3ec 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -148,7 +148,7 @@ int drm_stub_open(struct inode *inode, struct file *filp)
148 struct drm_minor *minor; 148 struct drm_minor *minor;
149 int minor_id = iminor(inode); 149 int minor_id = iminor(inode);
150 int err = -ENODEV; 150 int err = -ENODEV;
151 const struct file_operations *old_fops; 151 const struct file_operations *new_fops;
152 152
153 DRM_DEBUG("\n"); 153 DRM_DEBUG("\n");
154 154
@@ -163,18 +163,13 @@ int drm_stub_open(struct inode *inode, struct file *filp)
163 if (drm_device_is_unplugged(dev)) 163 if (drm_device_is_unplugged(dev))
164 goto out; 164 goto out;
165 165
166 old_fops = filp->f_op; 166 new_fops = fops_get(dev->driver->fops);
167 filp->f_op = fops_get(dev->driver->fops); 167 if (!new_fops)
168 if (filp->f_op == NULL) {
169 filp->f_op = old_fops;
170 goto out; 168 goto out;
171 }
172 if (filp->f_op->open && (err = filp->f_op->open(inode, filp))) {
173 fops_put(filp->f_op);
174 filp->f_op = fops_get(old_fops);
175 }
176 fops_put(old_fops);
177 169
170 replace_fops(filp, new_fops);
171 if (filp->f_op->open)
172 err = filp->f_op->open(inode, filp);
178out: 173out:
179 mutex_unlock(&drm_global_mutex); 174 mutex_unlock(&drm_global_mutex);
180 return err; 175 return err;