Commit d6f4aac1 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Paolo Abeni

nfc: hci: Introduce nfc_llc_del_engine() to reduce code duplication

Add a new helper to avoid code duplication between nfc_llc_exit() and
nfc_llc_unregister().
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 06e6bc1b
......@@ -30,15 +30,19 @@ int __init nfc_llc_init(void)
return r;
}
static void nfc_llc_del_engine(struct nfc_llc_engine *llc_engine)
{
list_del(&llc_engine->entry);
kfree(llc_engine->name);
kfree(llc_engine);
}
void nfc_llc_exit(void)
{
struct nfc_llc_engine *llc_engine, *n;
list_for_each_entry_safe(llc_engine, n, &llc_engines, entry) {
list_del(&llc_engine->entry);
kfree(llc_engine->name);
kfree(llc_engine);
}
list_for_each_entry_safe(llc_engine, n, &llc_engines, entry)
nfc_llc_del_engine(llc_engine);
}
int nfc_llc_register(const char *name, const struct nfc_llc_ops *ops)
......@@ -82,9 +86,7 @@ void nfc_llc_unregister(const char *name)
if (llc_engine == NULL)
return;
list_del(&llc_engine->entry);
kfree(llc_engine->name);
kfree(llc_engine);
nfc_llc_del_engine(llc_engine);
}
struct nfc_llc *nfc_llc_allocate(const char *name, struct nfc_hci_dev *hdev,
......
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