From patchwork Mon Jul 10 09:59:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 117808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4921303vqx; Mon, 10 Jul 2023 03:24:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlFBo6ajfQZtIEgreAf8m6XQCqQAYUYIS8n+tfQKD9i2joUM53bxtT/WPVRWyhn1oq+1/nzg X-Received: by 2002:a17:90a:d704:b0:261:326d:99e8 with SMTP id y4-20020a17090ad70400b00261326d99e8mr12418881pju.2.1688984674934; Mon, 10 Jul 2023 03:24:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688984674; cv=pass; d=google.com; s=arc-20160816; b=n+ANQA6NLzfDNWG+sJMEiQmBrl/kqcvurELUdmNXKn+oGoW0N1p0IBxnITEpFXP+35 Lx1IOoVHKK0v7/FXPeJMmSQ7F8qrpSsNhuXsu77rpw4E4qEN8T6yGz3fSdXdZE5RpAQV F3uJa3ajpI6ApVQv/mzPc/ssMsu69+Gce5reHEoEkpVoyr7fHR4KkBKcb4APZnWYDjfS AS7vyBrx2jaTFBbcq6QEfVAIRJwVRu9TwIsyuQjd7Ia3h8yQSBiwbljzAzZR1LlCU3nG uyh0+yRrLpA01LSoryw1PV3U+7sHSBVmxUuhTtPvOoIv15qfqyMG5piMVlC5i9nfWV4O Pr9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fIbTe94tJb+c7Hut//D6DIRJqgxdHnLzwdkufWRqizI=; fh=hJWu5E8n5R01lKxwZtJh1RYO5G8RLxFZH+3ru/WgKGQ=; b=wTDwqvGz1SwEv+l+ZQVRRiRZs6Ev7PCsAC7CaktCMlKl7S69oIafHpHodf5wRUXvMJ wAw1djE4pnZanJOCAdGL3OdqwxhDGOty6D1WyRq4L5Wwust99PCVipwgqjveVFlHTgvX YpSASjc8JQ79u4VqwxPZYH+sfbyT0Mic7AbSI3HzABhlMLeDSUHbYZGUs2pHp25a4foP eYXxydfs80qpM5f64jAmyiIGGrTAkgnmtLdOyc15qFXMYdhQ9LvOXQZfgn7Dp53A7LfD RBPS54GAqaOJiozrFgBIdGF45nZtjybFumOliFQe1RBq11QxYOxRsnDCI5SSvRb8Ik2Y J7LA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=XYzPUgGW; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a17090a718900b00263046538e1si6973552pjk.84.2023.07.10.03.24.22; Mon, 10 Jul 2023 03:24:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=XYzPUgGW; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232704AbjGJKEw (ORCPT + 99 others); Mon, 10 Jul 2023 06:04:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbjGJKDU (ORCPT ); Mon, 10 Jul 2023 06:03:20 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2110.outbound.protection.outlook.com [40.107.255.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C6CA3A89; Mon, 10 Jul 2023 03:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KAE2w8x3Gy4WHLvpmjKYRA/8atOxvGzsEshR5sQb8ltMJFG/TbcDmw/Oi7RCaa2XPSLcMdy0lDzcYnPVr6JdJn3HpISLLC/WNppb0xz0UzRkII+dRi/POHrRaLpKxSihWtwSRuw9nonZVicK7vRoalRkpMDAmhN+hb6R2I7wAaxN9F+1L7pqIqYWj9n5yHr3aD0TuXH+LGaZ0rgA8tAzHIb0AX7Jge+yQWWHh6iOSipOt9fi+wy0wxUkWMqTqZvzuX5cz0D5qnKYzZp2rFn0BS3wopeH+Pnt4BSE24HsL1RxzkCqj7iqr1e6X8fVA3Ppx+wcTW8OL1yCwp9ItZ4FUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=fIbTe94tJb+c7Hut//D6DIRJqgxdHnLzwdkufWRqizI=; b=YgzuHLhDny5qo3WJ46Z60KENYJOUM5a/kE9LLplpCN+it1aQuEC0mAWNI9bCowFfo0YI2tpLIpfW7UUN5bmAJbt+1VvtD54zHfNBNk/yTbmJ3zNaUxSYRmfoIntGQ8yPTPiBgF7PHX//GfyT0e1d715SdjxV914iJ4fLltexRcoFqa2n45qLDYZC0v/WnCFZUlRlPcejA/AqDzIczp4SgROUgMnq5eApL6Qmt0WBRGoH324IBnyMUJJiIaTuRo0yi6pu2oWHD6p0cdEwgo6NBMfeMdqX3qXl8X9Z0RcOBBsHVb6DHzjTYgnpsTLGlV73gn2rdTBEeanUcvvbXH8mPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fIbTe94tJb+c7Hut//D6DIRJqgxdHnLzwdkufWRqizI=; b=XYzPUgGWsLIsbgQ8JU3nI5zGGZqlK2HwSdaopqrOyHPwy5L1ZiMadso3bfvNNcab9pr5ap46KSIo4FhkQoqJs842DwW4jTeQUxdG51jfJNpvov5wjqamfpftzyCOmvD44bNHFn0c7LSJYSss/BAWcaWfEYIwgQ4/suEJmDra2LimhtW1G1qvG6n9gPGaJ2jNWSx3A5raFHgsXUwyhccZ4OHwjmHN+ZsWVQICuptp7OlUI4PKhIIOodwviROa4hsgA5FdYPj/j1j1IL1ZMjAIEGj5oSbuRp8BdanAlAuZg2weaY1sKlZ4iwEb339zJBRE7Wy9k1QrZpcvqaM3D1/ssw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SI2PR06MB3963.apcprd06.prod.outlook.com (2603:1096:4:f2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Mon, 10 Jul 2023 10:00:36 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%5]) with mapi id 15.20.6565.028; Mon, 10 Jul 2023 10:00:36 +0000 From: Yangtao Li To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: Yangtao Li , Thomas Gleixner , Krzysztof Kozlowski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Jonathan Cameron , AngeloGioacchino Del Regno , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 21/21] thermal/drivers/imx: convert to use devm_request*_irq_probe() Date: Mon, 10 Jul 2023 17:59:25 +0800 Message-Id: <20230710095926.15614-21-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230710095926.15614-1-frank.li@vivo.com> References: <20230710095926.15614-1-frank.li@vivo.com> X-ClientProxiedBy: SG2PR01CA0167.apcprd01.prod.exchangelabs.com (2603:1096:4:28::23) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB3963:EE_ X-MS-Office365-Filtering-Correlation-Id: 111c1420-0d5f-4fd1-d28d-08db812c8218 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aaFCJ0GRr6hEhIaAfDsPP/NeN8f0IPCndZLvjGyrzyX1+6U29QLUR1YJre3A2mS7jZn4h5xu0Yv3iCUoNIZAKEk0zWZYu1opBf1pRxUydcAWIpFRC1Zq7RgYdOkNo5zNx3VNc5bxe6zRrR+eeWVElUUPiyioMq0pRnEzMBn9+NAIIUq+1s2Na29msxR8B2MJ6/hnty8Yh+tcnpT8iqKgjhxKsWULhET9Vd85wPxDTdRa58pHM/jLGycgk92lw714SvxehZIitnBovYbhn2XoDH/hfVJw+lxsCj+Z2IMzNjNU1W34sEycP3LEyZnzzfDh2n7a1DP249mIqZ71ULS6/pHBLM2uiT8izUfcj9bzlYMia7V7HfY7sDLN81bwuiqul7neNT+KQuHMEr16UfDVP02ae6NdwpKmFNhNUGg1BkCDDiA9xRZxWoDtjxgbbWPxa13Ycz4gpSnpmzxldaBtgIlNwah/iVUbFobUTBsOqERUNIGZh2nDkbx4UtlT8W0AYYWhzWtdkL6YL+QiPeLGhrrOx4XGE6l0GB1fEuqQ+2Ltmu4oQnqowVFQ9/14/AaEbLz+YwWEs6d1+emT3gxY2t66v7M0HVsXclIVVfLQyDSSDExqr/AglnEYALKCNjVJ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(396003)(39860400002)(366004)(376002)(136003)(451199021)(86362001)(38100700002)(38350700002)(36756003)(6666004)(6486002)(52116002)(110136005)(54906003)(6506007)(26005)(186003)(1076003)(6512007)(2616005)(7416002)(5660300002)(2906002)(66556008)(316002)(478600001)(66946007)(8936002)(66476007)(8676002)(66574015)(83380400001)(4326008)(41300700001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?WJo4Lywmvhp/Gn0HlmJzU8pQtdTd?= =?utf-8?q?kPzt8SEEy00Y9p6uMAlGljFwyLUq/lr75zdqbbI/wI67vWjtDllPMia2idK8/CYG1?= =?utf-8?q?bn1jjXuWfL6HsJyz6amufcU00qTdpeY8/heg1SyMhCNS+QdBMAc0vhb1wDDrrB6Wn?= =?utf-8?q?d/juhe9jN6MV3Su2HPTHMUeOFS0VIrmSDWVgK7FNh9NPf7kSEhjVLIyiHjhCuRE8/?= =?utf-8?q?/DIobfanWw00M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6aHiIITQeVegRtKr9lbOpRGWdTiWTlVoYsB4aWDXipnXfmlDJBReXQHUM?= =?utf-8?q?f7QNOc7Nt7D450EPu4hnenCJoj/lzHFJyZZNbO12cOR5bGi0OHjgEsm5Anmmj/H1v?= =?utf-8?q?TiKXikUDV/a1GYZJ+ihbznvL+ivS6Bua92TfkJ7lJ3h8SQGJR0hYm2Qpx5puqjvyr?= =?utf-8?q?TeuF3HOQcl2zDYEomOz5Fkupuv7CC31rrXWzKW4KMpYS6EMurk9fsGOtSE0Haj9jw?= =?utf-8?q?QXJxmEiDWmY/74R2sIPPR6ZW5BbyHmfmxu/PfsSjn777ZaesvPXvlPFCtSCK53JYd?= =?utf-8?q?PfFXrD+qVZbKGNAuteorR6Zy1ft63WhjBe+8oO+/edoOz63OO8JcMGXS3ll6LiNu1?= =?utf-8?q?pJ6yi7YSVQCTF6QTxrnQg5qgUGyZ9prqDmun/R8dyHUmDImY31ZApPCyDFAYxqB2b?= =?utf-8?q?gulsgs5FV8h3?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 111c1420-0d5f-4fd1-d28d-08db812c8218 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 10:00:36.6174 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +cGO7Kwv0BXLdlMBL/xtRPe55oefXmKqxUPwmDA94Aw9tttQH0I4Mw31/DauTr1HOWvRYh/awEi6YHVgzva/pA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB3963 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771028794661836380 X-GMAIL-MSGID: 1771028794661836380 There are more than 700 calls to devm_request_threaded_irq method and more than 1000 calls to devm_request_irq method. Most drivers only request one interrupt resource, and these error messages are basically the same. If error messages are printed everywhere, more than 2000 lines of code can be saved by removing the msg in the driver. And tglx point out that: If we actually look at the call sites of devm_request_threaded_irq() then the vast majority of them print more or less lousy error messages. A quick grep/sed/awk/sort/uniq revealed 519 messages total (there are probably more) 352 unique messages 323 unique messages after lower casing Those 323 are mostly just variants of the same patterns with slight modifications in formatting and information provided. 186 of these messages do not deliver any useful information, e.g. "no irq", " The most useful one of all is: "could request wakeup irq: %d" So there is certainly an argument to be made that this particular function should print a well formatted and informative error message. It's not a general allocator like kmalloc(). It's specialized and in the vast majority of cases failing to request the interrupt causes the device probe to fail. So having proper and consistent information why the device cannot be used _is_ useful. So convert to use devm_request*_irq_probe() API, which ensure that all error handling branches print error information. In this way, when this function fails, the upper-layer functions can directly return an error code without missing debugging information. Otherwise, the error message will be printed redundantly or missing. Cc: Thomas Gleixner Cc: Krzysztof Kozlowski Cc: "Uwe Kleine-König" Cc: Jonathan Cameron Cc: AngeloGioacchino Del Regno Signed-off-by: Yangtao Li --- drivers/thermal/imx_thermal.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index a94ec0a0c9dd..3131a09f9906 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -746,13 +746,12 @@ static int imx_thermal_probe(struct platform_device *pdev) if (ret) goto thermal_zone_unregister; - ret = devm_request_threaded_irq(&pdev->dev, data->irq, - imx_thermal_alarm_irq, imx_thermal_alarm_irq_thread, - 0, "imx_thermal", data); - if (ret < 0) { - dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret); + ret = devm_request_threaded_irq_probe(&pdev->dev, data->irq, + imx_thermal_alarm_irq, + imx_thermal_alarm_irq_thread, + 0, "imx_thermal", data, "alarm"); + if (ret < 0) goto thermal_zone_unregister; - } pm_runtime_put(data->dev);