Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / drm_fops.c
index ed45ee628e3bd1740adb96d894831b68b4fefea0..79d5221c6e41c9880b5620623c9653799c1044ed 100644 (file)
@@ -194,6 +194,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
                        goto out_close;
                }
 
+               priv->is_master = 1;
                /* take another reference for the copy in the local file priv */
                priv->master = drm_master_get(priv->minor->master);
                priv->authenticated = 1;
@@ -385,6 +386,10 @@ int drm_release(struct inode *inode, struct file *filp)
 
        DRM_DEBUG("open_count = %d\n", dev->open_count);
 
+       mutex_lock(&dev->struct_mutex);
+       list_del(&file_priv->lhead);
+       mutex_unlock(&dev->struct_mutex);
+
        if (dev->driver->preclose)
                dev->driver->preclose(dev, file_priv);
 
@@ -421,7 +426,7 @@ int drm_release(struct inode *inode, struct file *filp)
 
        mutex_lock(&dev->master_mutex);
 
-       if (drm_is_master(file_priv)) {
+       if (file_priv->is_master) {
                struct drm_master *master = file_priv->master;
 
                /**
@@ -449,12 +454,9 @@ int drm_release(struct inode *inode, struct file *filp)
        /* drop the master reference held by the file priv */
        if (file_priv->master)
                drm_master_put(&file_priv->master);
+       file_priv->is_master = 0;
        mutex_unlock(&dev->master_mutex);
 
-       mutex_lock(&dev->struct_mutex);
-       list_del(&file_priv->lhead);
-       mutex_unlock(&dev->struct_mutex);
-
        if (dev->driver->postclose)
                dev->driver->postclose(dev, file_priv);