return 0;
 }
 
+static void nx842_delete_coprocs(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,
 
        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_coprocs();
                return ret;
        }
 
 
 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_coprocs();
 }
 module_exit(nx842_powernv_exit);