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

powerpc: pseries: 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.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Link: https://lore.kernel.org/r/20191014101642.GA30179@kroah.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+10 -55
+6 -32
arch/powerpc/platforms/pseries/dtl.c
··· 19 19 20 20 struct dtl { 21 21 struct dtl_entry *buf; 22 - struct dentry *file; 23 22 int cpu; 24 23 int buf_entries; 25 24 u64 last_idx; ··· 319 320 320 321 static struct dentry *dtl_dir; 321 322 322 - static int dtl_setup_file(struct dtl *dtl) 323 + static void dtl_setup_file(struct dtl *dtl) 323 324 { 324 325 char name[10]; 325 326 326 327 sprintf(name, "cpu-%d", dtl->cpu); 327 328 328 - dtl->file = debugfs_create_file(name, 0400, dtl_dir, dtl, &dtl_fops); 329 - if (!dtl->file) 330 - return -ENOMEM; 331 - 332 - return 0; 329 + debugfs_create_file(name, 0400, dtl_dir, dtl, &dtl_fops); 333 330 } 334 331 335 332 static int dtl_init(void) 336 333 { 337 - struct dentry *event_mask_file, *buf_entries_file; 338 - int rc, i; 334 + int i; 339 335 340 336 if (!firmware_has_feature(FW_FEATURE_SPLPAR)) 341 337 return -ENODEV; 342 338 343 339 /* set up common debugfs structure */ 344 340 345 - rc = -ENOMEM; 346 341 dtl_dir = debugfs_create_dir("dtl", powerpc_debugfs_root); 347 - if (!dtl_dir) { 348 - printk(KERN_WARNING "%s: can't create dtl root dir\n", 349 - __func__); 350 - goto err; 351 - } 352 342 353 - event_mask_file = debugfs_create_x8("dtl_event_mask", 0600, 354 - dtl_dir, &dtl_event_mask); 355 - buf_entries_file = debugfs_create_u32("dtl_buf_entries", 0400, 356 - dtl_dir, &dtl_buf_entries); 357 - 358 - if (!event_mask_file || !buf_entries_file) { 359 - printk(KERN_WARNING "%s: can't create dtl files\n", __func__); 360 - goto err_remove_dir; 361 - } 343 + debugfs_create_x8("dtl_event_mask", 0600, dtl_dir, &dtl_event_mask); 344 + debugfs_create_u32("dtl_buf_entries", 0400, dtl_dir, &dtl_buf_entries); 362 345 363 346 /* set up the per-cpu log structures */ 364 347 for_each_possible_cpu(i) { ··· 348 367 spin_lock_init(&dtl->lock); 349 368 dtl->cpu = i; 350 369 351 - rc = dtl_setup_file(dtl); 352 - if (rc) 353 - goto err_remove_dir; 370 + dtl_setup_file(dtl); 354 371 } 355 372 356 373 return 0; 357 - 358 - err_remove_dir: 359 - debugfs_remove_recursive(dtl_dir); 360 - err: 361 - return rc; 362 374 } 363 375 machine_arch_initcall(pseries, dtl_init);
+3 -9
arch/powerpc/platforms/pseries/hvCall_inst.c
··· 129 129 static int __init hcall_inst_init(void) 130 130 { 131 131 struct dentry *hcall_root; 132 - struct dentry *hcall_file; 133 132 char cpu_name_buf[CPU_NAME_BUF_SIZE]; 134 133 int cpu; 135 134 ··· 144 145 } 145 146 146 147 hcall_root = debugfs_create_dir(HCALL_ROOT_DIR, NULL); 147 - if (!hcall_root) 148 - return -ENOMEM; 149 148 150 149 for_each_possible_cpu(cpu) { 151 150 snprintf(cpu_name_buf, CPU_NAME_BUF_SIZE, "cpu%d", cpu); 152 - hcall_file = debugfs_create_file(cpu_name_buf, 0444, 153 - hcall_root, 154 - per_cpu(hcall_stats, cpu), 155 - &hcall_inst_seq_fops); 156 - if (!hcall_file) 157 - return -ENOMEM; 151 + debugfs_create_file(cpu_name_buf, 0444, hcall_root, 152 + per_cpu(hcall_stats, cpu), 153 + &hcall_inst_seq_fops); 158 154 } 159 155 160 156 return 0;
+1 -14
arch/powerpc/platforms/pseries/lpar.c
··· 1998 1998 return 0; 1999 1999 2000 2000 vpa_dir = debugfs_create_dir("vpa", powerpc_debugfs_root); 2001 - if (!vpa_dir) { 2002 - pr_warn("%s: can't create vpa root dir\n", __func__); 2003 - return -ENOMEM; 2004 - } 2005 2001 2006 2002 /* set up the per-cpu vpa file*/ 2007 2003 for_each_possible_cpu(i) { 2008 - struct dentry *d; 2009 - 2010 2004 sprintf(name, "cpu-%ld", i); 2011 - 2012 - d = debugfs_create_file(name, 0400, vpa_dir, (void *)i, 2013 - &vpa_fops); 2014 - if (!d) { 2015 - pr_warn("%s: can't create per-cpu vpa file\n", 2016 - __func__); 2017 - return -ENOMEM; 2018 - } 2005 + debugfs_create_file(name, 0400, vpa_dir, (void *)i, &vpa_fops); 2019 2006 } 2020 2007 2021 2008 return 0;