From patchwork Thu Dec 21 08:51:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gan, Yi Fang" X-Patchwork-Id: 182058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp275690dyi; Thu, 21 Dec 2023 00:55:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfH76xD3SUQR3gxxLTTEM4hy/qiq6AkVrzjnQOAMSDNriXHQxNT0S4nWRkrT8sc0gNKTYw X-Received: by 2002:a17:90a:c38b:b0:28b:f0b8:8528 with SMTP id h11-20020a17090ac38b00b0028bf0b88528mr481337pjt.45.1703148948144; Thu, 21 Dec 2023 00:55:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703148948; cv=none; d=google.com; s=arc-20160816; b=LJaGlIp7QRQKb8TENzlKosA3aNF50lZhVq1aZOUmiS3xNZgS00i5oaVuBcbTLJ16pO x4IzEN4OWpkfIcnx7v13Nrq7xAliUvku3xpYZqQKtTf7qyKmKwXa4b5KX5HJpH9RQkeK GgyIRan+GqhNQLd6etHrjOuDRKrl+gdpSXHaZYFyDuX6fdKXfbcx+RoTA8h4xYL1pCyQ b7jg7jVnol+FbpoXBqGoV0KvmwEB7HK5c/56FS1+lYknY+JXlqE4Si550ohNBQtNz9jo NzrbHL75qUwB+xCG2QE6mXfJ+bQfe43XqJRN9CzSE+UKUFUD8FlAQXW7i+8JvBVxPM24 LXEg== ARC-Message-Signature: i=1; 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=L+o6GCmq7tM2Ck0Vm10phqrLtCgwxUapERIrlHE6tIs=; fh=JhCqbF4gKBTnfq5pCBXWHsT+mGI+wlxAlh9egES2Iko=; b=Q+qXtEoIHECL4nQvp1o9nj6hFDDN3EJ2Ct8AJPJt2y84srgyr8k2SQlcDzUzHUhGr+ 7FCVUE4lYKW7s5QzIKCUBmepxo4yYUJsKAox4ZISYVg9rYYq2hH4Afy/5mSDQRhu+Vqw jOfLFR53ne6oL3gBaTT3Q+d995o2AzwqpelZNUiN50bQI0TVfDnKnMGw9kEQcEJqTf/B zBLFKYyGFvbeMMdjnVP0hD+ilGhKsvQtQYtw2KFsmzc+Kn8UufHOXHkOwPFSP67hOH93 IEg5kjqoY7TbJPiC+SIz6b0m3YccKtexoFmAPxHLp6v8dOVMZ6XfttteJbeSuoMLuxmX 1lrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Mt+sTEfa; spf=pass (google.com: domain of linux-kernel+bounces-8025-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8025-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id r13-20020a17090aa08d00b0028b6f9f3660si4561321pjp.133.2023.12.21.00.55.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 00:55:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8025-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Mt+sTEfa; spf=pass (google.com: domain of linux-kernel+bounces-8025-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8025-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 71C792848FF for ; Thu, 21 Dec 2023 08:55:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 691083C694; Thu, 21 Dec 2023 08:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Mt+sTEfa" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53B0538FA0; Thu, 21 Dec 2023 08:54:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703148879; x=1734684879; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1ba7Ldspb0L81io7WDsMQs1X2A/thFBlYyfgOhF/Vgg=; b=Mt+sTEfatZuHk+IlePDpUOOnyVhjOkOfworYqugNOlqHob/DXbNeUB8g I4pd/u7Q44CF4D/AChwmvw76ZswXoOliwei352toJz+hxmyh2eg2yHocy hXgeiZPK97mf72Ho4xMaArBjvEpr+aPyiS/ubvG2hVl1uBJDIB5k8dUjc S7lZlycmwZzmdU+sG3Q7a+EyECWT06mP1IzkxfGLRl7JMg8fVRteK2G6O P5qYe4uesbC2vPKO/P35TkuJF8Wr/8Yn/DUMKlnQfR8f8GRFb/o6LjKb/ iJpIDNLFJsFkPAZVlAaz7Q8wvtJG2IKNOilJHXRS8AdoMrXQoED8lAf2i w==; X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="2793693" X-IronPort-AV: E=Sophos;i="6.04,293,1695711600"; d="scan'208";a="2793693" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Dec 2023 00:54:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="842568329" X-IronPort-AV: E=Sophos;i="6.04,293,1695711600"; d="scan'208";a="842568329" Received: from ssid-ilbpg3-teeminta.png.intel.com (HELO localhost.localdomain) ([10.88.227.74]) by fmsmga008.fm.intel.com with ESMTP; 21 Dec 2023 00:54:32 -0800 From: "Gan, Yi Fang" To: Greg Kroah-Hartman , Andrew Halaney , Javier Martinez Canillas , John Stultz , "Rafael J . Wysocki" , Gan Yi Fang , Jens Axboe , Russell King , Andrew Lunn , Heiner Kallweit , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Marek_Beh=C3=BAn?= , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Looi Hong Aun , Voon Weifeng , Song Yoong Siang , Lai Peter Jun Ann , Choong Yong Liang Subject: [PATCH net v2 1/2] driver.h: add helper macro for module_exit() boilerplate Date: Thu, 21 Dec 2023 16:51:08 +0800 Message-Id: <20231221085109.2830794-2-yi.fang.gan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221085109.2830794-1-yi.fang.gan@intel.com> References: <20231221085109.2830794-1-yi.fang.gan@intel.com> 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: 1785881111543243009 X-GMAIL-MSGID: 1785881111543243009 For the modules need a module_init() but don't need to do anything special in module_exit() might need to have an empty module_exit(). This patch add a new macro module_exit_stub() to replace the empty module_exit(). The macro is useful to remove the module_exit() boilerplate. Cc: # 6.1+ Suggested-by: Lobakin, Aleksander Signed-off-by: Gan, Yi Fang --- include/linux/device/driver.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index 7738f458995f..7d322eef501e 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -288,4 +288,18 @@ static int __init __driver##_init(void) \ } \ device_initcall(__driver##_init); +/** + * module_exit_stub() - Helper macro for drivers that have init but don't + * do anything in exit. This eliminates some boilerplate. + * Each module may only use this macro once, and calling it replaces + * module_exit(). + * + * @__driver: driver name + */ +#define module_exit_stub(__driver) \ +static void __exit __driver##_exit(void) \ +{ \ +} \ +module_exit(__driver##_exit) + #endif /* _DEVICE_DRIVER_H_ */