forked from mirrors/linux
		
	rfkill: Cleanup error handling in rfkill_init()
Use a separate label per error condition in rfkill_init() to make it a bit cleaner and easier to extend. Signed-off-by: Michał Kępień <kernel@kempniu.pl> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
		
							parent
							
								
									4a5eccaa93
								
							
						
					
					
						commit
						6124c53ede
					
				
					 1 changed files with 12 additions and 11 deletions
				
			
		| 
						 | 
					@ -1263,24 +1263,25 @@ static int __init rfkill_init(void)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	error = class_register(&rfkill_class);
 | 
						error = class_register(&rfkill_class);
 | 
				
			||||||
	if (error)
 | 
						if (error)
 | 
				
			||||||
		goto out;
 | 
							goto error_class;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	error = misc_register(&rfkill_miscdev);
 | 
						error = misc_register(&rfkill_miscdev);
 | 
				
			||||||
	if (error) {
 | 
						if (error)
 | 
				
			||||||
		class_unregister(&rfkill_class);
 | 
							goto error_misc;
 | 
				
			||||||
		goto out;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_RFKILL_INPUT
 | 
					#ifdef CONFIG_RFKILL_INPUT
 | 
				
			||||||
	error = rfkill_handler_init();
 | 
						error = rfkill_handler_init();
 | 
				
			||||||
	if (error) {
 | 
						if (error)
 | 
				
			||||||
		misc_deregister(&rfkill_miscdev);
 | 
							goto error_input;
 | 
				
			||||||
		class_unregister(&rfkill_class);
 | 
					 | 
				
			||||||
		goto out;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 out:
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					error_input:
 | 
				
			||||||
 | 
						misc_deregister(&rfkill_miscdev);
 | 
				
			||||||
 | 
					error_misc:
 | 
				
			||||||
 | 
						class_unregister(&rfkill_class);
 | 
				
			||||||
 | 
					error_class:
 | 
				
			||||||
	return error;
 | 
						return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
subsys_initcall(rfkill_init);
 | 
					subsys_initcall(rfkill_init);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue