From patchwork Mon Jul 10 09:59:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 1805645 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=vivo.com header.i=@vivo.com header.a=rsa-sha256 header.s=selector2 header.b=G/FZpuu7; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4R000l1wfKz20Ph for ; Mon, 10 Jul 2023 20:02:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232608AbjGJKCK (ORCPT ); Mon, 10 Jul 2023 06:02:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbjGJKBu (ORCPT ); Mon, 10 Jul 2023 06:01:50 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2116.outbound.protection.outlook.com [40.107.255.116]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3258A1FF9; Mon, 10 Jul 2023 03:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RdQJlTPCm5RPKWhGimlSoyNApw2ykcu1sblHHSFP1fWiOnyblNmJS5ufA6+xPIXGapgnTi8DL9PIMiSo/pspdzmYEe+fkGbXKc89fc1YXT+74JcnyH5BhrextoxlEz8gYZ9x7JMDFt3be6SMlzr+BoSH7/uSN784jgUBDlFLxVCADZIeesakOBSIh1oOZdNBmk+3RI+LjQqBAvevD1IlRO/up6MOZ+qRV5Vayq7I3IUpx9Zpbyzb3PfESuJTIZJuuqk6+4SNg/8OicxKkUR7QkEbprDw4aSRVxrHD9IHAThGtOJIESXiOxVq0AfGqhu3NaRVyiJ3wKgJqPio/oSQqw== 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=s1Hj3E6IG7zyG8szMhWXzr8YNPdDsgk2wzcCR+rFIBw=; b=fZ8QW75IkyVcHwdNSo98YUB8RsnOtBEyHbeo0zQ6HwPt6sxm+/jdrUahBwgeETZaug34/0cuc+03drNHKkHf8en7DQw9+ypuZRIbAdiRkV+JGX0ZtRXTKyKUI/n9jZjj+q7XVHA9CRU+fHaGkHJErJ5OXKub6GBUh1mmCYavc9Nh4uC54B9xEs5cwCViwzc/z5iSBAOYnaYsMm32kCKD49fVQc9xr7dAMFFzT6ltxSSjh/w90vYVT61gzfaCL9O14uy6hhnXXG+suB0XRbqSNK89lgbf7cUXYDkb+kvACO6BTrDmXa0Yr+S+nmvz9wTrt268d8cNUNWvqvkxshG5NQ== 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=s1Hj3E6IG7zyG8szMhWXzr8YNPdDsgk2wzcCR+rFIBw=; b=G/FZpuu7p2k52nGzYZoE8R9SWMD7B/GluQFwhKfKdVkyZV3R/HpN8tpsyV9r/72yYVeXGHQ+fOPE1WzpnCclymlMOLH77JhnL+hBv8EbCe9V9JfS7klDEfMejm8HVVi1YjpW1WCJdofSAOT0mXNueqHGudvcEzonBZRrCu6NwtvabBxO+mcNSZLDQEl+kBZsIOn7niAalQAjqOCEBKLaPVyf5clmtWd2imzi6pVRcubyQ9tDSIXmkHFQYR68KhiiLqXDVAqETrA9684Fmn9JerfrAbTrhBVTrPvdzsz+haLVMh0HqWLmxueAmWhhrxjhNbr6BC1VlGu8Bnn6/sN5aw== 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 TYZPR06MB6096.apcprd06.prod.outlook.com (2603:1096:400:33e::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 09:59:50 +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 09:59:50 +0000 From: Yangtao Li To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Thierry Reding , Jonathan Hunter 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-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 05/21] thermal/drivers/tegra: convert to use devm_request*_irq_probe() Date: Mon, 10 Jul 2023 17:59:09 +0800 Message-Id: <20230710095926.15614-5-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_|TYZPR06MB6096:EE_ X-MS-Office365-Filtering-Correlation-Id: f0f2d4b8-600b-4955-a69c-08db812c6699 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BfInYk8hT9Mjqvc5dwfZtA0Vs9wI5MX8qXTCcE2Rn0EFqHChUuI4+W5PxcGferBrcOioI2qYOMUbTum7QULK7hE8ilPVNgoXBvKiSckfJ5Hftx9fTdCNDws8tR0APO92r3u8CSG/b0oRDHrjdk+JpOLsIXyziNlyxcWj82zWnmMv4zsqy6BRYt5Yr8UATmzkxjz5nPUhREBs67TgwDk6RDGrfJkso1f20gV7lscduucpv8avs6+gQoBNrfjwLUQKQz+wI67NuAvpkhdYffZWPkY0pS5k9deD0i/jYFP6qqc2LaoOvLT9G3BfoBME0B3B6lOPnRC+eNLQ8DTpAG2XefaX4Vrc9pY379sLgCG+VrcFG/be/r0cND+BIkrzJvXlesUfXTjtCcW2YoGvOwG3rbyJ3SaVQM3bgAILhX7qTbhHUrweUUHdNMSwibTY6qB3qv1HsCD7Y3sZ9XlLeY8/e7XQrpPzeFOzomtlUQiGQ7l0FwcZGYVYHmmQ40fr+opiFQki8jjO8qSBTQa+jqCh54HjNtI74KHmKDuslpMC+297in9O5E1yVFfm+jBHIRQUULX578COxN8azLrT+zoF+Yl1uZkA2itW+miK+lYIjCUgUAf+juQs+0V+2RHlhvZh 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)(376002)(39850400004)(366004)(136003)(346002)(396003)(451199021)(186003)(6506007)(1076003)(2616005)(6512007)(26005)(66574015)(83380400001)(41300700001)(4326008)(66476007)(2906002)(66556008)(316002)(7416002)(5660300002)(8936002)(8676002)(478600001)(66946007)(6486002)(52116002)(6666004)(110136005)(54906003)(36756003)(38350700002)(38100700002)(86362001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+vuOITZrF2u3VCeF2uTTNxMtdeEX?= =?utf-8?q?UGpf6oezNT5bskzsNBiVHTCt3Fk+1NgH4Usft5oFC2xbGbj9qhu966ahTQ5J3JMMI?= =?utf-8?q?8PJKEwVnDzjnKe9Lq67orU4zPUC2KvMmLau4kyPO5qKz//X1BVe+utzuMu3jSZWlI?= =?utf-8?q?JGwX4Ko8hBb/7VzMvNBC+UQQmC+VZTV9f2S8I8Q9nzYIfn9LaPswhjMyM0UAafOof?= =?utf-8?q?knC9OpWC6DYJYeAfwtgDmEpYZ2e3WWc5Zh0gFfdbZD3gzgcqCx4uZbxtjhkOjzn//?= =?utf-8?q?AjD6U/OReEiGkSdimX88YDh7YyXivVk5SGg5ew9X8D8MR2OR/rMUdWtsydMDDxCer?= =?utf-8?q?fsd+bszm3+YhEx+1pe095uVs7DABiwYK2pB0u1N9jCQaD5khrAnh0rMTQhRvyddeo?= =?utf-8?q?besRRnSxvGFvPjlwp4uM4pmzeFq5aDDF+gdRiIxvxvubJ/pZkFkFWfNUfngBke3wL?= =?utf-8?q?t4GBepRdcXyMU87t+qJduRXzHC/jCiZobshTayKrjR68yb5Pa7OZPa8AfFkoB5RtD?= =?utf-8?q?MrAAPvQCZ8Lt9/URY2biRo+P9+LgvduXWaWpIwk6bVS0EQKSLOrcEcpEDQHEKf8ME?= =?utf-8?q?EqERdG9DGjI6661MuFLy355lsFbp+FBsaHh4SfSCvbKAPSrbxsXgspQp+vWA764yz?= =?utf-8?q?HJlgQEruUaOZdl+hmZIPbSGovizpF4hsFHgNCTD8dznyX/HodmU/l1+2fHeJJLjn7?= =?utf-8?q?TX4Mrantuklg3CX3lezDHNYXYKk2hRYhhiX5MVzGvoMHTJL9//sZc9frH8HslP2Zg?= =?utf-8?q?Ga1npLB2lv+8yTmtFE82pTOb/JKQTYbxurKfXjDAeTr9l3rXb0rSLlu5o7lQrmofe?= =?utf-8?q?YT+12a16K/yCwsUhufnGMLpYnrCxgTyHsvsNq7aIl49lZUCHQlAf4IsRKdWcjs/PK?= =?utf-8?q?y2Jy3242oZJo4fViKnzRzoDw3jYO9WU/shTMUbx9WtmfdpURWosZ3BXaOcmO5EWrs?= =?utf-8?q?e2MawTUIruI6rn/dFxJvl0TUPixmUN4HJ2QSkuG3alaI9L61VEvnKAWgMgUVc0E/O?= =?utf-8?q?BxxqyiHRBHPcNQmnn5YfHeOIUG5oIROilQtmdXqL4IniNYgn1iDKPmpxFwIfUWwAr?= =?utf-8?q?9hN1pD6jzNkEp8+9Wqzueb8grW3S6zyDmvq9ZCkFEEyGE1sbLjNsLd0a63q72+2de?= =?utf-8?q?JKONHN+74ADRNr/47XveyBTtPAnJZ08Mm6s/0044UmPsmzEsVNOINwb8RwmyMTjz5?= =?utf-8?q?5zVvEwSYLDytkj9UnCFnFbBjPCdN4Q2+njaDCq968qhaCaR3cW0cScpnH8zZmmDUo?= =?utf-8?q?HFMehhHel7XOGPrLSmjvf/l401W0J7MEWWmyRqFo5oW/2qIjwtRgV6lEIP9EveYrJ?= =?utf-8?q?rsRyrYIO0lm1msnpREwFDO5xx5DGivusgum4T3xh0KEYrsdS7LW61Y/gUIHmU/NxM?= =?utf-8?q?38irIJQO2d2fEmQd4RIP8lyeoYKPHD2Q5HV7nNuRRRykDGNulKgBUUvQ1PfAExfx5?= =?utf-8?q?irNP8yvdebpuYizx4ceNlReVXDeTIcD117Ek3aNSYkz0d2Y3vk5nkJZ/P7ERpyBvB?= =?utf-8?q?nPfOI7slpPC0?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0f2d4b8-600b-4955-a69c-08db812c6699 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 09:59:50.4269 (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: PvGobHM7xebvcbytp1JBQdKds+MxSgga8P9xZO3iFa0q4GePfYMh0sybv7lXNFOvy55lw58Rflif/4RTNC45qA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB6096 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-tegra@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 Acked-by: Thierry Reding --- drivers/thermal/tegra/soctherm.c | 38 ++++++++++++------------- drivers/thermal/tegra/tegra30-tsensor.c | 9 +++--- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index ea66cba09e56..3d144377d90a 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -1993,29 +1993,27 @@ static int soctherm_interrupts_init(struct platform_device *pdev, return 0; } - ret = devm_request_threaded_irq(&pdev->dev, - tegra->thermal_irq, - soctherm_thermal_isr, - soctherm_thermal_isr_thread, - IRQF_ONESHOT, - dev_name(&pdev->dev), - tegra); - if (ret < 0) { - dev_err(&pdev->dev, "request_irq 'thermal_irq' failed.\n"); + ret = devm_request_threaded_irq_probe(&pdev->dev, + tegra->thermal_irq, + soctherm_thermal_isr, + soctherm_thermal_isr_thread, + IRQF_ONESHOT, + dev_name(&pdev->dev), + tegra, + "thermal_irq"); + if (ret < 0) return ret; - } - ret = devm_request_threaded_irq(&pdev->dev, - tegra->edp_irq, - soctherm_edp_isr, - soctherm_edp_isr_thread, - IRQF_ONESHOT, - "soctherm_edp", - tegra); - if (ret < 0) { - dev_err(&pdev->dev, "request_irq 'edp_irq' failed.\n"); + ret = devm_request_threaded_irq_probe(&pdev->dev, + tegra->edp_irq, + soctherm_edp_isr, + soctherm_edp_isr_thread, + IRQF_ONESHOT, + "soctherm_edp", + tegra, + "edp_irq"); + if (ret < 0) return ret; - } return 0; } diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegra/tegra30-tsensor.c index c243e9d76d3c..dd4c2deba93a 100644 --- a/drivers/thermal/tegra/tegra30-tsensor.c +++ b/drivers/thermal/tegra/tegra30-tsensor.c @@ -593,12 +593,11 @@ static int tegra_tsensor_probe(struct platform_device *pdev) return err; } - err = devm_request_threaded_irq(&pdev->dev, irq, NULL, - tegra_tsensor_isr, IRQF_ONESHOT, - "tegra_tsensor", ts); + err = devm_request_threaded_irq_probe(&pdev->dev, irq, NULL, + tegra_tsensor_isr, IRQF_ONESHOT, + "tegra_tsensor", ts, NULL); if (err) - return dev_err_probe(&pdev->dev, err, - "failed to request interrupt\n"); + return err; return 0; }