aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-13 09:34:39 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2019-06-13 10:39:16 -0400
commitb792e64021ecdefd27b84eb235d59b0476d4255c (patch)
tree537906c9e15624a6fa8623c0417c54ba4c1457bf
parent5b038dcf9d0aa0b1e8f2a8f973441b4f66d325f2 (diff)
drm: no need to check return value of debugfs_create functions
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Because there is no need to check these functions, a number of local functions can be made to return void to simplify things as nothing can fail. Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Maxime Ripard <maxime.ripard@bootlin.com> Cc: Sean Paul <sean@poorly.run> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190613133439.GA6715@kroah.com
-rw-r--r--drivers/gpu/drm/drm_connector.c6
-rw-r--r--drivers/gpu/drm/drm_crtc.c4
-rw-r--r--drivers/gpu/drm/drm_debugfs.c53
-rw-r--r--drivers/gpu/drm/drm_debugfs_crc.c28
-rw-r--r--drivers/gpu/drm/drm_drv.c5
-rw-r--r--drivers/gpu/drm/drm_internal.h20
6 files changed, 29 insertions, 87 deletions
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index e17586aaa80f..a598a5eb48d2 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -464,10 +464,7 @@ int drm_connector_register(struct drm_connector *connector)
464 if (ret) 464 if (ret)
465 goto unlock; 465 goto unlock;
466 466
467 ret = drm_debugfs_connector_add(connector); 467 drm_debugfs_connector_add(connector);
468 if (ret) {
469 goto err_sysfs;
470 }
471 468
472 if (connector->funcs->late_register) { 469 if (connector->funcs->late_register) {
473 ret = connector->funcs->late_register(connector); 470 ret = connector->funcs->late_register(connector);
@@ -482,7 +479,6 @@ int drm_connector_register(struct drm_connector *connector)
482 479
483err_debugfs: 480err_debugfs:
484 drm_debugfs_connector_remove(connector); 481 drm_debugfs_connector_remove(connector);
485err_sysfs:
486 drm_sysfs_connector_remove(connector); 482 drm_sysfs_connector_remove(connector);
487unlock: 483unlock:
488 mutex_unlock(&connector->mutex); 484 mutex_unlock(&connector->mutex);
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 790ba5941954..4936e1080e41 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -122,9 +122,7 @@ int drm_crtc_register_all(struct drm_device *dev)
122 int ret = 0; 122 int ret = 0;
123 123
124 drm_for_each_crtc(crtc, dev) { 124 drm_for_each_crtc(crtc, dev) {
125 if (drm_debugfs_crtc_add(crtc)) 125 drm_debugfs_crtc_add(crtc);
126 DRM_ERROR("Failed to initialize debugfs entry for CRTC '%s'.\n",
127 crtc->name);
128 126
129 if (crtc->funcs->late_register) 127 if (crtc->funcs->late_register)
130 ret = crtc->funcs->late_register(crtc); 128 ret = crtc->funcs->late_register(crtc);
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 4b8e817d7420..63b9951bb8f3 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -229,10 +229,6 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
229 mutex_init(&minor->debugfs_lock); 229 mutex_init(&minor->debugfs_lock);
230 sprintf(name, "%d", minor_id); 230 sprintf(name, "%d", minor_id);
231 minor->debugfs_root = debugfs_create_dir(name, root); 231 minor->debugfs_root = debugfs_create_dir(name, root);
232 if (!minor->debugfs_root) {
233 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%s\n", name);
234 return -1;
235 }
236 232
237 ret = drm_debugfs_create_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, 233 ret = drm_debugfs_create_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES,
238 minor->debugfs_root, minor); 234 minor->debugfs_root, minor);
@@ -313,17 +309,15 @@ static void drm_debugfs_remove_all_files(struct drm_minor *minor)
313 mutex_unlock(&minor->debugfs_lock); 309 mutex_unlock(&minor->debugfs_lock);
314} 310}
315 311
316int drm_debugfs_cleanup(struct drm_minor *minor) 312void drm_debugfs_cleanup(struct drm_minor *minor)
317{ 313{
318 if (!minor->debugfs_root) 314 if (!minor->debugfs_root)
319 return 0; 315 return;
320 316
321 drm_debugfs_remove_all_files(minor); 317 drm_debugfs_remove_all_files(minor);
322 318
323 debugfs_remove_recursive(minor->debugfs_root); 319 debugfs_remove_recursive(minor->debugfs_root);
324 minor->debugfs_root = NULL; 320 minor->debugfs_root = NULL;
325
326 return 0;
327} 321}
328 322
329static int connector_show(struct seq_file *m, void *data) 323static int connector_show(struct seq_file *m, void *data)
@@ -441,38 +435,24 @@ static const struct file_operations drm_connector_fops = {
441 .write = connector_write 435 .write = connector_write
442}; 436};
443 437
444int drm_debugfs_connector_add(struct drm_connector *connector) 438void drm_debugfs_connector_add(struct drm_connector *connector)
445{ 439{
446 struct drm_minor *minor = connector->dev->primary; 440 struct drm_minor *minor = connector->dev->primary;
447 struct dentry *root, *ent; 441 struct dentry *root;
448 442
449 if (!minor->debugfs_root) 443 if (!minor->debugfs_root)
450 return -1; 444 return;
451 445
452 root = debugfs_create_dir(connector->name, minor->debugfs_root); 446 root = debugfs_create_dir(connector->name, minor->debugfs_root);
453 if (!root)
454 return -ENOMEM;
455
456 connector->debugfs_entry = root; 447 connector->debugfs_entry = root;
457 448
458 /* force */ 449 /* force */
459 ent = debugfs_create_file("force", S_IRUGO | S_IWUSR, root, connector, 450 debugfs_create_file("force", S_IRUGO | S_IWUSR, root, connector,
460 &drm_connector_fops); 451 &drm_connector_fops);
461 if (!ent)
462 goto error;
463 452
464 /* edid */ 453 /* edid */
465 ent = debugfs_create_file("edid_override", S_IRUGO | S_IWUSR, root, 454 debugfs_create_file("edid_override", S_IRUGO | S_IWUSR, root, connector,
466 connector, &drm_edid_fops); 455 &drm_edid_fops);
467 if (!ent)
468 goto error;
469
470 return 0;
471
472error:
473 debugfs_remove_recursive(connector->debugfs_entry);
474 connector->debugfs_entry = NULL;
475 return -ENOMEM;
476} 456}
477 457
478void drm_debugfs_connector_remove(struct drm_connector *connector) 458void drm_debugfs_connector_remove(struct drm_connector *connector)
@@ -485,7 +465,7 @@ void drm_debugfs_connector_remove(struct drm_connector *connector)
485 connector->debugfs_entry = NULL; 465 connector->debugfs_entry = NULL;
486} 466}
487 467
488int drm_debugfs_crtc_add(struct drm_crtc *crtc) 468void drm_debugfs_crtc_add(struct drm_crtc *crtc)
489{ 469{
490 struct drm_minor *minor = crtc->dev->primary; 470 struct drm_minor *minor = crtc->dev->primary;
491 struct dentry *root; 471 struct dentry *root;
@@ -493,23 +473,14 @@ int drm_debugfs_crtc_add(struct drm_crtc *crtc)
493 473
494 name = kasprintf(GFP_KERNEL, "crtc-%d", crtc->index); 474 name = kasprintf(GFP_KERNEL, "crtc-%d", crtc->index);
495 if (!name) 475 if (!name)
496 return -ENOMEM; 476 return;
497 477
498 root = debugfs_create_dir(name, minor->debugfs_root); 478 root = debugfs_create_dir(name, minor->debugfs_root);
499 kfree(name); 479 kfree(name);
500 if (!root)
501 return -ENOMEM;
502 480
503 crtc->debugfs_entry = root; 481 crtc->debugfs_entry = root;
504 482
505 if (drm_debugfs_crtc_crc_add(crtc)) 483 drm_debugfs_crtc_crc_add(crtc);
506 goto error;
507
508 return 0;
509
510error:
511 drm_debugfs_crtc_remove(crtc);
512 return -ENOMEM;
513} 484}
514 485
515void drm_debugfs_crtc_remove(struct drm_crtc *crtc) 486void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c
index d2f102f01515..7ca486d750e9 100644
--- a/drivers/gpu/drm/drm_debugfs_crc.c
+++ b/drivers/gpu/drm/drm_debugfs_crc.c
@@ -351,33 +351,19 @@ static const struct file_operations drm_crtc_crc_data_fops = {
351 .release = crtc_crc_release, 351 .release = crtc_crc_release,
352}; 352};
353 353
354int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc) 354void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
355{ 355{
356 struct dentry *crc_ent, *ent; 356 struct dentry *crc_ent;
357 357
358 if (!crtc->funcs->set_crc_source || !crtc->funcs->verify_crc_source) 358 if (!crtc->funcs->set_crc_source || !crtc->funcs->verify_crc_source)
359 return 0; 359 return;
360 360
361 crc_ent = debugfs_create_dir("crc", crtc->debugfs_entry); 361 crc_ent = debugfs_create_dir("crc", crtc->debugfs_entry);
362 if (!crc_ent)
363 return -ENOMEM;
364
365 ent = debugfs_create_file("control", S_IRUGO, crc_ent, crtc,
366 &drm_crtc_crc_control_fops);
367 if (!ent)
368 goto error;
369
370 ent = debugfs_create_file("data", S_IRUGO, crc_ent, crtc,
371 &drm_crtc_crc_data_fops);
372 if (!ent)
373 goto error;
374
375 return 0;
376
377error:
378 debugfs_remove_recursive(crc_ent);
379 362
380 return -ENOMEM; 363 debugfs_create_file("control", S_IRUGO, crc_ent, crtc,
364 &drm_crtc_crc_control_fops);
365 debugfs_create_file("data", S_IRUGO, crc_ent, crtc,
366 &drm_crtc_crc_data_fops);
381} 367}
382 368
383/** 369/**
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 95a55d98e152..fe0ce86c280f 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -1164,11 +1164,6 @@ static int __init drm_core_init(void)
1164 } 1164 }
1165 1165
1166 drm_debugfs_root = debugfs_create_dir("dri", NULL); 1166 drm_debugfs_root = debugfs_create_dir("dri", NULL);
1167 if (!drm_debugfs_root) {
1168 ret = -ENOMEM;
1169 DRM_ERROR("Cannot create debugfs-root: %d\n", ret);
1170 goto error;
1171 }
1172 1167
1173 ret = register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops); 1168 ret = register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops);
1174 if (ret < 0) 1169 if (ret < 0)
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index 596e9f4ca7fc..d18c7b91a1a8 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -137,12 +137,12 @@ void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
137#if defined(CONFIG_DEBUG_FS) 137#if defined(CONFIG_DEBUG_FS)
138int drm_debugfs_init(struct drm_minor *minor, int minor_id, 138int drm_debugfs_init(struct drm_minor *minor, int minor_id,
139 struct dentry *root); 139 struct dentry *root);
140int drm_debugfs_cleanup(struct drm_minor *minor); 140void drm_debugfs_cleanup(struct drm_minor *minor);
141int drm_debugfs_connector_add(struct drm_connector *connector); 141void drm_debugfs_connector_add(struct drm_connector *connector);
142void drm_debugfs_connector_remove(struct drm_connector *connector); 142void drm_debugfs_connector_remove(struct drm_connector *connector);
143int drm_debugfs_crtc_add(struct drm_crtc *crtc); 143void drm_debugfs_crtc_add(struct drm_crtc *crtc);
144void drm_debugfs_crtc_remove(struct drm_crtc *crtc); 144void drm_debugfs_crtc_remove(struct drm_crtc *crtc);
145int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc); 145void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc);
146#else 146#else
147static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id, 147static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
148 struct dentry *root) 148 struct dentry *root)
@@ -150,30 +150,26 @@ static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
150 return 0; 150 return 0;
151} 151}
152 152
153static inline int drm_debugfs_cleanup(struct drm_minor *minor) 153static inline void drm_debugfs_cleanup(struct drm_minor *minor)
154{ 154{
155 return 0;
156} 155}
157 156
158static inline int drm_debugfs_connector_add(struct drm_connector *connector) 157static inline void drm_debugfs_connector_add(struct drm_connector *connector)
159{ 158{
160 return 0;
161} 159}
162static inline void drm_debugfs_connector_remove(struct drm_connector *connector) 160static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
163{ 161{
164} 162}
165 163
166static inline int drm_debugfs_crtc_add(struct drm_crtc *crtc) 164static inline void drm_debugfs_crtc_add(struct drm_crtc *crtc)
167{ 165{
168 return 0;
169} 166}
170static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc) 167static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
171{ 168{
172} 169}
173 170
174static inline int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc) 171static inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
175{ 172{
176 return 0;
177} 173}
178 174
179#endif 175#endif