Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Greg Kroah-Hartman and committed by
Daniel Vetter
b792e640 5b038dcf

+29 -87
+1 -5
drivers/gpu/drm/drm_connector.c
··· 464 464 if (ret) 465 465 goto unlock; 466 466 467 - ret = drm_debugfs_connector_add(connector); 468 - if (ret) { 469 - goto err_sysfs; 470 - } 467 + drm_debugfs_connector_add(connector); 471 468 472 469 if (connector->funcs->late_register) { 473 470 ret = connector->funcs->late_register(connector); ··· 479 482 480 483 err_debugfs: 481 484 drm_debugfs_connector_remove(connector); 482 - err_sysfs: 483 485 drm_sysfs_connector_remove(connector); 484 486 unlock: 485 487 mutex_unlock(&connector->mutex);
+1 -3
drivers/gpu/drm/drm_crtc.c
··· 122 122 int ret = 0; 123 123 124 124 drm_for_each_crtc(crtc, dev) { 125 - if (drm_debugfs_crtc_add(crtc)) 126 - DRM_ERROR("Failed to initialize debugfs entry for CRTC '%s'.\n", 127 - crtc->name); 125 + drm_debugfs_crtc_add(crtc); 128 126 129 127 if (crtc->funcs->late_register) 130 128 ret = crtc->funcs->late_register(crtc);
+12 -41
drivers/gpu/drm/drm_debugfs.c
··· 229 229 mutex_init(&minor->debugfs_lock); 230 230 sprintf(name, "%d", minor_id); 231 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 233 ret = drm_debugfs_create_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, 238 234 minor->debugfs_root, minor); ··· 309 313 mutex_unlock(&minor->debugfs_lock); 310 314 } 311 315 312 - int drm_debugfs_cleanup(struct drm_minor *minor) 316 + void drm_debugfs_cleanup(struct drm_minor *minor) 313 317 { 314 318 if (!minor->debugfs_root) 315 - return 0; 319 + return; 316 320 317 321 drm_debugfs_remove_all_files(minor); 318 322 319 323 debugfs_remove_recursive(minor->debugfs_root); 320 324 minor->debugfs_root = NULL; 321 - 322 - return 0; 323 325 } 324 326 325 327 static int connector_show(struct seq_file *m, void *data) ··· 435 441 .write = connector_write 436 442 }; 437 443 438 - int drm_debugfs_connector_add(struct drm_connector *connector) 444 + void drm_debugfs_connector_add(struct drm_connector *connector) 439 445 { 440 446 struct drm_minor *minor = connector->dev->primary; 441 - struct dentry *root, *ent; 447 + struct dentry *root; 442 448 443 449 if (!minor->debugfs_root) 444 - return -1; 450 + return; 445 451 446 452 root = debugfs_create_dir(connector->name, minor->debugfs_root); 447 - if (!root) 448 - return -ENOMEM; 449 - 450 453 connector->debugfs_entry = root; 451 454 452 455 /* force */ 453 - ent = debugfs_create_file("force", S_IRUGO | S_IWUSR, root, connector, 454 - &drm_connector_fops); 455 - if (!ent) 456 - goto error; 456 + debugfs_create_file("force", S_IRUGO | S_IWUSR, root, connector, 457 + &drm_connector_fops); 457 458 458 459 /* edid */ 459 - ent = debugfs_create_file("edid_override", S_IRUGO | S_IWUSR, root, 460 - connector, &drm_edid_fops); 461 - if (!ent) 462 - goto error; 463 - 464 - return 0; 465 - 466 - error: 467 - debugfs_remove_recursive(connector->debugfs_entry); 468 - connector->debugfs_entry = NULL; 469 - return -ENOMEM; 460 + debugfs_create_file("edid_override", S_IRUGO | S_IWUSR, root, connector, 461 + &drm_edid_fops); 470 462 } 471 463 472 464 void drm_debugfs_connector_remove(struct drm_connector *connector) ··· 465 485 connector->debugfs_entry = NULL; 466 486 } 467 487 468 - int drm_debugfs_crtc_add(struct drm_crtc *crtc) 488 + void drm_debugfs_crtc_add(struct drm_crtc *crtc) 469 489 { 470 490 struct drm_minor *minor = crtc->dev->primary; 471 491 struct dentry *root; ··· 473 493 474 494 name = kasprintf(GFP_KERNEL, "crtc-%d", crtc->index); 475 495 if (!name) 476 - return -ENOMEM; 496 + return; 477 497 478 498 root = debugfs_create_dir(name, minor->debugfs_root); 479 499 kfree(name); 480 - if (!root) 481 - return -ENOMEM; 482 500 483 501 crtc->debugfs_entry = root; 484 502 485 - if (drm_debugfs_crtc_crc_add(crtc)) 486 - goto error; 487 - 488 - return 0; 489 - 490 - error: 491 - drm_debugfs_crtc_remove(crtc); 492 - return -ENOMEM; 503 + drm_debugfs_crtc_crc_add(crtc); 493 504 } 494 505 495 506 void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
+7 -21
drivers/gpu/drm/drm_debugfs_crc.c
··· 351 351 .release = crtc_crc_release, 352 352 }; 353 353 354 - int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc) 354 + void 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 358 if (!crtc->funcs->set_crc_source || !crtc->funcs->verify_crc_source) 359 - return 0; 359 + return; 360 360 361 361 crc_ent = debugfs_create_dir("crc", crtc->debugfs_entry); 362 - if (!crc_ent) 363 - return -ENOMEM; 364 362 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 - 377 - error: 378 - debugfs_remove_recursive(crc_ent); 379 - 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 /**
-5
drivers/gpu/drm/drm_drv.c
··· 1164 1164 } 1165 1165 1166 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 1168 ret = register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops); 1174 1169 if (ret < 0)
+8 -12
drivers/gpu/drm/drm_internal.h
··· 137 137 #if defined(CONFIG_DEBUG_FS) 138 138 int drm_debugfs_init(struct drm_minor *minor, int minor_id, 139 139 struct dentry *root); 140 - int drm_debugfs_cleanup(struct drm_minor *minor); 141 - int drm_debugfs_connector_add(struct drm_connector *connector); 140 + void drm_debugfs_cleanup(struct drm_minor *minor); 141 + void drm_debugfs_connector_add(struct drm_connector *connector); 142 142 void drm_debugfs_connector_remove(struct drm_connector *connector); 143 - int drm_debugfs_crtc_add(struct drm_crtc *crtc); 143 + void drm_debugfs_crtc_add(struct drm_crtc *crtc); 144 144 void drm_debugfs_crtc_remove(struct drm_crtc *crtc); 145 - int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc); 145 + void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc); 146 146 #else 147 147 static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id, 148 148 struct dentry *root) ··· 150 150 return 0; 151 151 } 152 152 153 - static inline int drm_debugfs_cleanup(struct drm_minor *minor) 153 + static inline void drm_debugfs_cleanup(struct drm_minor *minor) 154 154 { 155 - return 0; 156 155 } 157 156 158 - static inline int drm_debugfs_connector_add(struct drm_connector *connector) 157 + static inline void drm_debugfs_connector_add(struct drm_connector *connector) 159 158 { 160 - return 0; 161 159 } 162 160 static inline void drm_debugfs_connector_remove(struct drm_connector *connector) 163 161 { 164 162 } 165 163 166 - static inline int drm_debugfs_crtc_add(struct drm_crtc *crtc) 164 + static inline void drm_debugfs_crtc_add(struct drm_crtc *crtc) 167 165 { 168 - return 0; 169 166 } 170 167 static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc) 171 168 { 172 169 } 173 170 174 - static inline int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc) 171 + static inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc) 175 172 { 176 - return 0; 177 173 } 178 174 179 175 #endif