Remove such 3 levels of nesting patterns to check success return values
from function calls.

ret = enable_hvpipe_IRQ()
    if (!ret)
            ret = set_hvpipe_sys_param(1)
                if (!ret)
                    ret = misc_register()

Instead just bail out to "out*:" labels, in case of any error. This
simplifies the init flow.

Signed-off-by: Ritesh Harjani (IBM) <[email protected]>
---
 arch/powerpc/platforms/pseries/papr-hvpipe.c | 26 +++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c 
b/arch/powerpc/platforms/pseries/papr-hvpipe.c
index ac2c4b42b373..5d04d1fa4370 100644
--- a/arch/powerpc/platforms/pseries/papr-hvpipe.c
+++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c
@@ -783,23 +783,27 @@ static int __init papr_hvpipe_init(void)
        }
 
        ret = enable_hvpipe_IRQ();
-       if (!ret) {
-               ret = set_hvpipe_sys_param(1);
-               if (!ret)
-                       ret = misc_register(&papr_hvpipe_dev);
-       }
+       if (ret)
+               goto out_wq;
 
-       if (!ret) {
-               pr_info("hvpipe feature is enabled\n");
-               hvpipe_feature = true;
-               return 0;
-       }
+       ret = set_hvpipe_sys_param(1);
+       if (ret)
+               goto out_wq;
 
-       pr_err("hvpipe feature is not enabled %d\n", ret);
+       ret = misc_register(&papr_hvpipe_dev);
+       if (ret)
+               goto out_wq;
+
+       pr_info("hvpipe feature is enabled\n");
+       hvpipe_feature = true;
+       return 0;
+
+out_wq:
        destroy_workqueue(papr_hvpipe_wq);
 out:
        kfree(papr_hvpipe_work);
        papr_hvpipe_work = NULL;
+       pr_err("hvpipe feature is not enabled %d\n", ret);
        return ret;
 }
 machine_device_initcall(pseries, papr_hvpipe_init);
-- 
2.39.5


Reply via email to