diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2024-02-03 08:51:03 +0100 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2024-02-06 15:36:06 +0100 |
commit | d6f4aac19ad44998c6b1cde0334ad76900136ca4 (patch) | |
tree | 814979cc2d01eac5cf80a3781f21606635d13bf0 /net/nfc | |
parent | tipc: rename the module name diag to tipc_diag (diff) | |
download | linux-d6f4aac19ad44998c6b1cde0334ad76900136ca4.tar.xz linux-d6f4aac19ad44998c6b1cde0334ad76900136ca4.zip |
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: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/hci/llc.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/net/nfc/hci/llc.c b/net/nfc/hci/llc.c index 2140f6724644..480c17f372a5 100644 --- a/net/nfc/hci/llc.c +++ b/net/nfc/hci/llc.c @@ -30,15 +30,19 @@ exit: 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, |