From patchwork Sat Dec 28 01:14:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 13922237 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4CE66E7718B for ; Sat, 28 Dec 2024 01:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=r2hVzGwq/lGLJf/+SRytq7PzChhrqrxvhNJyvMgE8xk=; b=XpFNSBbNI4VQDdTlLuLuipDqrF BrEAq1InYbEE1YK0Z0d9Rvrd91B6u11nudx8OAJLt6QMOWW1hcw58JKAndBw1/u28RsPjo0YVq9mX /osjyZ2oAdLkoPt5/erxNoT7cpRIbPlcikZijevsZUJDNqK8acvfgu6EJiPzfb61X8JdolEjz1In9 Rdd5ZOtOr4jxHVqmC8Ko2jg36pMd2hvGyut88rlZMOMl6URM/nm3lbUVIEARbY/JpUwiUsAkayeop NYTQZZkT5WT4dEe9Lz3A7CV/uGOt1lJHriLNvVaMZ2O9xgBtHfk4qipzyudo6cAzGwR0wEW42JwHt xV2W2irw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tRLZm-00000001D18-02j3; Sat, 28 Dec 2024 01:25:10 +0000 Received: from mail-vi1eur05on2060b.outbound.protection.outlook.com ([2a01:111:f403:2613::60b] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tRLQr-00000001BET-0GhX; Sat, 28 Dec 2024 01:15:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tf/lEd8zbFuK3ibEDx9jGqHKWkgJpK6DF/FCgfeqrd7sG7zUmyFwL3fc6gnpkDM21YlngW8JWnpOvB7zJIlW/HcZBzWRDWjrro7Z6fCyUBbhB4pTS+9JlLPVVhQD5qeHaAv2zDN4lWzPXWino2KN7Gae1X0TOmkk+julNpYBRxYPyy07QljT+n4dKNqEbMAlleGve6i+jjAtIA4mKsQZW+OeQWqw+zw7HdKF2uwiN3NBukOd1VSm+9hGWkrBogitdExYj9ninwBPggHAAzEs/fFH1ACpiozxzaAaKYdjTsWj8GeS4AEuMVKd2nVd8/rlaWXkAuJ9h53jSS8GMERk6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VFg5y3TrIOn9VH/jNSFVTNtUnnNsK5iZCxLymVMVirI=; b=xeuBrPTlkMx+d+wO/drwBoY5rrdQS42JRT8bU6e4tmfMA/zfsYoX26wys/YQDOW/QMSIItfWaEi+otBczYTvp20XDe7A9Ax2hSdZNx53OShl408PgeZcbraw8IrReWVrA2Dtb8N+ZNpiYoaMiJCHltGMdUB0oA3PM3ipae/lttvgLOKlOUYOY8FezrfcxI4QDsISqyNa6X1Ce8bkwc0njeV+irhG3/sBHN8IxlswWxtxBafG0ed4F8PumFW0f9McwiKTWuib7HoSb8uDXWd19C6qzE+KCKRpyzlRRunWkt+qZH5H58OhQ3jQAhx0T+sd3CoQJDiRTSINal0Q4+tt/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VFg5y3TrIOn9VH/jNSFVTNtUnnNsK5iZCxLymVMVirI=; b=JboT+Epwb3x2Arjezq5MdwcMSqep2L0tWB1HYJy46fthtfvPQj16Pb31L6cNT4gmoJcp00zTTytgYNpf8UID/tnEBymbNtULU0A480vijRl3LWQbxl2LMkSHrIXCjOwz49gjKaLUsKo3SMPEqhxxbtZoQpCQy86w2qdmABnPaZsuSwCTsqv/2tf76WKQ5JfRZI7vBNomdr7wBLKpo8SkmqTe+chkGXGCXM4ep6Bqg7MgoeY2gZ5oWKrMRGHsxuhivncBxt7W0lMVR6t5KztVEDpXWfjUFKYA3+x9dYPKEDDgvPVagdsroJeCeYJDgP7HDyL4N30GaDsBOvCbUpQ6rw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by AM0PR04MB7140.eurprd04.prod.outlook.com (2603:10a6:208:192::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.15; Sat, 28 Dec 2024 01:15:49 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8293.000; Sat, 28 Dec 2024 01:15:49 +0000 From: "Peng Fan (OSS)" Date: Sat, 28 Dec 2024 09:14:43 +0800 Subject: [PATCH 07/12] rtc: nxp-bbnsm: Use resource managed API to simplify code Message-Id: <20241228-wake_irq-v1-7-09cfca77cd47@nxp.com> References: <20241228-wake_irq-v1-0-09cfca77cd47@nxp.com> In-Reply-To: <20241228-wake_irq-v1-0-09cfca77cd47@nxp.com> To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Dmitry Torokhov , Alexandre Belloni , Maxime Coquelin , Alexandre Torgue , Linus Walleij , Conor Dooley , Daire McNamara Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-rtc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-riscv@lists.infradead.org, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735348488; l=2071; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=VAulaoWVPhHtzgpO1nG1u9VR+bogAGzfLBxhdt2/l0I=; b=/Y2rJW+uvGVymldGjTdqHDl+b4ky/5JEFPBIiquUwbEeAm86Ox9gFX8XXPk1WjXf7BQX3ZFl7 EVH+AXBrsT4CjLNe6ykOi1b3V/H+/sq6s7NoLo4euO+l/d0xsKfEZBx X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0099.apcprd02.prod.outlook.com (2603:1096:4:92::15) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|AM0PR04MB7140:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a057b42-4d3e-46e2-a3e1-08dd26dd2a36 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?8kLL5PPXT4dfFka54uebgWFnIZSKyWj?= =?utf-8?q?P4+BR4ZriLrnznTappqcwZRvfZb23aDnMoL+SB9rM2PIEGCTe97CSSEXGi3o80aFr?= =?utf-8?q?NStM/DH0q5A5lYhAsOYjEaNvxHqZHK/IH8pExZkrhh7dLAvVUnRabp+Vs3kcdX7+d?= =?utf-8?q?hV8lBx2y1iZNSuTglElMIQ6y8BU5fgSD95m1e2SoWN6JAkZFiRJlPJHhZmv9HueHP?= =?utf-8?q?1/jKaO+uZlm4SRWzRARqA8Z5CycA2LtzV7bjt6XDewlEyzfa46LpK4pmhSvxilHho?= =?utf-8?q?mHC5CpjtSYUijpI/C5hp3E4ituEA4a8hRhMFrz1Elb2nmHOB7+MrcpP2aoj5iZ1V1?= =?utf-8?q?fkGXB9GhvKbbfxQcO5gSoNS2KxT/84WtMLqtYh9vaJzP/T/1mM8Lqb7sxZ0EJTjER?= =?utf-8?q?QDqc4zUMYQevfzcEy99g9lZbhUYw1uf5XVGd5pFJ0z8jZ463AFeMiiugdvZJjFO/5?= =?utf-8?q?nh9pq6s+V0XUdyJWg0Ul9ZurqKQQpcMZh16cpUmKG33Smz8p24DGKFdIUVNuDjzig?= =?utf-8?q?BcfLI+tFDrfIDgpI0CKCepIVeH3hKcsQkPGucJi5qNyOr2pQ30M9HNZXJbA03bvNR?= =?utf-8?q?ZV/BenINaAmGc63PPA5Xzf7Imiwx0OicwTN/ZbsQiVXwY4WUwsaoxiogiHnLJJRTG?= =?utf-8?q?6q5y1JQIf4vR+5P69pT0q35MrffYt5yNomoWke6BLxT7F4m8gBE60zk4dzayPbj9T?= =?utf-8?q?7mZObDCvKsokcbzYclXeBOjPbg5SRjGbQ4LfPIRWLYB36ePH90HqnhHDuqoqXUzhM?= =?utf-8?q?ZiIbPf/p9vOmIYL52jfp7qhYbrS9BF2L5BigKVZ+LUvtxodm1j3smgFRibdrkcehi?= =?utf-8?q?qUsoHO9M3ToNaz4ycjWcI/gC2dokMSl24aXGGWuzmCXg4J1k4yb8GY4AozBuTovhv?= =?utf-8?q?SGy0a945FvF1Q5t5ZX1lvcYgjW3nFDvW2t9tkoBWw4K36ZxJaYZ6DxXPBllW1u1ox?= =?utf-8?q?pTzCKLPVfP2MFBa1QTOMQeSAPNUeVod0uXHpcr5GHtwjJRfG7JGwiDCTOmffZTEw1?= =?utf-8?q?yujrAm8ueVl+pYBW5E1HYnB8Yjb6r5kzqAcfUnp8LI5s4fDwbe2x1YQ13CU/HXEJQ?= =?utf-8?q?fw90TIUFakJULCwOLtGKzB3eyL1iemMMIx/M+gydn88IWWPK0GsKRQefsOmx+CCvk?= =?utf-8?q?jVAR6w1gZYkuFPDFkMdD5UZsMUffLy6MWLWe6OEESnl65ILAfPOmjQe9Y6muzu1Dc?= =?utf-8?q?wGLcEHyUvCnrL7tBrXos5I4kbrTM8vEcYi0Fiufv3oNk/41+FROIqYMTc5ILePWc5?= =?utf-8?q?WY/Hl2YeE1K6DjBfsYNxZVCAkSnPoc/dA3XMQ5GtCyzIeTCYAmuwQ7wV5G/niRIvc?= =?utf-8?q?JMlcxAHgxcUhLX41CmvzsulwBKVH00B8vsRj/lgR44m4PjkIBcIv0bjmqy7cQ5IkM?= =?utf-8?q?IMdfnrQi6f0?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(376014)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yp3N0TJTTpv7BF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+A+9AI/gEtWjc+q3?= =?utf-8?q?kZJ1AUvh/nomf84HoAN2tc+k5eTMsE/EIPZab0UiLwQ0o2XMijtBT4jqKEaag6vlS?= =?utf-8?q?/UilEc/HCu+5GhxOaQmNAFdryo2QrU53/UIO0Kotey6gq1CQq68no1yww4GkeXS4l?= =?utf-8?q?iBno6+Z2JMciZggiBa8/zvnUpKrLqCDMKKy0WUrhbD3FXxVSPRr2e+vWlvgmZmG09?= =?utf-8?q?bhzodIRz2jNcoXFgQ4Mz4Z8Iq9aY2XPGzLbDhO+FAjdNOla8i96yitcIF7OFvQ0Lo?= =?utf-8?q?IATye/GeZQslz4VRSkseKpd8U4SV0u3asSugI49D9Q5Po0oNWfABd8BoJbiOCGupy?= =?utf-8?q?hkETCXdBAj4W3ORxqLFljg+WNJg1BZ1GJ4+csVwwds4dhshOn6WIz7BNxc6NJ8OGr?= =?utf-8?q?3nKPSJcB/eFiqX6ZC/8IO8Agsg8wtHiCFw/tAWXbXdvUgzx2KO4cNwqm8M19KOpOu?= =?utf-8?q?2p8w/5CB2KyyKfOSQzTP4wWpE3qNDVA1NPGRNPgEWxRqgdzS20gFZQMSm/5juVVNJ?= =?utf-8?q?9pu2ALQXjo6AgMoZ8Rqth6Q/3IyaG+HrTuqH/VjNbR53mhJepavgDGLyyZyPrkpqr?= =?utf-8?q?6igYO1YGFTqQML3hlgDSYSm8dR+hmUznY5Yztn+PK7ub1ExN8XmYqcy6UrOLmwIdR?= =?utf-8?q?ZQPdwUPiAF9M?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a057b42-4d3e-46e2-a3e1-08dd26dd2a36 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2024 01:15:49.5526 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 037cqaYX6lrRruUNEz7qXHqPSkrDbyK6Dt0fVNXUp1BYwzW6EiUo/aSAYpeURU39MuecTrPOjL+EXWPjkqZtVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7140 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241227_171557_113773_C08618D1 X-CRM114-Status: GOOD ( 12.05 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Peng Fan Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the error handling code and 'driver.remove()' hook. Signed-off-by: Peng Fan --- drivers/rtc/rtc-nxp-bbnsm.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c index fa3b0328c7a255ff8a902a58d61a4b0e59eac493..d4fc9dc583d317d4852b7d897a6c45cfff6961a2 100644 --- a/drivers/rtc/rtc-nxp-bbnsm.c +++ b/drivers/rtc/rtc-nxp-bbnsm.c @@ -189,36 +189,26 @@ static int bbnsm_rtc_probe(struct platform_device *pdev) /* clear all the pending events */ regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A); - device_init_wakeup(&pdev->dev, true); - dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq); + ret = devm_device_init_wakeup(&pdev->dev); + if (ret) + dev_err(&pdev->dev, "failed to init wakeup, %d\n", ret); + + ret = devm_pm_set_wake_irq(&pdev->dev, bbnsm->irq); + if (ret) + dev_err(&pdev->dev, "failed to set wake irq, %d\n", ret); ret = devm_request_irq(&pdev->dev, bbnsm->irq, bbnsm_rtc_irq_handler, IRQF_SHARED, "rtc alarm", &pdev->dev); if (ret) { dev_err(&pdev->dev, "failed to request irq %d: %d\n", bbnsm->irq, ret); - goto err; + return ret; } bbnsm->rtc->ops = &bbnsm_rtc_ops; bbnsm->rtc->range_max = U32_MAX; - ret = devm_rtc_register_device(bbnsm->rtc); - if (ret) - goto err; - - return 0; - -err: - dev_pm_clear_wake_irq(&pdev->dev); - device_init_wakeup(&pdev->dev, false); - return ret; -} - -static void bbnsm_rtc_remove(struct platform_device *pdev) -{ - dev_pm_clear_wake_irq(&pdev->dev); - device_init_wakeup(&pdev->dev, false); + return devm_rtc_register_device(bbnsm->rtc); } static const struct of_device_id bbnsm_dt_ids[] = { @@ -233,7 +223,6 @@ static struct platform_driver bbnsm_rtc_driver = { .of_match_table = bbnsm_dt_ids, }, .probe = bbnsm_rtc_probe, - .remove = bbnsm_rtc_remove, }; module_platform_driver(bbnsm_rtc_driver);