From patchwork Sat Feb 3 07:51:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 196206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp905185dyc; Sat, 3 Feb 2024 00:10:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IERLI7i9Yh60h2fhpzcuoKairi8POAMjHnKhOSv8vhp7tsCaBzYmSXtYVCXv4LcB+HCipEF X-Received: by 2002:a17:90a:d24e:b0:290:ee58:6549 with SMTP id o14-20020a17090ad24e00b00290ee586549mr7605347pjw.15.1706947802488; Sat, 03 Feb 2024 00:10:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706947802; cv=pass; d=google.com; s=arc-20160816; b=nCyJ6t2br8tZRyai+14FWw8B4YZ+rz6SdZA9tNjp7hmqH2sTgf20ZmTCnMHFCtBp2n ChorqAEq/aJ8uUJgy8HCiJzCV5KyUk0Ud1/O+4m9zlQEJ/YYtC3WhvYIqhhC89oAcl8y k3hHLf3KaZFDu+21gluW19RMMlS4HPDoPpL3pGFe0gri/tX3Xs5O+YTVs62C9BHaRLdv gN4iJcYN7diRGPkQnDcKwxgvcIKs6K3s7V8cRMER4yfL7PRen9DzfKZNzp7Pvrp5DldY INCqBXRy2szVgxdhepC91eUtTmanCdlpSoOoddCMStpBR7KxEVa8rXU7vh2mmik9D7lA U6aA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fjCBezS7CokH+7JLcr/hfWM+uGZ5cz/EMtWkOxCQIdQ=; fh=hlWebjSAqPaYj7gnZJreeYTlOxswT4B4yY86rfMXRhI=; b=JnsWNy80McJjTp+rF3bPNASr8lt7eNHSn8zTK5qcXqfpw1lgi/OPMr8+Hcv6Ne1GjL XLLkDGraji5cxxoPkjhsTFoZ08L9LtBjdu/NxUQBo/PzLc+MS8BsjX3Xua4t7X8V0/La J6W7jsyUSIXagKthGFXlXoO0YXHeuUKtnqn24fUXILuxP11R4Z04JkYNyEWPVdFAnS/f fqw083/gt69UhMTNrJqcIM7p4YNvf0UqBa3D+FUbaYG5FNz0w/OP1b/VQOhvqRZtRfIH i45ZLz6Nr50QRwkGI2xovqrJcvpn5os/ToS8bxYcPW99O7yieKhNQAi+Ih74hLHxYpfE pdVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=kWneXtzT; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-50967-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50967-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr X-Forwarded-Encrypted: i=1; AJvYcCU7HWRscBMza17A3dNITabj18xXjvgX7JThpqGwt/euDij4X1eeGltBpRBCbXNQDzPAC5mUyE5Y+pCea8Ty7PY0pt8Lig== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ca5-20020a17090af30500b0028da227178dsi1218851pjb.76.2024.02.03.00.10.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 00:10:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50967-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=kWneXtzT; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-50967-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50967-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 35D1CB29E54 for ; Sat, 3 Feb 2024 07:53:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8F1450260; Sat, 3 Feb 2024 07:52:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="kWneXtzT" Received: from smtp.smtpout.orange.fr (smtp-17.smtpout.orange.fr [80.12.242.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D1A74EB38; Sat, 3 Feb 2024 07:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706946752; cv=none; b=KUfpZo3hZVjGrSMhcNVjN1Jpi+LBY1PfH7m/g+zpyvMn9ZoJNLuNJ/H05MSzQNg1VlMxliuV0Dr3+iXYk2uZeA/37XOYL8pzME1JMDqwxin4PlJ4akluscqr6osOPe8G0P79Eap0r7jdDr/HFj0clkEwNt3KZnnTL4kb8E6gVeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706946752; c=relaxed/simple; bh=aObXlr/4PR6KuSz8tcT/d0388K6mphyDLXDR/dnQyDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EJuBBqKJsTpX9A2Hz7HVbqQ/wN7nJndAHQhfA4IuTKSeN+RWZDHL0Yk11kvhBUmObnkZNQ5CDclyg2yJzpHGy64db40O/TP3b1b/YNb/GqM7rrRAxhnmqSgoTHUkrg2GcLnk2t6c5jkbkFGN9cP/EBLuFlyrCDT8ch/MXf3kx7M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=kWneXtzT; arc=none smtp.client-ip=80.12.242.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from fedora.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id WAnwrvC6Ki8tRWAo5rII0H; Sat, 03 Feb 2024 08:51:21 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1706946681; bh=fjCBezS7CokH+7JLcr/hfWM+uGZ5cz/EMtWkOxCQIdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kWneXtzTmCFzOw/FUm8NnKkQd7Iw/IzgIyI9OnUrFuIkyCUysZBPxzSSHc7rCnzLp Fjo0vDrwv1+o0JQAK6tK7XJMUzCdZ2FJaNBDhFY7VqWZjSmQTcIkzexhjGiUyygQp5 iYTUCXnEUxtPItjc+7CG2+NFGh59KFIPKqTGGyKSNWiJwn2DtS1+BYrVRJhTl/3EnV X+gYEW8+s/BwowQ8bpVYMbXhj2rWc8ueMITbCV3FcgsJCKcaA94wP43ikE2KMFCE/r 2SboN1MQF6TknmG3CvtHW61z0kq5QVbiVkCQzCa3uZmCpzg3TczRjcY1OeWz5SINnA nhruBnB2ax0ig== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 03 Feb 2024 08:51:21 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: krzysztof.kozlowski@linaro.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2 1/2] nfc: hci: Introduce nfc_llc_del_engine() to reduce code duplication Date: Sat, 3 Feb 2024 08:51:03 +0100 Message-ID: <6d9a8544b923d92defdf2ab1b9092004cc7b51f1.1706946099.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789864498720136810 X-GMAIL-MSGID: 1789864498720136810 Add a new helper to avoid code duplication between nfc_llc_exit() and nfc_llc_unregister(). Signed-off-by: Christophe JAILLET Reviewed-by: Simon Horman --- net/nfc/hci/llc.c | 18 ++++++++++-------- 1 file 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 @@ 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,