From patchwork Mon Jul 10 09:59:21 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: 117796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4915857vqx; Mon, 10 Jul 2023 03:12:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlHH8M/hqnuEVcBhkVcnpUZl65WGV9cHniVELsDiJf+qOAUJhbuf8Pm56EJmnkWpYasrYUmZ X-Received: by 2002:a05:6512:3c83:b0:4fa:21d4:b3ca with SMTP id h3-20020a0565123c8300b004fa21d4b3camr11135180lfv.2.1688983979201; Mon, 10 Jul 2023 03:12:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688983979; cv=pass; d=google.com; s=arc-20160816; b=RIK+0/v99ba8Gk13gOkiwp1Dwz7WGMAzqbzMFcBMzY8T2eHpoYVeG6Gdw96tXSb6xo LHd+Wt5eXCsPwx+CEH/W8yPIxJepBggp/Lo70svp4hKMBZGmwmSFCjdKZn8oZlFWKO2Q ccX3Ax5bBFkc97xS0E1wX3fLlegl6MZjvZVGhdyoDpHTCUDtRw7KfOYqKqOQ59NTRW7u USYXtwfq8nCUWO5vE9n63N+OReK6pDnsgNDR9uD2rOK5HCnfovMYokIh51KR8f7dqWno yif/qMjqoMjVsCWZ/l2uyMZNH4abhx+z8uqekmDxn7vUHabKutVh9VIY1F+718mUWexh +cWQ== 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=q+TzYuEeTgIKdnKfQ77B8vedEfB0P2/z7sQrh3Z4zJE=; fh=8Zzvw/eTUuxAjDvMUtsP0x+Qkw83CBIjC1nKrfItm8A=; b=FhW0vBFeJB27hcNMwEtBswOd1QtVYds7rIJHdxJJgSZtRUL00ZBJX3w7Yr1omHXUm0 ZhbN968Cqktsx/yPfInU/CNV7O2EG625LQJ0xiRyav9ZYfTela30KGP8Lk5MnVFXawYi Nk8OualpDrtDZCg8ZB5nfUebbAL8bVGijElgSpqYIKc2dgCwD/14/hN7g/rgqthyOKMl 7CubR0lbUz0PdQugROMm26v/YiBILaqVOO5jaWHDEd1AdOS+JG+BruPZWmxYH9/WcjMC wioDK185JePdFZJ3h5WR+/L+McDixveiNO2U061hBhDXblx7RurdJFP8AbCq8wLPCaqC NCVw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="kiD7/uXV"; 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 gv21-20020a170906f11500b00992af47620esi6348923ejb.509.2023.07.10.03.12.34; Mon, 10 Jul 2023 03:12:59 -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="kiD7/uXV"; 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 S233167AbjGJKFP (ORCPT + 99 others); Mon, 10 Jul 2023 06:05:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbjGJKEZ (ORCPT ); Mon, 10 Jul 2023 06:04:25 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2133.outbound.protection.outlook.com [40.107.255.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEE12FA; Mon, 10 Jul 2023 03:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YDi8f4fhqBQmLo/w1erRj4h0KDlAtdnSYVvIxrxqzZptmLOvVw0oCGfXqxRJT2yMWLHiCk6wFbGmZPHwv+jGf+i4uRzAIBpkOnshebHP7jC1j2C/L2Upo9EjR8nXmfABFuPbSMc9mY2p34D0/6/n5qKPibxngIHOta95yf7Jb1Fh/lBPXuPUaqSl+kKwmjwc3fYidJfbLEcsnAhxrJ2RtJ1OFhhk6l0a4dqjBq9iA1RYZ8cOnsKeGoXfZt5YxfzJhoeXv7MCEJxb+x0iSu1b6Ebcth3IWCmrJYymTzX7X22P/axAke0hBUY3lxFAJI5Ywi4hbbRENZvTzJZse4/9Vw== 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=q+TzYuEeTgIKdnKfQ77B8vedEfB0P2/z7sQrh3Z4zJE=; b=jbdgUc597raW8lebj/wdUJpRl7kmq9zg7nrHuiE6i8l/UcLXbrdnlcLBxenKen/FrBPMG0E4yGM8PNVS5D6ISW9oZmr06JoZiz3hVgM3nk4gZwjWSP6jsVeKZZtOg8ChQ3oOlbcP7IgLL6YtxI5kfjz6dA/KogeSC5eylREB7cMYyYPOhJaG/LPqlgDlowfJmK9Ztu8g8rN9swqepz5FDRD2r6GnqLa+9VReUc5plE2jJpm6i4Ucc27hwV1ng+1G+EX2myWesICHHo4ayN2nuchAF3L2cHG6jcSNJPhjzkzczHa5pJCIuMkuKjvQ+UDb24D3ACI50jgQB4us0vkD+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=q+TzYuEeTgIKdnKfQ77B8vedEfB0P2/z7sQrh3Z4zJE=; b=kiD7/uXVMCofQRZRkRX6QdEPamF9JqMfA1ZKeGZh2ReH/s0XEXen5Alpbwi069HZrEmwGNKJ9pGCt81SoCGON/onmU/S5TA1kfGCmYbK2KGEOPeiFbdvooV/Sx3bDYqPNUsGX2yvxDCtFJwB24CYdOS2g1SS6GJpjEKYDenspndmt3yI6g2wlPzz1v4OORXOFrtxc6zjgd5dV+JliHaw37Xpp3aRduUbp3LHgu7aJD9F2It79VEBvZyEpNmzLoGOhTDeiTdWGhov8z7g3Y+nngSEflq3m1K98v/ryph0xSu8DaWpP1upSvOH0FPEWSD3FIWr2sf7ovdMOyFaZJm3yQ== 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 10:00:24 +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:24 +0000 From: Yangtao Li To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Maxime Coquelin , Alexandre Torgue 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, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 17/21] thermal/drivers/stm: convert to use devm_request*_irq_probe() Date: Mon, 10 Jul 2023 17:59:21 +0800 Message-Id: <20230710095926.15614-17-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: 50708932-a9ee-43cd-aeba-08db812c7a9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6lRSknbGh8PmoS3Xny7ElGcMj4BkXGR6wUlGvJFyeGElbaP0+MxuEZVysx+sIgC0Tl9LrAnn2bMHfKSvqYIxDoURVajnmY2KoOUu8mNxcaTe6hgvKy8LG/2RvIx+Ei+wpuYcbTmdhy52anUfS1gVT62LKb397GM9JtBxQzNBIl8O/5rMgvCwUJGkFyn4GUM2+3+qirkqZBdciwPO/9qp4wA4iblD9VoC/DtGU7h/naSkfSnAPCbydxH6EZQLfSlpzIv95QdxsDe73yYndvCXRnWYJYf73D8bdPFtemKacq6w72ysCwpQrnrB5DrOtubIY7pBYN+cNogfEPYvMjilqyjTpcLf0ZG3MMDETrsPKvhGUByvkhDTSVEmK3SvOjJVdFqHOKUAvC+PteSwv0Jq2lkICtH3e6fF+WSCQbbbM4N3PF7/8G3vrtC9kMCen6nHg8F6S/xvlGU+BsAS1yoaqiae+E9CkZ/DPWYsjMtfpYDhIMi3R3T4szfHevmV3nln9xsaDhPJnbqROzyNpRfwnLnrZKPZxsqAqiNxMMAy4sBMScKEqmV1tDcs3DEusA9L2+bd3lCd1ubWgI8H8oNj2HcroyGBUaicMB2it75vLPcGOlzFmKDSI8WhyHH5okEb 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?uY16imdcqOG8IwNJ2rMKw+AKLjtP?= =?utf-8?q?phfg0EAbDhbtkggYEEA1WR1q8kjiUbfDcYwQFp/m4w+RtVdhXJd9UEnxxY0umQSwe?= =?utf-8?q?fBu/z0d0jE7uNSdDfsclhQERuaDwZPL5HPvSpLKLAWsUjnIHAoUAECd9keG1+fh8K?= =?utf-8?q?7BHfrFnST4urU6gaAooFocZgbSUXKkZOc0LTsIp1TJ1Fr9K0G3EDNUxqdZ2W5dnfJ?= =?utf-8?q?mUEDhExcc98F7y600vXPngPYCZg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66f+PZdVFExXn7Rc1Kd?= =?utf-8?q?rXNlWrv8GV1Qj3Ft66laU3ycEfPlpufp5qrKhqvLNXnwe3FXkSTTbXOIw6wneOYfy?= =?utf-8?q?++Vv4C9ZxhT0zTibZm5vhgn/CCZqlbmnxOEYEh5KFylrQs/FZeMcoPsNqX/1RLLNq?= =?utf-8?q?6ZvuKshWmTUcgX3eE4qqFf3uJhOsIM64gfnVhKGRTUxpRMAQ9xU5eaYdYn92tiP0s?= =?utf-8?q?dsWUsiT+9vIMQ395z+ahF+ogCXwpdSeFKd0dDRCcI8joAN1cwy/eJFVAeX49f3L6T?= =?utf-8?q?cF09qrGhnzVXo1m3ir6oThlF1LqP+3rwh/n7ZDXyxm8nRodT7TX1GE8Y9c0G0iYNB?= =?utf-8?q?WUAm9EB9CgASRqZjSi/Q9KboMqp8SZ/9nucerFg1OO5LQYauhs/Hz9BvNHDcUObq5?= =?utf-8?q?J4Gix5p9THYE?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50708932-a9ee-43cd-aeba-08db812c7a9e 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:24.0271 (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: 1M+lcwzHaiTgRP3rY7KrlwAvwU2zQZYM1X5/3OtFwJJIsQ17TrI83qhdF9LdmNb0dN3MiDqEkIIGrxQYHuR+pw== 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771028065111883638 X-GMAIL-MSGID: 1771028065111883638 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/st/st_thermal_memmap.c | 12 +++++------- drivers/thermal/st/stm_thermal.c | 13 ++++--------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/st/st_thermal_memmap.c b/drivers/thermal/st/st_thermal_memmap.c index e8cfa83b724a..40bb318b5489 100644 --- a/drivers/thermal/st/st_thermal_memmap.c +++ b/drivers/thermal/st/st_thermal_memmap.c @@ -97,14 +97,12 @@ static int st_mmap_register_enable_irq(struct st_thermal_sensor *sensor) if (sensor->irq < 0) return sensor->irq; - ret = devm_request_threaded_irq(dev, sensor->irq, - NULL, st_mmap_thermal_trip_handler, - IRQF_TRIGGER_RISING | IRQF_ONESHOT, - dev->driver->name, sensor); - if (ret) { - dev_err(dev, "failed to register IRQ %d\n", sensor->irq); + ret = devm_request_threaded_irq_probe(dev, sensor->irq, + NULL, st_mmap_thermal_trip_handler, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + dev->driver->name, sensor, NULL); + if (ret) return ret; - } return st_mmap_enable_irq(sensor); } diff --git a/drivers/thermal/st/stm_thermal.c b/drivers/thermal/st/stm_thermal.c index 903fcf1763f1..6a36a7eab9bd 100644 --- a/drivers/thermal/st/stm_thermal.c +++ b/drivers/thermal/st/stm_thermal.c @@ -387,16 +387,11 @@ static int stm_register_irq(struct stm_thermal_sensor *sensor) if (sensor->irq < 0) return sensor->irq; - ret = devm_request_threaded_irq(dev, sensor->irq, - NULL, - stm_thermal_irq_handler, - IRQF_ONESHOT, - dev->driver->name, sensor); - if (ret) { - dev_err(dev, "%s: Failed to register IRQ %d\n", __func__, - sensor->irq); + ret = devm_request_threaded_irq_probe(dev, sensor->irq, NULL, + stm_thermal_irq_handler, IRQF_ONESHOT, + dev->driver->name, sensor, NULL); + if (ret) return ret; - } dev_dbg(dev, "%s: thermal IRQ registered", __func__);