diff options
author | Dave Airlie <airlied@redhat.com> | 2008-04-21 02:47:32 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2008-04-26 03:55:07 -0400 |
commit | 2c14f28be2a3f2a2e9861b156d64fbe2bc7000c3 (patch) | |
tree | dbf55c07d1b245a45330e0d879833df29954fe12 /drivers/char/drm/drm_proc.c | |
parent | 7b832b56bd971348329c3f4c753ca0abfdf3a3d1 (diff) |
drm: reorganise minor number handling using backported modesetting code.
rips out the head crap and replaces it with an idr and drm_minor structure
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/char/drm/drm_proc.c')
-rw-r--r-- | drivers/char/drm/drm_proc.c | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c index d9b560fe9bbe..93b1e0475c93 100644 --- a/drivers/char/drm/drm_proc.c +++ b/drivers/char/drm/drm_proc.c | |||
@@ -87,34 +87,35 @@ static struct drm_proc_list { | |||
87 | * "/proc/dri/%minor%/", and each entry in proc_list as | 87 | * "/proc/dri/%minor%/", and each entry in proc_list as |
88 | * "/proc/dri/%minor%/%name%". | 88 | * "/proc/dri/%minor%/%name%". |
89 | */ | 89 | */ |
90 | int drm_proc_init(struct drm_device * dev, int minor, | 90 | int drm_proc_init(struct drm_minor *minor, int minor_id, |
91 | struct proc_dir_entry *root, struct proc_dir_entry **dev_root) | 91 | struct proc_dir_entry *root) |
92 | { | 92 | { |
93 | struct proc_dir_entry *ent; | 93 | struct proc_dir_entry *ent; |
94 | int i, j; | 94 | int i, j; |
95 | char name[64]; | 95 | char name[64]; |
96 | 96 | ||
97 | sprintf(name, "%d", minor); | 97 | sprintf(name, "%d", minor_id); |
98 | *dev_root = proc_mkdir(name, root); | 98 | minor->dev_root = proc_mkdir(name, root); |
99 | if (!*dev_root) { | 99 | if (!minor->dev_root) { |
100 | DRM_ERROR("Cannot create /proc/dri/%s\n", name); | 100 | DRM_ERROR("Cannot create /proc/dri/%s\n", name); |
101 | return -1; | 101 | return -1; |
102 | } | 102 | } |
103 | 103 | ||
104 | for (i = 0; i < DRM_PROC_ENTRIES; i++) { | 104 | for (i = 0; i < DRM_PROC_ENTRIES; i++) { |
105 | ent = create_proc_entry(drm_proc_list[i].name, | 105 | ent = create_proc_entry(drm_proc_list[i].name, |
106 | S_IFREG | S_IRUGO, *dev_root); | 106 | S_IFREG | S_IRUGO, minor->dev_root); |
107 | if (!ent) { | 107 | if (!ent) { |
108 | DRM_ERROR("Cannot create /proc/dri/%s/%s\n", | 108 | DRM_ERROR("Cannot create /proc/dri/%s/%s\n", |
109 | name, drm_proc_list[i].name); | 109 | name, drm_proc_list[i].name); |
110 | for (j = 0; j < i; j++) | 110 | for (j = 0; j < i; j++) |
111 | remove_proc_entry(drm_proc_list[i].name, | 111 | remove_proc_entry(drm_proc_list[i].name, |
112 | *dev_root); | 112 | minor->dev_root); |
113 | remove_proc_entry(name, root); | 113 | remove_proc_entry(name, root); |
114 | minor->dev_root = NULL; | ||
114 | return -1; | 115 | return -1; |
115 | } | 116 | } |
116 | ent->read_proc = drm_proc_list[i].f; | 117 | ent->read_proc = drm_proc_list[i].f; |
117 | ent->data = dev; | 118 | ent->data = minor; |
118 | } | 119 | } |
119 | 120 | ||
120 | return 0; | 121 | return 0; |
@@ -130,18 +131,17 @@ int drm_proc_init(struct drm_device * dev, int minor, | |||
130 | * | 131 | * |
131 | * Remove all proc entries created by proc_init(). | 132 | * Remove all proc entries created by proc_init(). |
132 | */ | 133 | */ |
133 | int drm_proc_cleanup(int minor, struct proc_dir_entry *root, | 134 | int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root) |
134 | struct proc_dir_entry *dev_root) | ||
135 | { | 135 | { |
136 | int i; | 136 | int i; |
137 | char name[64]; | 137 | char name[64]; |
138 | 138 | ||
139 | if (!root || !dev_root) | 139 | if (!root || !minor->dev_root) |
140 | return 0; | 140 | return 0; |
141 | 141 | ||
142 | for (i = 0; i < DRM_PROC_ENTRIES; i++) | 142 | for (i = 0; i < DRM_PROC_ENTRIES; i++) |
143 | remove_proc_entry(drm_proc_list[i].name, dev_root); | 143 | remove_proc_entry(drm_proc_list[i].name, minor->dev_root); |
144 | sprintf(name, "%d", minor); | 144 | sprintf(name, "%d", minor->index); |
145 | remove_proc_entry(name, root); | 145 | remove_proc_entry(name, root); |
146 | 146 | ||
147 | return 0; | 147 | return 0; |
@@ -163,7 +163,8 @@ int drm_proc_cleanup(int minor, struct proc_dir_entry *root, | |||
163 | static int drm_name_info(char *buf, char **start, off_t offset, int request, | 163 | static int drm_name_info(char *buf, char **start, off_t offset, int request, |
164 | int *eof, void *data) | 164 | int *eof, void *data) |
165 | { | 165 | { |
166 | struct drm_device *dev = (struct drm_device *) data; | 166 | struct drm_minor *minor = (struct drm_minor *) data; |
167 | struct drm_device *dev = minor->dev; | ||
167 | int len = 0; | 168 | int len = 0; |
168 | 169 | ||
169 | if (offset > DRM_PROC_LIMIT) { | 170 | if (offset > DRM_PROC_LIMIT) { |
@@ -205,7 +206,8 @@ static int drm_name_info(char *buf, char **start, off_t offset, int request, | |||
205 | static int drm__vm_info(char *buf, char **start, off_t offset, int request, | 206 | static int drm__vm_info(char *buf, char **start, off_t offset, int request, |
206 | int *eof, void *data) | 207 | int *eof, void *data) |
207 | { | 208 | { |
208 | struct drm_device *dev = (struct drm_device *) data; | 209 | struct drm_minor *minor = (struct drm_minor *) data; |
210 | struct drm_device *dev = minor->dev; | ||
209 | int len = 0; | 211 | int len = 0; |
210 | struct drm_map *map; | 212 | struct drm_map *map; |
211 | struct drm_map_list *r_list; | 213 | struct drm_map_list *r_list; |
@@ -261,7 +263,8 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request, | |||
261 | static int drm_vm_info(char *buf, char **start, off_t offset, int request, | 263 | static int drm_vm_info(char *buf, char **start, off_t offset, int request, |
262 | int *eof, void *data) | 264 | int *eof, void *data) |
263 | { | 265 | { |
264 | struct drm_device *dev = (struct drm_device *) data; | 266 | struct drm_minor *minor = (struct drm_minor *) data; |
267 | struct drm_device *dev = minor->dev; | ||
265 | int ret; | 268 | int ret; |
266 | 269 | ||
267 | mutex_lock(&dev->struct_mutex); | 270 | mutex_lock(&dev->struct_mutex); |
@@ -284,7 +287,8 @@ static int drm_vm_info(char *buf, char **start, off_t offset, int request, | |||
284 | static int drm__queues_info(char *buf, char **start, off_t offset, | 287 | static int drm__queues_info(char *buf, char **start, off_t offset, |
285 | int request, int *eof, void *data) | 288 | int request, int *eof, void *data) |
286 | { | 289 | { |
287 | struct drm_device *dev = (struct drm_device *) data; | 290 | struct drm_minor *minor = (struct drm_minor *) data; |
291 | struct drm_device *dev = minor->dev; | ||
288 | int len = 0; | 292 | int len = 0; |
289 | int i; | 293 | int i; |
290 | struct drm_queue *q; | 294 | struct drm_queue *q; |
@@ -334,7 +338,8 @@ static int drm__queues_info(char *buf, char **start, off_t offset, | |||
334 | static int drm_queues_info(char *buf, char **start, off_t offset, int request, | 338 | static int drm_queues_info(char *buf, char **start, off_t offset, int request, |
335 | int *eof, void *data) | 339 | int *eof, void *data) |
336 | { | 340 | { |
337 | struct drm_device *dev = (struct drm_device *) data; | 341 | struct drm_minor *minor = (struct drm_minor *) data; |
342 | struct drm_device *dev = minor->dev; | ||
338 | int ret; | 343 | int ret; |
339 | 344 | ||
340 | mutex_lock(&dev->struct_mutex); | 345 | mutex_lock(&dev->struct_mutex); |
@@ -357,7 +362,8 @@ static int drm_queues_info(char *buf, char **start, off_t offset, int request, | |||
357 | static int drm__bufs_info(char *buf, char **start, off_t offset, int request, | 362 | static int drm__bufs_info(char *buf, char **start, off_t offset, int request, |
358 | int *eof, void *data) | 363 | int *eof, void *data) |
359 | { | 364 | { |
360 | struct drm_device *dev = (struct drm_device *) data; | 365 | struct drm_minor *minor = (struct drm_minor *) data; |
366 | struct drm_device *dev = minor->dev; | ||
361 | int len = 0; | 367 | int len = 0; |
362 | struct drm_device_dma *dma = dev->dma; | 368 | struct drm_device_dma *dma = dev->dma; |
363 | int i; | 369 | int i; |
@@ -406,7 +412,8 @@ static int drm__bufs_info(char *buf, char **start, off_t offset, int request, | |||
406 | static int drm_bufs_info(char *buf, char **start, off_t offset, int request, | 412 | static int drm_bufs_info(char *buf, char **start, off_t offset, int request, |
407 | int *eof, void *data) | 413 | int *eof, void *data) |
408 | { | 414 | { |
409 | struct drm_device *dev = (struct drm_device *) data; | 415 | struct drm_minor *minor = (struct drm_minor *) data; |
416 | struct drm_device *dev = minor->dev; | ||
410 | int ret; | 417 | int ret; |
411 | 418 | ||
412 | mutex_lock(&dev->struct_mutex); | 419 | mutex_lock(&dev->struct_mutex); |
@@ -429,7 +436,8 @@ static int drm_bufs_info(char *buf, char **start, off_t offset, int request, | |||
429 | static int drm__clients_info(char *buf, char **start, off_t offset, | 436 | static int drm__clients_info(char *buf, char **start, off_t offset, |
430 | int request, int *eof, void *data) | 437 | int request, int *eof, void *data) |
431 | { | 438 | { |
432 | struct drm_device *dev = (struct drm_device *) data; | 439 | struct drm_minor *minor = (struct drm_minor *) data; |
440 | struct drm_device *dev = minor->dev; | ||
433 | int len = 0; | 441 | int len = 0; |
434 | struct drm_file *priv; | 442 | struct drm_file *priv; |
435 | 443 | ||
@@ -445,7 +453,7 @@ static int drm__clients_info(char *buf, char **start, off_t offset, | |||
445 | list_for_each_entry(priv, &dev->filelist, lhead) { | 453 | list_for_each_entry(priv, &dev->filelist, lhead) { |
446 | DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lu\n", | 454 | DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lu\n", |
447 | priv->authenticated ? 'y' : 'n', | 455 | priv->authenticated ? 'y' : 'n', |
448 | priv->minor, | 456 | priv->minor->index, |
449 | priv->pid, | 457 | priv->pid, |
450 | priv->uid, priv->magic, priv->ioctl_count); | 458 | priv->uid, priv->magic, priv->ioctl_count); |
451 | } | 459 | } |
@@ -462,7 +470,8 @@ static int drm__clients_info(char *buf, char **start, off_t offset, | |||
462 | static int drm_clients_info(char *buf, char **start, off_t offset, | 470 | static int drm_clients_info(char *buf, char **start, off_t offset, |
463 | int request, int *eof, void *data) | 471 | int request, int *eof, void *data) |
464 | { | 472 | { |
465 | struct drm_device *dev = (struct drm_device *) data; | 473 | struct drm_minor *minor = (struct drm_minor *) data; |
474 | struct drm_device *dev = minor->dev; | ||
466 | int ret; | 475 | int ret; |
467 | 476 | ||
468 | mutex_lock(&dev->struct_mutex); | 477 | mutex_lock(&dev->struct_mutex); |
@@ -476,7 +485,8 @@ static int drm_clients_info(char *buf, char **start, off_t offset, | |||
476 | static int drm__vma_info(char *buf, char **start, off_t offset, int request, | 485 | static int drm__vma_info(char *buf, char **start, off_t offset, int request, |
477 | int *eof, void *data) | 486 | int *eof, void *data) |
478 | { | 487 | { |
479 | struct drm_device *dev = (struct drm_device *) data; | 488 | struct drm_minor *minor = (struct drm_minor *) data; |
489 | struct drm_device *dev = minor->dev; | ||
480 | int len = 0; | 490 | int len = 0; |
481 | struct drm_vma_entry *pt; | 491 | struct drm_vma_entry *pt; |
482 | struct vm_area_struct *vma; | 492 | struct vm_area_struct *vma; |
@@ -535,7 +545,8 @@ static int drm__vma_info(char *buf, char **start, off_t offset, int request, | |||
535 | static int drm_vma_info(char *buf, char **start, off_t offset, int request, | 545 | static int drm_vma_info(char *buf, char **start, off_t offset, int request, |
536 | int *eof, void *data) | 546 | int *eof, void *data) |
537 | { | 547 | { |
538 | struct drm_device *dev = (struct drm_device *) data; | 548 | struct drm_minor *minor = (struct drm_minor *) data; |
549 | struct drm_device *dev = minor->dev; | ||
539 | int ret; | 550 | int ret; |
540 | 551 | ||
541 | mutex_lock(&dev->struct_mutex); | 552 | mutex_lock(&dev->struct_mutex); |