diff options
Diffstat (limited to 'linux-core/drm_auth.c')
-rw-r--r-- | linux-core/drm_auth.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/linux-core/drm_auth.c b/linux-core/drm_auth.c index 20c8a634..c904a91d 100644 --- a/linux-core/drm_auth.c +++ b/linux-core/drm_auth.c | |||
@@ -45,15 +45,14 @@ | |||
45 | * the one with matching magic number, while holding the drm_device::struct_mutex | 45 | * the one with matching magic number, while holding the drm_device::struct_mutex |
46 | * lock. | 46 | * lock. |
47 | */ | 47 | */ |
48 | static struct drm_file *drm_find_file(struct drm_master *master , drm_magic_t magic) | 48 | static struct drm_file *drm_find_file(struct drm_device * dev, drm_magic_t magic) |
49 | { | 49 | { |
50 | struct drm_file *retval = NULL; | 50 | struct drm_file *retval = NULL; |
51 | struct drm_magic_entry *pt; | 51 | struct drm_magic_entry *pt; |
52 | struct drm_hash_item *hash; | 52 | struct drm_hash_item *hash; |
53 | struct drm_device *dev = master->minor->dev; | ||
54 | 53 | ||
55 | mutex_lock(&dev->struct_mutex); | 54 | mutex_lock(&dev->struct_mutex); |
56 | if (!drm_ht_find_item(&master->magiclist, (unsigned long)magic, &hash)) { | 55 | if (!drm_ht_find_item(&dev->magiclist, (unsigned long)magic, &hash)) { |
57 | pt = drm_hash_entry(hash, struct drm_magic_entry, hash_item); | 56 | pt = drm_hash_entry(hash, struct drm_magic_entry, hash_item); |
58 | retval = pt->priv; | 57 | retval = pt->priv; |
59 | } | 58 | } |
@@ -72,11 +71,11 @@ static struct drm_file *drm_find_file(struct drm_master *master , drm_magic_t ma | |||
72 | * associated the magic number hash key in drm_device::magiclist, while holding | 71 | * associated the magic number hash key in drm_device::magiclist, while holding |
73 | * the drm_device::struct_mutex lock. | 72 | * the drm_device::struct_mutex lock. |
74 | */ | 73 | */ |
75 | static int drm_add_magic(struct drm_master *master, struct drm_file * priv, | 74 | static int drm_add_magic(struct drm_device * dev, struct drm_file * priv, |
76 | drm_magic_t magic) | 75 | drm_magic_t magic) |
77 | { | 76 | { |
78 | struct drm_magic_entry *entry; | 77 | struct drm_magic_entry *entry; |
79 | struct drm_device *dev = master->minor->dev; | 78 | |
80 | DRM_DEBUG("%d\n", magic); | 79 | DRM_DEBUG("%d\n", magic); |
81 | 80 | ||
82 | entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC); | 81 | entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC); |
@@ -86,8 +85,8 @@ static int drm_add_magic(struct drm_master *master, struct drm_file * priv, | |||
86 | entry->priv = priv; | 85 | entry->priv = priv; |
87 | entry->hash_item.key = (unsigned long)magic; | 86 | entry->hash_item.key = (unsigned long)magic; |
88 | mutex_lock(&dev->struct_mutex); | 87 | mutex_lock(&dev->struct_mutex); |
89 | drm_ht_insert_item(&master->magiclist, &entry->hash_item); | 88 | drm_ht_insert_item(&dev->magiclist, &entry->hash_item); |
90 | list_add_tail(&entry->head, &master->magicfree); | 89 | list_add_tail(&entry->head, &dev->magicfree); |
91 | mutex_unlock(&dev->struct_mutex); | 90 | mutex_unlock(&dev->struct_mutex); |
92 | 91 | ||
93 | return 0; | 92 | return 0; |
@@ -102,21 +101,20 @@ static int drm_add_magic(struct drm_master *master, struct drm_file * priv, | |||
102 | * Searches and unlinks the entry in drm_device::magiclist with the magic | 101 | * Searches and unlinks the entry in drm_device::magiclist with the magic |
103 | * number hash key, while holding the drm_device::struct_mutex lock. | 102 | * number hash key, while holding the drm_device::struct_mutex lock. |
104 | */ | 103 | */ |
105 | static int drm_remove_magic(struct drm_master *master, drm_magic_t magic) | 104 | static int drm_remove_magic(struct drm_device * dev, drm_magic_t magic) |
106 | { | 105 | { |
107 | struct drm_magic_entry *pt; | 106 | struct drm_magic_entry *pt; |
108 | struct drm_hash_item *hash; | 107 | struct drm_hash_item *hash; |
109 | struct drm_device *dev = master->minor->dev; | ||
110 | 108 | ||
111 | DRM_DEBUG("%d\n", magic); | 109 | DRM_DEBUG("%d\n", magic); |
112 | 110 | ||
113 | mutex_lock(&dev->struct_mutex); | 111 | mutex_lock(&dev->struct_mutex); |
114 | if (drm_ht_find_item(&master->magiclist, (unsigned long)magic, &hash)) { | 112 | if (drm_ht_find_item(&dev->magiclist, (unsigned long)magic, &hash)) { |
115 | mutex_unlock(&dev->struct_mutex); | 113 | mutex_unlock(&dev->struct_mutex); |
116 | return -EINVAL; | 114 | return -EINVAL; |
117 | } | 115 | } |
118 | pt = drm_hash_entry(hash, struct drm_magic_entry, hash_item); | 116 | pt = drm_hash_entry(hash, struct drm_magic_entry, hash_item); |
119 | drm_ht_remove_item(&master->magiclist, hash); | 117 | drm_ht_remove_item(&dev->magiclist, hash); |
120 | list_del(&pt->head); | 118 | list_del(&pt->head); |
121 | mutex_unlock(&dev->struct_mutex); | 119 | mutex_unlock(&dev->struct_mutex); |
122 | 120 | ||
@@ -154,9 +152,9 @@ int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
154 | ++sequence; /* reserve 0 */ | 152 | ++sequence; /* reserve 0 */ |
155 | auth->magic = sequence++; | 153 | auth->magic = sequence++; |
156 | spin_unlock(&lock); | 154 | spin_unlock(&lock); |
157 | } while (drm_find_file(file_priv->master, auth->magic)); | 155 | } while (drm_find_file(dev, auth->magic)); |
158 | file_priv->magic = auth->magic; | 156 | file_priv->magic = auth->magic; |
159 | drm_add_magic(file_priv->master, file_priv, auth->magic); | 157 | drm_add_magic(dev, file_priv, auth->magic); |
160 | } | 158 | } |
161 | 159 | ||
162 | DRM_DEBUG("%u\n", auth->magic); | 160 | DRM_DEBUG("%u\n", auth->magic); |
@@ -182,9 +180,9 @@ int drm_authmagic(struct drm_device *dev, void *data, | |||
182 | struct drm_file *file; | 180 | struct drm_file *file; |
183 | 181 | ||
184 | DRM_DEBUG("%u\n", auth->magic); | 182 | DRM_DEBUG("%u\n", auth->magic); |
185 | if ((file = drm_find_file(file_priv->master, auth->magic))) { | 183 | if ((file = drm_find_file(dev, auth->magic))) { |
186 | file->authenticated = 1; | 184 | file->authenticated = 1; |
187 | drm_remove_magic(file_priv->master, auth->magic); | 185 | drm_remove_magic(dev, auth->magic); |
188 | return 0; | 186 | return 0; |
189 | } | 187 | } |
190 | return -EINVAL; | 188 | return -EINVAL; |