From nobody Mon Apr 6 20:13:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5A52C54EE9 for ; Fri, 2 Sep 2022 07:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235640AbiIBH7L (ORCPT ); Fri, 2 Sep 2022 03:59:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235608AbiIBH6z (ORCPT ); Fri, 2 Sep 2022 03:58:55 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F3A9BD77B; Fri, 2 Sep 2022 00:58:47 -0700 (PDT) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MJqvn4Fq5zlWh8; Fri, 2 Sep 2022 15:55:17 +0800 (CST) Received: from huawei.com (10.67.174.96) by canpemm500005.china.huawei.com (7.192.104.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 2 Sep 2022 15:58:44 +0800 From: Zhang Jianhua To: , CC: , , Subject: [PATCH -next v2] rtc: fsl-ftm-alarm: Use module_init and add module_exit Date: Fri, 2 Sep 2022 15:55:25 +0800 Message-ID: <20220902075525.379699-1-chris.zjh@huawei.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.67.174.96] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500005.china.huawei.com (7.192.104.229) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" fsl-ftm-alarm driver can be built out of tree, so change the macro device_initcall() to module_init() for standard usage. fsl-ftm-alarm registers a platform driver in module_init function, however there is no module_exit function to unregister it, and it will occur resource leak, so add ftm_alarm_exit() function for module_exit. Signed-off-by: Zhang Jianhua --- v2: - modify the commit message for more accurate description --- drivers/rtc/rtc-fsl-ftm-alarm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-fsl-ftm-alarm.c b/drivers/rtc/rtc-fsl-ftm-alar= m.c index c0df49fb978c..28bdc6c97b64 100644 --- a/drivers/rtc/rtc-fsl-ftm-alarm.c +++ b/drivers/rtc/rtc-fsl-ftm-alarm.c @@ -332,7 +332,13 @@ static int __init ftm_alarm_init(void) return platform_driver_register(&ftm_rtc_driver); } =20 -device_initcall(ftm_alarm_init); +static void __exit ftm_alarm_exit(void) +{ + platform_driver_unregister(&ftm_rtc_driver); +} + +module_init(ftm_alarm_init) +module_exit(ftm_alarm_exit) =20 MODULE_DESCRIPTION("NXP/Freescale FlexTimer alarm driver"); MODULE_AUTHOR("Biwen Li "); --=20 2.31.0