From patchwork Fri Jul 21 09:46:26 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: 706016 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 01B01EB64DC for ; Fri, 21 Jul 2023 09:48:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231852AbjGUJrr (ORCPT ); Fri, 21 Jul 2023 05:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231818AbjGUJrX (ORCPT ); Fri, 21 Jul 2023 05:47:23 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2095.outbound.protection.outlook.com [40.107.215.95]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498D930D7; Fri, 21 Jul 2023 02:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ICrn6L49WCKH73MWdY9X3Eh7bGowQFLSJKr6iu5vDdcvTsC4aGJGRnqJg4CXywLs/bnbIzNFcZfqbGYGT/CYO2kcByD2fhuQyG0jD53QZE23uew2CXB8SqDsRaR9jxb4EGvfubMH8OZqOBvcBQBhzEaQEE83lnf6EvmpH0NJHYelJKm++uw+EvMUhLKG09EGv4o3zB4REMtnx7WUofoCeSUk+3dRWW/HphX1iK+6kg3dRSXh9/BrkLg4bmqlcH8dYJoR9bEIqiVlvAZqNFrn9bKY3oGgJ17AhFSHJ7/HKts5PrGA2FYxHvX1tUGpBsg88tWIdkUhAPjIt7akz0srAQ== 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=/+gwW3HWoFbyKNr4P4zmQsQ0AWdekKwoDQhwbjDld4s=; b=J2X/hCcddxm6sMaBw++W167h2z/j3UKMr0CnULfgtGFLwbNWZAoiaRmYs+V4QhKFa+w0HeCzFBQyRAjU03VL1nsJ9qs3rw+z3Je4xZFgT6lIJcNk2Cgjo4J77JD38Z/bJtd8IlkDcH8Zo5JCy0aiSNSjzPvjoattLCGCpUGTxm7SQlWX/AJnuUasvDRtVQFyXDbJcdGz+PS2Gpy5cNiiozR5HFw/fSBxeHj10n33E0qJWBb3uvc8zNH2iBQXRQW9zavrMcNEo/thYy3qWKV5vz+TyBFaY0uK2s4Uip7UP0CLo46R+v4fqJxZx2IruMU17ml/TZ2KwlkT8WdW65MiCw== 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=/+gwW3HWoFbyKNr4P4zmQsQ0AWdekKwoDQhwbjDld4s=; b=cF2JDo5dPh1vPk+ZMHECqPCMHysej4t8qvwFlUK7Pc1+9z1CIbWZeapFwF/Du5Nq96jYnPSp/8DoSzmgVcyi8U+GPDL3KgIKMe+2HMAd8JQZjt+7w4ZU/BzGJqL8nJo4N305nV5R6YjdO1BOtnPn4HDwLG6Eh4noF9XbgR0SomNKWjtdhms/4DczdQi7aVEaeqpiEl8LK87Nrd2w0PbgXEMlJRfBwD5YlLcOx/9jD7QDAM+kHPg6+vpShUg3dUT5JgOa2gixaVYpX4l71KA0mQhSc0npFg41RJW3bWMJV76P5jbxexxIozqpZOsmoDQ8J4QBW5tsMvC4B4sa3EiU0Q== 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:12 +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:12 +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 07/22] thermal/drivers/db8500: convert to use devm_request*_irq_probe() Date: Fri, 21 Jul 2023 17:46:26 +0800 Message-Id: <20230721094641.77189-7-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: c0dff76a-c25d-482a-d2c1-08db89cf755b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Nf+mI4/Mbgb4QIPpg+NgXypRZOsvG9mTHKTYKoRjvR9DdmfEaP9Tqeni/OMV/tD1GQRL2C9u8iArqBTnqzJk/o5qVcXpJBXIpbO9wcNneFs8W8la/JntM6wPCTZedM6NCBQjHpurQgHEcPH2CKZN4P4RNdgHXuqpQIonqLvkr8XTW7S34VNtlPxrxDxQsQ6NgXFj5U1UI/HGnYKJE9VK9i9NnGLusO8RUXy4L4HkMUxXzTqp2q5fnP1DxCzw4NB8uc15MwJzu5vYfdMd6X+hxhBpAs6e4LXEJ2GCBkHJoMkHhOWtMqXR+BM9+is3xrooCMNd+hEqmye643dunzVY/1txENvQtADY4UHDOA1CNLZZGdcJxiHKTE9uuhUDRXURRRtZrjJkOMznjO9CtJ1MfXhicz/ZLySV5b6jv7y38nq3jaORKNm4gw8dJsQB7HRGb/x6ICwLWFhM09Q8fNmk2ECL9OnWNyqX0jNvpU9r63VAcsOFM+co5j5WLtLioIyJkevdGKSXVisLWN1YUffggobRtFOFdlKAetCTGZAmDGA8lhzDh1lYCtRk6RR+44pIC4BsiKbd9KPcaVzMGYMkAY00YItLE0wZXihigMS3wZPP1oF9jTd7odq6VKOQEWT 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)(6666004)(7416002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?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r/d6rKnBPpBXBNpRnQQ?= =?utf-8?q?nHieOl4O6weonFKOoZyCz8VJgsEWwqLZQgM7qsirPTcf/4nz7UZBsCK42z1w2r+t5?= =?utf-8?q?x+yRsTDhK+ZtYuNcA9wGbJzYBcQJQDtweNTI3JMLNnchUQ6B30xKBb9j7xzNJx0HE?= =?utf-8?q?EOTkcxQN8CfZMeEDzhQzyefx67abfls4BVbVtfCq42KpPttiyzllVsMBaRuVqk1JU?= =?utf-8?q?UNNev+/ldhCdGncVypq5vtJduoh0tieYJisoDRGgzKVB8Aht/eUtdXpaQuak4AQBc?= =?utf-8?q?NjjxaDbuRQQ/hNFaow4FuqKn0JCDj7RFyQyy4xW2pFxUXXaUY1Osn9Kp4Cbn0tq+B?= =?utf-8?q?x7NX0jIypp1T3l2FS2OxXB+dbIVaQMs+Ga4KcBTVkf7ZoxjkEWc3Ddxs8sQ4NL3NM?= =?utf-8?q?84OyhvLuigwztcTtPz/dalNBNb2IYMziOvkdiZ2NUqnaFWj3smlltg8Vr9SHEIF3n?= =?utf-8?q?1PGvS+ctNGWmn0HWtk4XenBW6sBm6TX4btClb9TFnqLNo/sXbKpG28/2+NSNZxssu?= =?utf-8?q?pkkINd7NgGe9XdxiBAVP4g1/mrWTQI26S9YLcz5CWaFcalRn0sHNNCEv1yUlj6okC?= =?utf-8?q?Cc2sEtLmiH/QWRlfY+j6soa2K3HcHIC0QmObPDTIVfZMi1AyveMO0/1vtXw8Wjucg?= =?utf-8?q?77UhzEncDIUy?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0dff76a-c25d-482a-d2c1-08db89cf755b 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:12.5246 (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: ImTdWJDZnd6c63N6ido1LZwl/uxovGBRTpXyATl+75blg+1emqIuXEp9ritOH+qTmWmts/25B4FOyfuFnECZmQ== 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/db8500_thermal.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c index fca5c2c93bf9..0ef8fc2eb4a1 100644 --- a/drivers/thermal/db8500_thermal.c +++ b/drivers/thermal/db8500_thermal.c @@ -164,25 +164,21 @@ static int db8500_thermal_probe(struct platform_device *pdev) if (low_irq < 0) return low_irq; - ret = devm_request_threaded_irq(dev, low_irq, NULL, + ret = devm_request_threaded_irq_probe(dev, low_irq, NULL, prcmu_low_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT, - "dbx500_temp_low", th); - if (ret < 0) { - dev_err(dev, "failed to allocate temp low irq\n"); + "dbx500_temp_low", th, "temp low"); + if (ret < 0) return ret; - } high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH"); if (high_irq < 0) return high_irq; - ret = devm_request_threaded_irq(dev, high_irq, NULL, + ret = devm_request_threaded_irq_probe(dev, high_irq, NULL, prcmu_high_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT, - "dbx500_temp_high", th); - if (ret < 0) { - dev_err(dev, "failed to allocate temp high irq\n"); + "dbx500_temp_high", th, "temp high"); + if (ret < 0) return ret; - } /* register of thermal sensor and get info from DT */ th->tz = devm_thermal_of_zone_register(dev, 0, th, &thdev_ops);