Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp4164703rwn; Sun, 11 Sep 2022 06:31:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR49YGG/GkypxGIZhJ+FYfNsnV2L3+CuAUxnHibwzG1RaJmWg30zoGYUAq9W27jGmVoQAlWb X-Received: by 2002:a17:903:1c3:b0:177:ef4b:c614 with SMTP id e3-20020a17090301c300b00177ef4bc614mr17837189plh.17.1662903075964; Sun, 11 Sep 2022 06:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662903075; cv=none; d=google.com; s=arc-20160816; b=IQxDJXnUYCOMX1e/RIIBjLNglMXgi8Rcd7qjZjcgusNQXhpttTP34xPs5niFw6EnXU QgJCdiR8ZufLpzESWL3rnY2XfGw+Ku67c4GJF6F+L3JYX24x9mHNjHU8TQO+BSUMwBeN a0FQrlqX7rdKK3BlpQgpjVkpSNxn9AGEEiWhBLeSCsCoJeAPD2iCIpW3n8nxSs8vhnyn ePChX4wDwa/VSqmZOkvy8S0BNMoM6gHKkVxpf1D11qoTeJFEQzhXn/7l0AGILD+GqVCU qngMGH7ICzcANMJsxSq+vhiZsxaJO4nYnVX8PCXkHA86mCSA86mePvETFWeOHD4ShP8b mlLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=6rALyhmiakw/k97Cbmn8ZR3itBkDVmP07yrXbj9WA1E=; b=Btn4x1n3rJs/R0CHB6u6N/OBYfEuYqqXpODTs2v7rF5zUEBCo0h+fB29rf/mf/6mwl bGlNGJT8PcTqOxVu8GwShcsYwEsA/5uYB0h5jU9dHAFI0mgCojaT88kiu/B2Ei0vXRgz Q/knGyw8Ntap3DwhcI/YDixfolxTelIkspiqUCcyrSRZ7AkKtoJozz/5oFrOcYu/g3rn RmmrF7WFQ7YBYRUHcCygshLj2HeAJq27f/YscsBKVS6JQ2PsnqKCwfoCdZT5+fT7nHaB IPrK+umGSbahoP62DMwE46/cwvI07OS8/k2eqh2XRInYLT5oHxQbbspX7P35zkYRO9XP hPIw== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a170903240a00b0017811e39271si6669192plo.487.2022.09.11.06.31.04; Sun, 11 Sep 2022 06:31:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230184AbiIKNWA (ORCPT + 99 others); Sun, 11 Sep 2022 09:22:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbiIKNV7 (ORCPT ); Sun, 11 Sep 2022 09:21:59 -0400 Received: from smtp.smtpout.orange.fr (smtp02.smtpout.orange.fr [80.12.242.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6768F23BD5 for ; Sun, 11 Sep 2022 06:21:57 -0700 (PDT) Received: from [192.168.1.18] ([90.11.190.129]) by smtp.orange.fr with ESMTPA id XMuIol8dXLFqbXMuIofNot; Sun, 11 Sep 2022 15:21:56 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 11 Sep 2022 15:21:56 +0200 X-ME-IP: 90.11.190.129 Message-ID: Date: Sun, 11 Sep 2022 15:21:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [RFC PATCH] checkpatch: Check check for places where dev_err_probe() would likely be better than dev_err() Content-Language: en-US To: Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , "linus.walleij@linaro.org" Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <3cdc2e776dea77b07c75694ba1410bd21e8ed749.1662902045.git.christophe.jaillet@wanadoo.fr> From: Christophe JAILLET In-Reply-To: <3cdc2e776dea77b07c75694ba1410bd21e8ed749.1662902045.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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 Le 11/09/2022 à 15:15, Christophe JAILLET a écrit : > Some functions are known to potentially return -EPROBE_DEFER. In such a > case, it is likely that dev_err_probe() is a better choice than err_err(). > > dev_err_probe(): > - is usually less verbose > - generates smaller .o files > - handles -EPROBE_DEFER so that logs are not spammed > - automatically log the error code in a human readable way > > Signed-off-by: Christophe JAILLET > --- > This patch is only a PoC to see if there is some interest in such a new > check. > The hard coded '5 lines of context' has been chosen because a typical > pattern is: > > clk = devm_clk_get(dev, "clk_lcd"); > if (IS_ERR(clk) { > dev_err(dev, "Error meesage\n"); > return PTR_ERR(clk); > } (adding Linus Walleij) I forgot to say that this patch is a try to address the comment from Linus Walleij at [1]. It would not help "fixing a gazillion dev_err_probe()", but it could help not having more to fix later :) CJ [1]: https://lore.kernel.org/all/CACRpkdZEcTD1A3tR=d4fDF89ECMDfchVPW921v6X6ARiPXHEMQ@mail.gmail.com/ > --- > scripts/checkpatch.pl | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 2737e4ced574..88365749ed2e 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -2625,6 +2625,9 @@ sub process { > my $last_blank_line = 0; > my $last_coalesced_string_linenr = -1; > > + my $last_function_that_return_defer = ""; > + my $last_function_that_return_defer_linenr = 0; > + > our @report = (); > our $cnt_lines = 0; > our $cnt_error = 0; > @@ -7459,6 +7462,17 @@ sub process { > WARN("DUPLICATED_SYSCTL_CONST", > "duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h\n" . $herecurr); > } > + > +# check for places where dev_err_probe() would likely be better than dev_err() > + if ($line =~ /((?:devm_)?clk_get)s*\(/) { > + $last_function_that_return_defer = $1; > + $last_function_that_return_defer_linenr = $linenr; > + } > + if ($last_function_that_return_defer_linenr >= ($linenr - 5) && > + $line =~ /dev_err[^_]/) { > + WARN("LIKELY_DEV_ERR_PROBE", > + "dev_err_probe() is likely a better choice than err_err() after a " . $last_function_that_return_defer . "() call\n" . $herecurr); > + } > } > > # If we have no input at all, then there is nothing to report on