From patchwork Fri Jul 21 09:46:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13321742 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 32B64EB64DD for ; Fri, 21 Jul 2023 09:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231958AbjGUJtX (ORCPT ); Fri, 21 Jul 2023 05:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231920AbjGUJsl (ORCPT ); Fri, 21 Jul 2023 05:48:41 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2103.outbound.protection.outlook.com [40.107.215.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 842BD35AD; Fri, 21 Jul 2023 02:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cl6BYj2ZKDT13HtNKI9yGBhjEtIAiezQo3eg1rPA1STUYfy90inWB5xHGvcSs/WXuXOGaq53OoO3hzYBQMnlygCUhdijnE0K7qd2MCGhMOl29T0GqzzdBvyPIIKF8HMYeHtsxp5VhMQxEkzkvdV8Fsbvb63LlIDfoAgRw0Mr+z4bp9/XqyqVHpsN2jy16XU2LB62e359LpRPXusOw7Nh0nsiVOT+4azodiVqSvzfPUIdPsQw7j/EqWYihDNHthwgxl8nRo+nynxaFOuAJj1P5+Z7Xh5ghMOJ2sXVIS+U4yuWUcFGPxktSbHGCyn0X2i2LT3eaTulSAD56Dv3PTIyvg== 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=U7xJSqPC6R6oyLUW7A4Grg9gjrzZA4zR9DzCNmCHg5k=; b=jq8eToF4MZRlz/OyWTgVXDOwilmP70wYhKfo/zktwWJ9b9tVfFcb9JPo0VIeAF8OkJbhVgfRTvsLwC+xcec2d3ix8Mz+I+63NKMlyd+1/XsFvLPS4z2OlvOW8v1V1/dKTaPdwaK12okR96ePMrHu4sqamIAXx14KZfFPXHgDbN2qkNIzkhrsUcGzzsV3+vxGhg42uZT7IS0lbnbPJarZG4D4xV3gyLuaStUcchrKdTK1adQZ1dJQ7AAXd9Y+K6bP1alkwaoerIpR+6GCzVzyJZmIETkwiGyIbLN2stOdHVyYqqpXv3eRQAhMXYEj5Ax/8+5seLkHFaaMNPssxhwe0A== 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=U7xJSqPC6R6oyLUW7A4Grg9gjrzZA4zR9DzCNmCHg5k=; b=Vfg0VrrWIQ7lE4EPXt51RC8KzvDDG6MXA8DOv8YPcr+6tEMh94myt9tTymy2jInrzEaW/1dsbqIhDo5ip82QZjmybaJ9CoHMUWDvbsXum4fPu5lZaXc6J70caWWl5MbjY3/9Sb9quK0kchmra2kx0goOZOFb5nOTWkYdM/7SQ6xPf6wImoWLO7nF1KdxzTIJeIu0kiqQdulvSh5XT0C0bps4JH+lrZWw44srL1HwdtK+pqP0Zz/CGXyKUTmWaPc0sRsTtZ8OSEq0Gr4zi38Y0oS4ZfZfENW3EqE5OTtslAm5x6ydMF4pYb1xBOTNeRAerLXaR79XHlM1lwpzthmVuA== 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 SEYPR06MB6311.apcprd06.prod.outlook.com (2603:1096:101:13a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.28; Fri, 21 Jul 2023 09:47:43 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::732f:ea1d:45a1:1e0b]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::732f:ea1d:45a1:1e0b%3]) with mapi id 15.20.6588.031; Fri, 21 Jul 2023 09:47:42 +0000 From: Yangtao Li To: Amit Kucheria , Thara Gopinath , Andy Gross , Bjorn Andersson , Konrad Dybcio , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui Cc: Yangtao Li , Thomas Gleixner , Krzysztof Kozlowski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Jonathan Cameron , AngeloGioacchino Del Regno , Dmitry Baryshkov , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 19/22] thermal/drivers/qcom/tsens-v0_1: convert to use devm_request*_irq_probe() Date: Fri, 21 Jul 2023 17:46:38 +0800 Message-Id: <20230721094641.77189-19-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230721094641.77189-1-frank.li@vivo.com> References: <20230721094641.77189-1-frank.li@vivo.com> X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SEYPR06MB6311:EE_ X-MS-Office365-Filtering-Correlation-Id: b39fc405-4e07-4457-1c11-08db89cf8784 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OzMUkSUhbywZQpA3N8ZR+aY4fuifa+oAlXbD0967Ts5nBmreNKTjHsJCNKlboBzljeZyZJd4KNbSAGg7vBv4pwqBkeZoYtxhAAo2rHPx0TWQWIk5u0FUUEqXB+QbnIb+ICfcnp1YboQWKuvqWylNU/dmop/1nkHAHHhtcb76zcJkqWSar49plXTHBqhv53kpI7W0ROTC1Yb9sbFkpPR1nEhANfKR+0HI4MseKbrDJCDuZmTSQtFhG598NdHAtdToiwH61f8ANlFCPZ+zgr1muC6lhUlA1Bg4bq+4nTqRMhM0yYe65oQjVtHrCzAWeDmNtuinIHfczxjMaKpWWJMiDENpo187Rdw1s4gPk2Vu/0uMAC9MqIIIodG5KAnT/voK1UB/pe4ssSbMASN312e91xBbjRX9smShEWCD0f+YsOF3DrLSL3/oEZMimvHE0IFn7+yukiub3kgZy3Gaj82qYHJNUBHX2enJW8kBIGab0YOibhoLPH7vd4BuwEVWCmNNXw4JTJG5P5bDdniCUtqqxfuhL2YzYQy1249ktZ0FjCjSErgGgoR9A7u+Ld21kj9lSZR1MQ+CIRLdy055mXRJy1n+3fti8G64G4lABWrARxtElSiZdxsH/eq3OEJbxuwE 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)(396003)(376002)(346002)(136003)(366004)(39860400002)(451199021)(54906003)(52116002)(6486002)(6666004)(478600001)(110136005)(6512007)(186003)(6506007)(1076003)(26005)(2906002)(41300700001)(316002)(4326008)(7416002)(5660300002)(66476007)(8676002)(2616005)(66946007)(8936002)(66556008)(38100700002)(38350700002)(36756003)(86362001)(66574015)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?c3FJWAOQkscS3nq1q6u/QcueG6dj?= =?utf-8?q?t3+RVDw061xcefO0B28MxbteeuiTo0G0ch/VBLuQZdRzsS3h1CW5rsAvE5jMa5jbF?= =?utf-8?q?EDWsZ9e5jx5y7ROcCvMlpjkmb3XFGPacRmA3Tx4Iq2hzBdWE0lN+niwduSGZgcZGv?= =?utf-8?q?+hVxuby5cuQXrIjaV8CX5TGUhbrFBlglyfO5ivy4lvR+JJyETmz9cyP/vQrJA9ubw?= =?utf-8?q?dDiksG5pyClq8chw1jJVNsoXyswibjr4t44/jU3qRzCq5ysRjx0ymsVpAef/tE90i?= =?utf-8?q?qKafRSBROIBQBmlVMo0qHUAUFcow5H5vniLabVCvEuskJczisG5USrW7IKe0vZJCd?= =?utf-8?q?klMTjCObmu25YikDQXmwGbhnq2/Xfo3V5WDqmv1slmpEXr/54XqY6VYlQ33Si1yDH?= =?utf-8?q?fuDFj/yt1JuWVAjVFjevWIrHBOZOPlVHWh2Gb3xlZJz9SG9r+qJICl/XYU7gpPcje?= =?utf-8?q?rHc00GpDC1Mb7biz2oDIJ6oUsOJoXz3fR+f9xMWmOdCL+e8SbafGSHNN3OXUg1zsn?= =?utf-8?q?eS14hr++EVESJEobsNuZlIsBcB/jNFc4csdZy/k73BkIY/OjD/CPNbE73kkr2WH0r?= =?utf-8?q?Mmwt+L790hsuimzkGxZRgk5mP66FvQYcJOeO0/xpzRWKn7Gfuv+FxgP34nSMdf+No?= =?utf-8?q?5UArcJ/DhLkPbeg+0OfOvvuN3ylAitFVDHKSixQG5sgJm1s9fUqaQKgoRs6DU/qUK?= =?utf-8?q?1saKk6bKhW27p1hWbuTSiHji2O8rGVY0BCP7spNsJ0LGleSk56CKFd9Wldrl7WNjD?= =?utf-8?q?7dnKqKBH6H4P0PlRPpkl+iApdZc2B4pr1OKRlixPDX6/2XOGT98X7EkXAK5OzO9LU?= =?utf-8?q?F5zVkCT6mm6aEEtp24OJjRFxR00WNQ9MOrUSZqsnRbT//fho3nNiWCG/skRT5ZabC?= =?utf-8?q?6NXtJOMOkojLDWq3DWjMuPzoisEZIGMqMGcqv8e6gl2DsEIEHr4W6J10ip61l78n0?= =?utf-8?q?OFkRi5wxQq0tgSzeCbnt5Lx3tjCaW+zRMiat+tW/KA/2a3WCQbUpqvEtQ5R5ywZJG?= =?utf-8?q?G7pqhD933R7+qyurooZGBPzWf4axKlxkS0gbVeGnOJCLmDQNEPjzicAC7mAT8dbUs?= =?utf-8?q?oYUaJbVa9ceRDY7nV6z5f76Kr/BvMqh98jcf9k4fMxiTZ0O9UBET4PbwL7FMgQj0Q?= =?utf-8?q?pHvuq5ifjhqJmcKX9n6zZbd2TlwXi4t8/hgKIIL/w0EIU3kJmCHyBn77911o9vwLR?= =?utf-8?q?z2gOA7Kq/wgvNG2sv30/P7sCfwgrElJQ+g+51Oss1kg0EQl4+u1LiuxYKCeyO2TvS?= =?utf-8?q?yY4K6gbqrS/4PwvAHoK7Dz6tf0nkry/7K1RsCzky1ChiIqKx0Brg+tNOMDsUVSCtQ?= =?utf-8?q?BHue24JtVaC+6paVLMN3jiLClQa9+sl0FUJ1sQXuc8XMe3jKOH3Ug9bKj6hoeYuR+?= =?utf-8?q?9LKxlQWKb9GKn1VopTYPH4IRQ3xiDspU3cY/Nm5SFCzLfzWV1zk7cTaQdSkwNcbhC?= =?utf-8?q?H1tOBoSdqS8sTjlGfGv9p97MdOuvfwg4SMuMVJZdJOf16KecCpI6B0sKQyfCsThMk?= =?utf-8?q?US88D6r3tJuV?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b39fc405-4e07-4457-1c11-08db89cf8784 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2023 09:47:42.9298 (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: vRDRWDI9cXvvvsa57ELLKLgSYKtxp3ZD32Bm1yRVSh5N4a+si+9iS+XECjHeHa9rTBmUkXIsaOsXamLXH9mkBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6311 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 Reviewed-by: Dmitry Baryshkov --- drivers/thermal/qcom/tsens.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 98c356acfe98..d4528d36c085 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -1171,21 +1171,18 @@ static int tsens_register_irq(struct tsens_priv *priv, char *irqname, } else { /* VER_0 interrupt is TRIGGER_RISING, VER_0_1 and up is ONESHOT */ if (tsens_version(priv) == VER_0) - ret = devm_request_threaded_irq(&pdev->dev, irq, - thread_fn, NULL, - IRQF_TRIGGER_RISING, - dev_name(&pdev->dev), - priv); + ret = devm_request_threaded_irq_probe(&pdev->dev, irq, + thread_fn, NULL, + IRQF_TRIGGER_RISING, + dev_name(&pdev->dev), + priv, NULL); else - ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, - thread_fn, IRQF_ONESHOT, - dev_name(&pdev->dev), - priv); + ret = devm_request_threaded_irq_probe(&pdev->dev, irq, NULL, + thread_fn, IRQF_ONESHOT, + dev_name(&pdev->dev), + priv, NULL); - if (ret) - dev_err(&pdev->dev, "%s: failed to get irq\n", - __func__); - else + if (!ret) enable_irq_wake(irq); }