[PATCH 3/5] crypto/nx: Create nx842_delete_coproc function

Move deleting coprocessor info upon exit or failure to
nx842_delete_coproc().

Signed-off-by: Haren Myneni <ha...@us.ibm.com>
---
 drivers/crypto/nx/nx-842-powernv.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/crypto/nx/nx-842-powernv.c 
b/drivers/crypto/nx/nx-842-powernv.c
index 4cd6a6f..8737e90 100644
--- a/drivers/crypto/nx/nx-842-powernv.c
+++ b/drivers/crypto/nx/nx-842-powernv.c
@@ -597,6 +597,16 @@ static int __init nx842_powernv_probe(struct device_node 
*dn)
        return 0;
 }
 
+static void nx842_delete_coproc(void)
+{
+       struct nx842_coproc *coproc, *n;
+
+       list_for_each_entry_safe(coproc, n, &nx842_coprocs, list) {
+               list_del(&coproc->list);
+               kfree(coproc);
+       }
+}
+
 static struct nx842_constraints nx842_powernv_constraints = {
        .alignment =    DDE_BUFFER_ALIGN,
        .multiple =     DDE_BUFFER_LAST_MULT,
@@ -656,13 +666,7 @@ static __init int nx842_powernv_init(void)
 
        ret = crypto_register_alg(&nx842_powernv_alg);
        if (ret) {
-               struct nx842_coproc *coproc, *n;
-
-               list_for_each_entry_safe(coproc, n, &nx842_coprocs, list) {
-                       list_del(&coproc->list);
-                       kfree(coproc);
-               }
-
+               nx842_delete_coproc();
                return ret;
        }
 
@@ -672,13 +676,8 @@ static __init int nx842_powernv_init(void)
 
 static void __exit nx842_powernv_exit(void)
 {
-       struct nx842_coproc *coproc, *n;
-
        crypto_unregister_alg(&nx842_powernv_alg);
 
-       list_for_each_entry_safe(coproc, n, &nx842_coprocs, list) {
-               list_del(&coproc->list);
-               kfree(coproc);
-       }
+       nx842_delete_coproc();
 }
 module_exit(nx842_powernv_exit);
-- 
1.8.3.1



Reply via email to