diff options
Diffstat (limited to 'drivers/char/drm/drm_fops.c')
-rw-r--r-- | drivers/char/drm/drm_fops.c | 68 |
1 files changed, 22 insertions, 46 deletions
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c index 3b159cab3bc8..7bc51bac450d 100644 --- a/drivers/char/drm/drm_fops.c +++ b/drivers/char/drm/drm_fops.c | |||
@@ -39,9 +39,9 @@ | |||
39 | #include <linux/poll.h> | 39 | #include <linux/poll.h> |
40 | 40 | ||
41 | static int drm_open_helper(struct inode *inode, struct file *filp, | 41 | static int drm_open_helper(struct inode *inode, struct file *filp, |
42 | drm_device_t * dev); | 42 | struct drm_device * dev); |
43 | 43 | ||
44 | static int drm_setup(drm_device_t * dev) | 44 | static int drm_setup(struct drm_device * dev) |
45 | { | 45 | { |
46 | drm_local_map_t *map; | 46 | drm_local_map_t *map; |
47 | int i; | 47 | int i; |
@@ -79,13 +79,6 @@ static int drm_setup(drm_device_t * dev) | |||
79 | drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER); | 79 | drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER); |
80 | INIT_LIST_HEAD(&dev->magicfree); | 80 | INIT_LIST_HEAD(&dev->magicfree); |
81 | 81 | ||
82 | dev->ctxlist = drm_alloc(sizeof(*dev->ctxlist), DRM_MEM_CTXLIST); | ||
83 | if (dev->ctxlist == NULL) | ||
84 | return -ENOMEM; | ||
85 | memset(dev->ctxlist, 0, sizeof(*dev->ctxlist)); | ||
86 | INIT_LIST_HEAD(&dev->ctxlist->head); | ||
87 | |||
88 | dev->vmalist = NULL; | ||
89 | dev->sigdata.lock = NULL; | 82 | dev->sigdata.lock = NULL; |
90 | init_waitqueue_head(&dev->lock.lock_queue); | 83 | init_waitqueue_head(&dev->lock.lock_queue); |
91 | dev->queue_count = 0; | 84 | dev->queue_count = 0; |
@@ -135,7 +128,7 @@ static int drm_setup(drm_device_t * dev) | |||
135 | */ | 128 | */ |
136 | int drm_open(struct inode *inode, struct file *filp) | 129 | int drm_open(struct inode *inode, struct file *filp) |
137 | { | 130 | { |
138 | drm_device_t *dev = NULL; | 131 | struct drm_device *dev = NULL; |
139 | int minor = iminor(inode); | 132 | int minor = iminor(inode); |
140 | int retcode = 0; | 133 | int retcode = 0; |
141 | 134 | ||
@@ -174,7 +167,7 @@ EXPORT_SYMBOL(drm_open); | |||
174 | */ | 167 | */ |
175 | int drm_stub_open(struct inode *inode, struct file *filp) | 168 | int drm_stub_open(struct inode *inode, struct file *filp) |
176 | { | 169 | { |
177 | drm_device_t *dev = NULL; | 170 | struct drm_device *dev = NULL; |
178 | int minor = iminor(inode); | 171 | int minor = iminor(inode); |
179 | int err = -ENODEV; | 172 | int err = -ENODEV; |
180 | const struct file_operations *old_fops; | 173 | const struct file_operations *old_fops; |
@@ -230,10 +223,10 @@ static int drm_cpu_valid(void) | |||
230 | * filp and add it into the double linked list in \p dev. | 223 | * filp and add it into the double linked list in \p dev. |
231 | */ | 224 | */ |
232 | static int drm_open_helper(struct inode *inode, struct file *filp, | 225 | static int drm_open_helper(struct inode *inode, struct file *filp, |
233 | drm_device_t * dev) | 226 | struct drm_device * dev) |
234 | { | 227 | { |
235 | int minor = iminor(inode); | 228 | int minor = iminor(inode); |
236 | drm_file_t *priv; | 229 | struct drm_file *priv; |
237 | int ret; | 230 | int ret; |
238 | 231 | ||
239 | if (filp->f_flags & O_EXCL) | 232 | if (filp->f_flags & O_EXCL) |
@@ -258,6 +251,8 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
258 | priv->authenticated = capable(CAP_SYS_ADMIN); | 251 | priv->authenticated = capable(CAP_SYS_ADMIN); |
259 | priv->lock_count = 0; | 252 | priv->lock_count = 0; |
260 | 253 | ||
254 | INIT_LIST_HEAD(&priv->lhead); | ||
255 | |||
261 | if (dev->driver->open) { | 256 | if (dev->driver->open) { |
262 | ret = dev->driver->open(dev, priv); | 257 | ret = dev->driver->open(dev, priv); |
263 | if (ret < 0) | 258 | if (ret < 0) |
@@ -265,19 +260,10 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
265 | } | 260 | } |
266 | 261 | ||
267 | mutex_lock(&dev->struct_mutex); | 262 | mutex_lock(&dev->struct_mutex); |
268 | if (!dev->file_last) { | 263 | if (list_empty(&dev->filelist)) |
269 | priv->next = NULL; | ||
270 | priv->prev = NULL; | ||
271 | dev->file_first = priv; | ||
272 | dev->file_last = priv; | ||
273 | /* first opener automatically becomes master */ | ||
274 | priv->master = 1; | 264 | priv->master = 1; |
275 | } else { | 265 | |
276 | priv->next = NULL; | 266 | list_add(&priv->lhead, &dev->filelist); |
277 | priv->prev = dev->file_last; | ||
278 | dev->file_last->next = priv; | ||
279 | dev->file_last = priv; | ||
280 | } | ||
281 | mutex_unlock(&dev->struct_mutex); | 267 | mutex_unlock(&dev->struct_mutex); |
282 | 268 | ||
283 | #ifdef __alpha__ | 269 | #ifdef __alpha__ |
@@ -309,8 +295,8 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
309 | /** No-op. */ | 295 | /** No-op. */ |
310 | int drm_fasync(int fd, struct file *filp, int on) | 296 | int drm_fasync(int fd, struct file *filp, int on) |
311 | { | 297 | { |
312 | drm_file_t *priv = filp->private_data; | 298 | struct drm_file *priv = filp->private_data; |
313 | drm_device_t *dev = priv->head->dev; | 299 | struct drm_device *dev = priv->head->dev; |
314 | int retcode; | 300 | int retcode; |
315 | 301 | ||
316 | DRM_DEBUG("fd = %d, device = 0x%lx\n", fd, | 302 | DRM_DEBUG("fd = %d, device = 0x%lx\n", fd, |
@@ -336,8 +322,8 @@ EXPORT_SYMBOL(drm_fasync); | |||
336 | */ | 322 | */ |
337 | int drm_release(struct inode *inode, struct file *filp) | 323 | int drm_release(struct inode *inode, struct file *filp) |
338 | { | 324 | { |
339 | drm_file_t *priv = filp->private_data; | 325 | struct drm_file *priv = filp->private_data; |
340 | drm_device_t *dev; | 326 | struct drm_device *dev; |
341 | int retcode = 0; | 327 | int retcode = 0; |
342 | 328 | ||
343 | lock_kernel(); | 329 | lock_kernel(); |
@@ -414,10 +400,10 @@ int drm_release(struct inode *inode, struct file *filp) | |||
414 | drm_fasync(-1, filp, 0); | 400 | drm_fasync(-1, filp, 0); |
415 | 401 | ||
416 | mutex_lock(&dev->ctxlist_mutex); | 402 | mutex_lock(&dev->ctxlist_mutex); |
417 | if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) { | 403 | if (!list_empty(&dev->ctxlist)) { |
418 | drm_ctx_list_t *pos, *n; | 404 | struct drm_ctx_list *pos, *n; |
419 | 405 | ||
420 | list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) { | 406 | list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { |
421 | if (pos->tag == priv && | 407 | if (pos->tag == priv && |
422 | pos->handle != DRM_KERNEL_CONTEXT) { | 408 | pos->handle != DRM_KERNEL_CONTEXT) { |
423 | if (dev->driver->context_dtor) | 409 | if (dev->driver->context_dtor) |
@@ -436,22 +422,12 @@ int drm_release(struct inode *inode, struct file *filp) | |||
436 | 422 | ||
437 | mutex_lock(&dev->struct_mutex); | 423 | mutex_lock(&dev->struct_mutex); |
438 | if (priv->remove_auth_on_close == 1) { | 424 | if (priv->remove_auth_on_close == 1) { |
439 | drm_file_t *temp = dev->file_first; | 425 | struct drm_file *temp; |
440 | while (temp) { | 426 | |
427 | list_for_each_entry(temp, &dev->filelist, lhead) | ||
441 | temp->authenticated = 0; | 428 | temp->authenticated = 0; |
442 | temp = temp->next; | ||
443 | } | ||
444 | } | ||
445 | if (priv->prev) { | ||
446 | priv->prev->next = priv->next; | ||
447 | } else { | ||
448 | dev->file_first = priv->next; | ||
449 | } | ||
450 | if (priv->next) { | ||
451 | priv->next->prev = priv->prev; | ||
452 | } else { | ||
453 | dev->file_last = priv->prev; | ||
454 | } | 429 | } |
430 | list_del(&priv->lhead); | ||
455 | mutex_unlock(&dev->struct_mutex); | 431 | mutex_unlock(&dev->struct_mutex); |
456 | 432 | ||
457 | if (dev->driver->postclose) | 433 | if (dev->driver->postclose) |