diff options
author | David Howells <dhowells@redhat.com> | 2013-04-12 10:34:31 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-05-01 17:29:44 -0400 |
commit | b63e6aa5028dfde3b360945564290de28b47c2d7 (patch) | |
tree | 1761e4b0f59254bb30602d9690c2431c5a7f5b36 | |
parent | ce089b5472f7d0321bcb2cbc22d85bac15e4778b (diff) |
drm: proc: Use minor->index to label things, not PDE->name
Use minor->index to label things, not the name field from the proc_dir_entry
of the /proc/dwm/<minor>/ directory.
Also, use "%u" not "%d" to render the value and use a 12-byte buffer in which
to render the integer, not a 16-byte buffer. The longest string an unsigned
int can give you is 10 chars (4294967295) plus a NUL, so round up to 12 as the
stack is likely to be 4- or 8-byte aligned.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: dri-devel@lists.freedesktop.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | drivers/gpu/drm/drm_proc.c | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_stub.c | 2 | ||||
-rw-r--r-- | include/drm/drmP.h | 3 |
3 files changed, 7 insertions, 11 deletions
diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c index aead653c1833..0646a462d4c7 100644 --- a/drivers/gpu/drm/drm_proc.c +++ b/drivers/gpu/drm/drm_proc.c | |||
@@ -116,14 +116,13 @@ static int drm_proc_create_files(const struct drm_info_list *files, int count, | |||
116 | ent = proc_create_data(files[i].name, S_IRUGO, root, | 116 | ent = proc_create_data(files[i].name, S_IRUGO, root, |
117 | &drm_proc_fops, tmp); | 117 | &drm_proc_fops, tmp); |
118 | if (!ent) { | 118 | if (!ent) { |
119 | DRM_ERROR("Cannot create /proc/dri/%s/%s\n", | 119 | DRM_ERROR("Cannot create /proc/dri/%u/%s\n", |
120 | root->name, files[i].name); | 120 | minor->index, files[i].name); |
121 | list_del(&tmp->list); | 121 | list_del(&tmp->list); |
122 | kfree(tmp); | 122 | kfree(tmp); |
123 | ret = -1; | 123 | ret = -1; |
124 | goto fail; | 124 | goto fail; |
125 | } | 125 | } |
126 | |||
127 | } | 126 | } |
128 | return 0; | 127 | return 0; |
129 | 128 | ||
@@ -137,7 +136,6 @@ fail: | |||
137 | * Initialize the DRI proc filesystem for a device | 136 | * Initialize the DRI proc filesystem for a device |
138 | * | 137 | * |
139 | * \param dev DRM device | 138 | * \param dev DRM device |
140 | * \param minor device minor number | ||
141 | * \param root DRI proc dir entry. | 139 | * \param root DRI proc dir entry. |
142 | * \param dev_root resulting DRI device proc dir entry. | 140 | * \param dev_root resulting DRI device proc dir entry. |
143 | * \return root entry pointer on success, or NULL on failure. | 141 | * \return root entry pointer on success, or NULL on failure. |
@@ -146,14 +144,13 @@ fail: | |||
146 | * "/proc/dri/%minor%/", and each entry in proc_list as | 144 | * "/proc/dri/%minor%/", and each entry in proc_list as |
147 | * "/proc/dri/%minor%/%name%". | 145 | * "/proc/dri/%minor%/%name%". |
148 | */ | 146 | */ |
149 | int drm_proc_init(struct drm_minor *minor, int minor_id, | 147 | int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root) |
150 | struct proc_dir_entry *root) | ||
151 | { | 148 | { |
152 | char name[64]; | 149 | char name[12]; |
153 | int ret; | 150 | int ret; |
154 | 151 | ||
155 | INIT_LIST_HEAD(&minor->proc_nodes.list); | 152 | INIT_LIST_HEAD(&minor->proc_nodes.list); |
156 | sprintf(name, "%d", minor_id); | 153 | sprintf(name, "%u", minor->index); |
157 | minor->proc_root = proc_mkdir(name, root); | 154 | minor->proc_root = proc_mkdir(name, root); |
158 | if (!minor->proc_root) { | 155 | if (!minor->proc_root) { |
159 | DRM_ERROR("Cannot create /proc/dri/%s\n", name); | 156 | DRM_ERROR("Cannot create /proc/dri/%s\n", name); |
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index 7d30802a018f..16f3ec579b3b 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c | |||
@@ -352,7 +352,7 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type) | |||
352 | idr_replace(&drm_minors_idr, new_minor, minor_id); | 352 | idr_replace(&drm_minors_idr, new_minor, minor_id); |
353 | 353 | ||
354 | if (type == DRM_MINOR_LEGACY) { | 354 | if (type == DRM_MINOR_LEGACY) { |
355 | ret = drm_proc_init(new_minor, minor_id, drm_proc_root); | 355 | ret = drm_proc_init(new_minor, drm_proc_root); |
356 | if (ret) { | 356 | if (ret) { |
357 | DRM_ERROR("DRM: Failed to initialize /proc/dri.\n"); | 357 | DRM_ERROR("DRM: Failed to initialize /proc/dri.\n"); |
358 | goto err_mem; | 358 | goto err_mem; |
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index af5332059328..60c33f14408f 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -1546,8 +1546,7 @@ extern struct idr drm_minors_idr; | |||
1546 | extern struct drm_local_map *drm_getsarea(struct drm_device *dev); | 1546 | extern struct drm_local_map *drm_getsarea(struct drm_device *dev); |
1547 | 1547 | ||
1548 | /* Proc support (drm_proc.h) */ | 1548 | /* Proc support (drm_proc.h) */ |
1549 | extern int drm_proc_init(struct drm_minor *minor, int minor_id, | 1549 | extern int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root); |
1550 | struct proc_dir_entry *root); | ||
1551 | extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root); | 1550 | extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root); |
1552 | 1551 | ||
1553 | /* Debugfs support */ | 1552 | /* Debugfs support */ |