From patchwork Fri Jul 21 09:46:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13321781 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 D1A6EEB64DC for ; Fri, 21 Jul 2023 09:50:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231981AbjGUJur (ORCPT ); Fri, 21 Jul 2023 05:50:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231822AbjGUJuS (ORCPT ); Fri, 21 Jul 2023 05:50:18 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2119.outbound.protection.outlook.com [40.107.215.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EC844220; Fri, 21 Jul 2023 02:49:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J43RpKt4DRzZ7yOxVN9y3MgwYBWFbX2tH8eAl/7XdwNMzjTpgCC4EICZVVDnNU2qk4mZKf8Jw60FR+dubR6MUPlkklnSpsyDlCxBdbaq9hkSmlsWCxGjC4CcWbW1ClEjDMw6i8y13xuyzRb5VTWG8FmTBb3bOPIodkdvYPOpQn3FRdufbj8qefUauAbkGFyNVys6lOqWow9Lv5IOgHlSSKYA5OEDSfMZOKkW7CSygMXkdrVwUsxhjzZuvnXMtJ/7yrft0rPvKY0Ws481XQTIZlpGIXriIjlzOhjsG403wCcvv7pQhPZn+5ZWAtsFtkbRT3ZA1spIJoncfnuWGKkplw== 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=f4bfb4yk8VVql8CBIboaJds/47jikygD97Ynoj6D92M=; b=bZo1qAAcMO6KhjoLfNW/o9Oj1skYQ/Akx/kw5pFjTxFWnsI5YKh8vEMMWCiRMfp/US7727c+U+WViK2TKwDzf5iweYZcwNqbao2Krls+M1hRCd5fdingjLjgrNNWdrkEOJeb8Q/cNnROJDpLbyuocxbLRefrHbHEXtsjKQUQDye19cqTHv8UntPH/xP1BgAm4lykfGOfxzdLcO2WcIEeRLOPUnoX4rAhJbazwio0ukrchiG87DBzFKWBg1bfVbxKJyQ3e57OF0EI0dBWnmLlY6MdYtRpQFgKeT0R+BjSYb7M93FWCPERxVMpB6QuRWt4TmudRT7bhna7VJCMpU/r/A== 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=f4bfb4yk8VVql8CBIboaJds/47jikygD97Ynoj6D92M=; b=dnnKKBLOvkjihUG90bDE71v/OBJS0X566qXj11vWSsMEnnUfPo36m7VEixLFmq12OsblsyGelu9dnjVp99ujhSM+W3SVY+P2wlZ+gZNk6VX6Rc5+FgOQKp2KuRvkcGQ2pNba6AaxR3N3x6YcmHNOGeIjR8J8iKWcznoiABqco5y7Dlu2yMAr1kWhe/Vj1T43p2iSy3I9IFTQGdN+X0hw98kpCxw4H50xJxxmik0tkn2Xmr+c4NrllWji3sRHaVLFLK0xmiU0W38oexps7uXwXZxH5eg57Xc1TksW+OQ1wNu4aUTiPZduxjCe92BrF3TqvuQPXNHGvse6s11iRbzxGA== 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 KL1PR06MB6789.apcprd06.prod.outlook.com (2603:1096:820:ff::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Fri, 21 Jul 2023 09:47:35 +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:34 +0000 From: Yangtao Li To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui 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-kernel@vger.kernel.org Subject: [PATCH v5 16/22] thermal: max77620: convert to use devm_request*_irq_probe() Date: Fri, 21 Jul 2023 17:46:35 +0800 Message-Id: <20230721094641.77189-16-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_|KL1PR06MB6789:EE_ X-MS-Office365-Filtering-Correlation-Id: 54eaae52-7f4b-4efc-0536-08db89cf82c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mrjw952keaR9LHfNm1FjYtJ2bgUpy/RDKZ5P75vKFScAmbDLZN7IpooC+JoSdBORrvV2jci8jsZHj/uCno7dZ0F4NeYb2DiP03hOtkvPgkdbBCTjT5l8gTxxTbOiwiV41Ve6XCErYqjDFabQo/MwUEl1ISPWpLkv0dyE1/uU1enmg9k/MglS0q+wpRyGpnRBBwfP6enDlAz/kYCiPlHyDwfRkF+c0Yqw3VnklvYUJqKOyZynwU6sh3oZ8xr6lqClaiHkUM1XxgBY9oAA8SO8Y54CmbX7t8p7sBmteWAh6UGDHqs2hVNCLl3zZfA/enNpEJ+2EGJeHFtCQR5lOUln4CjTQ9he4bC5V+n4matfRVxswm7UKXuyJzX2YE3qDoBeiqWWv8GFuEfu7hWZXzcM6A0vC7/TzBSvZSA0VAee+DB9g5H+nYZJDOemHX3VOPAZy+bHS+FJswgae1VxCqdKwQ6BJhez1Tkoj9DqSOSicqEX39jG2MBFGuZ6Sc2rQLPQjM28JcBhmdWjZVOy3q530OYWldsUB2BsWBYPUWs4vCZc35UAHVB/HDCdy4pqpeHU/eOYACsKMwQHUo4G6W2lXiCmTruk5BxwzD/iAd+NpaXfOjjzP00v9bN7yRu3D2L+ 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)(136003)(346002)(376002)(366004)(39860400002)(451199021)(83380400001)(66574015)(2616005)(2906002)(38350700002)(38100700002)(66556008)(316002)(66946007)(478600001)(6486002)(41300700001)(4326008)(6506007)(26005)(186003)(1076003)(66476007)(52116002)(6512007)(110136005)(54906003)(36756003)(5660300002)(8936002)(8676002)(86362001)(7416002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?6SHKl2amuMQC0zaHdHkMS0WGCZ/E?= =?utf-8?q?dqaq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qi5VAb9RAMc7m7CELE7bNcatGM3pTK9nR5KGKxrFZefaGGfy?= =?utf-8?q?whDdavOyZc4KButHTWTUB8XONGmhYITlDGsVBSJ6HLmsqRB2rzXIsOzZHOSRDgffF?= =?utf-8?q?Lyv1DMgUiq6em51ZiFRA7kwVVns3ot3dKcKocqjkVocb93031b/bf1GM9uEmYrhxk?= =?utf-8?q?0LLJZuNUQ1jGeBBJTGBjjutrUGxGpiun0lhbh3AqNz8A3qPHU0rtJWoSM9JgIdKYi?= =?utf-8?q?Qt2YQqYy6RGxB+vn73fGgVooLT7V+0yEsFc4otqdxU5kr9gdlPr0sKGtnoGPtBVfp?= =?utf-8?q?JqpbMnHXm2m06zd9ZJEomiZf5NgNlhnGmkjazTTYUe1bIenVT3ZLwuHGB54zaaIQb?= =?utf-8?q?NeRy1KjzuDTBbMiMwb1dEzje8aSsCsJOzW+8MMMpxrOoa/7S5VL/hOlf/d127OV6H?= =?utf-8?q?qW1s0kQcb2A2rQt3FZvkpLhX6iDekbo4XMowjjWhwya/vdSndQlunw21skmFkt461?= =?utf-8?q?o9gDWwo8MnqUclg1uJlKknbA9OewNKklvJL7HpGN3ViMWEjmvDmqIX3+LEp3cMtmv?= =?utf-8?q?b2swWKVg9Ik6nhrAPZMj30c6t+p2D4lb2Wt3OCWvE9id2+eaS9hMRUqoPwrRr/vZZ?= =?utf-8?q?y2qyBeyK5jrL?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54eaae52-7f4b-4efc-0536-08db89cf82c2 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:34.9390 (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: hPReEiJND1ptIyymzFa/lkGX4NU7ll0E1KKVpG+b//GAxdCgThRqrlCglyx7/om2NvTTJuhBUhrOnPCKVTzwzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB6789 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 --- drivers/thermal/max77620_thermal.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/max77620_thermal.c b/drivers/thermal/max77620_thermal.c index 61c7622d9945..92289498fa17 100644 --- a/drivers/thermal/max77620_thermal.c +++ b/drivers/thermal/max77620_thermal.c @@ -121,23 +121,19 @@ static int max77620_thermal_probe(struct platform_device *pdev) return ret; } - ret = devm_request_threaded_irq(&pdev->dev, mtherm->irq_tjalarm1, NULL, - max77620_thermal_irq, - IRQF_ONESHOT | IRQF_SHARED, - dev_name(&pdev->dev), mtherm); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to request irq1: %d\n", ret); + ret = devm_request_threaded_irq_probe(&pdev->dev, mtherm->irq_tjalarm1, NULL, + max77620_thermal_irq, + IRQF_ONESHOT | IRQF_SHARED, + dev_name(&pdev->dev), mtherm, "irq1"); + if (ret < 0) return ret; - } - ret = devm_request_threaded_irq(&pdev->dev, mtherm->irq_tjalarm2, NULL, - max77620_thermal_irq, - IRQF_ONESHOT | IRQF_SHARED, - dev_name(&pdev->dev), mtherm); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to request irq2: %d\n", ret); + ret = devm_request_threaded_irq_probe(&pdev->dev, mtherm->irq_tjalarm2, NULL, + max77620_thermal_irq, + IRQF_ONESHOT | IRQF_SHARED, + dev_name(&pdev->dev), mtherm, "irq2"); + if (ret < 0) return ret; - } platform_set_drvdata(pdev, mtherm);