Staging: sep: untangle the register_fs code
authorAlan Cox <alan@linux.intel.com>
Fri, 14 Aug 2009 14:49:22 +0000 (15:49 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 15 Sep 2009 19:02:15 +0000 (12:02 -0700)
While goto can be useful for cleaner cleaning up in C (as Linux sometimes
does and I think Linus borrowed stylistically from Amiga) you can overdo it.
Here is a fine fine example of when it's overkill

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/sep/sep_driver.c

index 79dce5804c63aa02452f0e636364a4f5dc317238..aa864362ad347a5ce16174e80ae02f7b8574aeef 100644 (file)
@@ -2169,8 +2169,8 @@ static int sep_get_time_handler(struct sep_device *sep, unsigned long arg)
        struct sep_driver_get_time_t command_args;
 
        mutex_lock(&sep_mutex);
-       command_arg.time_value = sep_set_time(sep);
-       command_args.time_physical_address = sep_time_address(sep);
+       command_args.time_value = sep_set_time(sep);
+       command_args.time_physical_address = (unsigned long)sep_time_address(sep);
        mutex_unlock(&sep_mutex);
        if (copy_to_user((void __user *)arg,
                        &command_args, sizeof(struct sep_driver_get_time_t)))
@@ -2646,31 +2646,22 @@ static int sep_register_driver_to_fs(void)
 {
        int ret_val = alloc_chrdev_region(&sep_devno, 0, 1, "sep_sec_driver");
        if (ret_val) {
-               edbg("sep_driver:major number allocation failed, retval is %d\n", ret_val);
-               goto end_function;
+               edbg("sep: major number allocation failed, retval is %d\n",
+                                                               ret_val);
+               return ret_val;
        }
-
        /* init cdev */
        cdev_init(&sep_cdev, &sep_file_operations);
        sep_cdev.owner = THIS_MODULE;
 
        /* register the driver with the kernel */
        ret_val = cdev_add(&sep_cdev, sep_devno, 1);
-
        if (ret_val) {
                edbg("sep_driver:cdev_add failed, retval is %d\n", ret_val);
-               goto end_function_unregister_devnum;
+               /* unregister dev numbers */
+               unregister_chrdev_region(sep_devno, 1);
        }
-
-       goto end_function;
-
-end_function_unregister_devnum:
-
-       /* unregister dev numbers */
-       unregister_chrdev_region(sep_devno, 1);
-
-end_function:
-      return ret_val;
+       return ret_val;
 }