diff options
Diffstat (limited to 'drivers/gpu/drm/drm_proc.c')
-rw-r--r-- | drivers/gpu/drm/drm_proc.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c index ff5456b7df72..d7f2324b4fb1 100644 --- a/drivers/gpu/drm/drm_proc.c +++ b/drivers/gpu/drm/drm_proc.c | |||
@@ -49,7 +49,7 @@ | |||
49 | /** | 49 | /** |
50 | * Proc file list. | 50 | * Proc file list. |
51 | */ | 51 | */ |
52 | static struct drm_info_list drm_proc_list[] = { | 52 | static const struct drm_info_list drm_proc_list[] = { |
53 | {"name", drm_name_info, 0}, | 53 | {"name", drm_name_info, 0}, |
54 | {"vm", drm_vm_info, 0}, | 54 | {"vm", drm_vm_info, 0}, |
55 | {"clients", drm_clients_info, 0}, | 55 | {"clients", drm_clients_info, 0}, |
@@ -63,7 +63,7 @@ static struct drm_info_list drm_proc_list[] = { | |||
63 | 63 | ||
64 | static int drm_proc_open(struct inode *inode, struct file *file) | 64 | static int drm_proc_open(struct inode *inode, struct file *file) |
65 | { | 65 | { |
66 | struct drm_info_node* node = PDE(inode)->data; | 66 | struct drm_info_node* node = PDE_DATA(inode); |
67 | 67 | ||
68 | return single_open(file, node->info_ent->show, node); | 68 | return single_open(file, node->info_ent->show, node); |
69 | } | 69 | } |
@@ -89,13 +89,13 @@ static const struct file_operations drm_proc_fops = { | |||
89 | * Create a given set of proc files represented by an array of | 89 | * Create a given set of proc files represented by an array of |
90 | * gdm_proc_lists in the given root directory. | 90 | * gdm_proc_lists in the given root directory. |
91 | */ | 91 | */ |
92 | static int drm_proc_create_files(struct drm_info_list *files, int count, | 92 | static int drm_proc_create_files(const struct drm_info_list *files, int count, |
93 | struct proc_dir_entry *root, struct drm_minor *minor) | 93 | struct proc_dir_entry *root, struct drm_minor *minor) |
94 | { | 94 | { |
95 | struct drm_device *dev = minor->dev; | 95 | struct drm_device *dev = minor->dev; |
96 | struct proc_dir_entry *ent; | 96 | struct proc_dir_entry *ent; |
97 | struct drm_info_node *tmp; | 97 | struct drm_info_node *tmp; |
98 | int i, ret; | 98 | int i; |
99 | 99 | ||
100 | for (i = 0; i < count; i++) { | 100 | for (i = 0; i < count; i++) { |
101 | u32 features = files[i].driver_features; | 101 | u32 features = files[i].driver_features; |
@@ -105,10 +105,9 @@ static int drm_proc_create_files(struct drm_info_list *files, int count, | |||
105 | continue; | 105 | continue; |
106 | 106 | ||
107 | tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL); | 107 | tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL); |
108 | if (tmp == NULL) { | 108 | if (!tmp) |
109 | ret = -1; | 109 | return -1; |
110 | goto fail; | 110 | |
111 | } | ||
112 | tmp->minor = minor; | 111 | tmp->minor = minor; |
113 | tmp->info_ent = &files[i]; | 112 | tmp->info_ent = &files[i]; |
114 | list_add(&tmp->list, &minor->proc_nodes.list); | 113 | list_add(&tmp->list, &minor->proc_nodes.list); |
@@ -116,28 +115,20 @@ static int drm_proc_create_files(struct drm_info_list *files, int count, | |||
116 | ent = proc_create_data(files[i].name, S_IRUGO, root, | 115 | ent = proc_create_data(files[i].name, S_IRUGO, root, |
117 | &drm_proc_fops, tmp); | 116 | &drm_proc_fops, tmp); |
118 | if (!ent) { | 117 | if (!ent) { |
119 | DRM_ERROR("Cannot create /proc/dri/%s/%s\n", | 118 | DRM_ERROR("Cannot create /proc/dri/%u/%s\n", |
120 | root->name, files[i].name); | 119 | minor->index, files[i].name); |
121 | list_del(&tmp->list); | 120 | list_del(&tmp->list); |
122 | kfree(tmp); | 121 | kfree(tmp); |
123 | ret = -1; | 122 | return -1; |
124 | goto fail; | ||
125 | } | 123 | } |
126 | |||
127 | } | 124 | } |
128 | return 0; | 125 | return 0; |
129 | |||
130 | fail: | ||
131 | for (i = 0; i < count; i++) | ||
132 | remove_proc_entry(drm_proc_list[i].name, minor->proc_root); | ||
133 | return ret; | ||
134 | } | 126 | } |
135 | 127 | ||
136 | /** | 128 | /** |
137 | * Initialize the DRI proc filesystem for a device | 129 | * Initialize the DRI proc filesystem for a device |
138 | * | 130 | * |
139 | * \param dev DRM device | 131 | * \param dev DRM device |
140 | * \param minor device minor number | ||
141 | * \param root DRI proc dir entry. | 132 | * \param root DRI proc dir entry. |
142 | * \param dev_root resulting DRI device proc dir entry. | 133 | * \param dev_root resulting DRI device proc dir entry. |
143 | * \return root entry pointer on success, or NULL on failure. | 134 | * \return root entry pointer on success, or NULL on failure. |
@@ -146,14 +137,13 @@ fail: | |||
146 | * "/proc/dri/%minor%/", and each entry in proc_list as | 137 | * "/proc/dri/%minor%/", and each entry in proc_list as |
147 | * "/proc/dri/%minor%/%name%". | 138 | * "/proc/dri/%minor%/%name%". |
148 | */ | 139 | */ |
149 | int drm_proc_init(struct drm_minor *minor, int minor_id, | 140 | int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root) |
150 | struct proc_dir_entry *root) | ||
151 | { | 141 | { |
152 | char name[64]; | 142 | char name[12]; |
153 | int ret; | 143 | int ret; |
154 | 144 | ||
155 | INIT_LIST_HEAD(&minor->proc_nodes.list); | 145 | INIT_LIST_HEAD(&minor->proc_nodes.list); |
156 | sprintf(name, "%d", minor_id); | 146 | sprintf(name, "%u", minor->index); |
157 | minor->proc_root = proc_mkdir(name, root); | 147 | minor->proc_root = proc_mkdir(name, root); |
158 | if (!minor->proc_root) { | 148 | if (!minor->proc_root) { |
159 | DRM_ERROR("Cannot create /proc/dri/%s\n", name); | 149 | DRM_ERROR("Cannot create /proc/dri/%s\n", name); |
@@ -163,7 +153,7 @@ int drm_proc_init(struct drm_minor *minor, int minor_id, | |||
163 | ret = drm_proc_create_files(drm_proc_list, DRM_PROC_ENTRIES, | 153 | ret = drm_proc_create_files(drm_proc_list, DRM_PROC_ENTRIES, |
164 | minor->proc_root, minor); | 154 | minor->proc_root, minor); |
165 | if (ret) { | 155 | if (ret) { |
166 | remove_proc_entry(name, root); | 156 | remove_proc_subtree(name, root); |
167 | minor->proc_root = NULL; | 157 | minor->proc_root = NULL; |
168 | DRM_ERROR("Failed to create core drm proc files\n"); | 158 | DRM_ERROR("Failed to create core drm proc files\n"); |
169 | return ret; | 159 | return ret; |
@@ -172,7 +162,7 @@ int drm_proc_init(struct drm_minor *minor, int minor_id, | |||
172 | return 0; | 162 | return 0; |
173 | } | 163 | } |
174 | 164 | ||
175 | static int drm_proc_remove_files(struct drm_info_list *files, int count, | 165 | static int drm_proc_remove_files(const struct drm_info_list *files, int count, |
176 | struct drm_minor *minor) | 166 | struct drm_minor *minor) |
177 | { | 167 | { |
178 | struct list_head *pos, *q; | 168 | struct list_head *pos, *q; |
@@ -213,8 +203,7 @@ int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root) | |||
213 | drm_proc_remove_files(drm_proc_list, DRM_PROC_ENTRIES, minor); | 203 | drm_proc_remove_files(drm_proc_list, DRM_PROC_ENTRIES, minor); |
214 | 204 | ||
215 | sprintf(name, "%d", minor->index); | 205 | sprintf(name, "%d", minor->index); |
216 | remove_proc_entry(name, root); | 206 | remove_proc_subtree(name, root); |
217 | |||
218 | return 0; | 207 | return 0; |
219 | } | 208 | } |
220 | 209 | ||