Commit 1ee51b28 authored by Haren Myneni's avatar Haren Myneni Committed by Michael Ellerman

crypto/nx: Create nx842_delete_coprocs function

Move deleting coprocessors info upon exit or failure to
nx842_delete_coprocs().
Signed-off-by: default avatarHaren Myneni <haren@us.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 56c10d5e
...@@ -593,6 +593,16 @@ static int __init nx842_powernv_probe(struct device_node *dn) ...@@ -593,6 +593,16 @@ static int __init nx842_powernv_probe(struct device_node *dn)
return 0; 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 = { static struct nx842_constraints nx842_powernv_constraints = {
.alignment = DDE_BUFFER_ALIGN, .alignment = DDE_BUFFER_ALIGN,
.multiple = DDE_BUFFER_LAST_MULT, .multiple = DDE_BUFFER_LAST_MULT,
...@@ -652,13 +662,7 @@ static __init int nx842_powernv_init(void) ...@@ -652,13 +662,7 @@ static __init int nx842_powernv_init(void)
ret = crypto_register_alg(&nx842_powernv_alg); ret = crypto_register_alg(&nx842_powernv_alg);
if (ret) { if (ret) {
struct nx842_coproc *coproc, *n; nx842_delete_coprocs();
list_for_each_entry_safe(coproc, n, &nx842_coprocs, list) {
list_del(&coproc->list);
kfree(coproc);
}
return ret; return ret;
} }
...@@ -668,13 +672,8 @@ module_init(nx842_powernv_init); ...@@ -668,13 +672,8 @@ module_init(nx842_powernv_init);
static void __exit nx842_powernv_exit(void) static void __exit nx842_powernv_exit(void)
{ {
struct nx842_coproc *coproc, *n;
crypto_unregister_alg(&nx842_powernv_alg); crypto_unregister_alg(&nx842_powernv_alg);
list_for_each_entry_safe(coproc, n, &nx842_coprocs, list) { nx842_delete_coprocs();
list_del(&coproc->list);
kfree(coproc);
}
} }
module_exit(nx842_powernv_exit); module_exit(nx842_powernv_exit);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment