Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp96613ybj; Wed, 6 May 2020 12:25:27 -0700 (PDT) X-Google-Smtp-Source: APiQypIIHkJIsB2UECWw48011o5njsDI8WID+eyMX48Kggzh3yNWIjtEa06nfm7DwuFv5g6ryEPT X-Received: by 2002:a17:906:1292:: with SMTP id k18mr8905551ejb.132.1588793127164; Wed, 06 May 2020 12:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588793127; cv=none; d=google.com; s=arc-20160816; b=HIQXKLKPRw8ItfX/z0j1KTKOEgA4zq9sKMwLmp9UW//KIarJmb6hT3ugeUUGsU+PeK Bd4WlDI8KzrUtTSofalfFUSVq9dtp6o1TFSPVCLp4PZYmtB7gxvdiTPrwxRg23S3bNDW QQDRhTtFRgxRhMlebhgs6W2iE0Dvehgeb6aO+u+FxJerETlqwtHeJiyqBNbeItKwn1kD sh4ZSwCn+BTCSWbRaYxq/obW5pwboOD+wUzNnDnSqtSOZqbyVBJsW+zNGCctnmU91ASW nYxi7TXlWvLVe/7RTlV2LO/uZ/NTI8zRnlm6A4Gn+KgaQuV40FwMJKpzbjYkSch46uIC 1FuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=0VvaK4qV5Etc72CR3O+s6dMnkCvk9HbAf4bkxXWnjEk=; b=G8BOiZrPawOZzjzHLSCywKbBOUfvnN57W+h7+IAXieQYZ+dzYMXpsZau77Spxg7RYx Fg2Vy6VFT9bOWJe0vUhJCVHNP8BQgpL8n78sdCD6Sn2dKjozUWymr2BsvSbK/WlGJfNE fIUPb1COgCavsmcpeuJQlYQapWAWDvt91NYsRQ+d6cHOk7ixdtQhDFrZXGBH1qi+ijNd 4LyAVRqNDRffbccJe5IH8Ed8ixDQRvFk49EDeN5uhat3EC6vFNXCL6zUGsGm4Owg6WBi n7id3jIoNtwcmwhKk80FAmolVgcGN0Ho12JZzEL2wLfrCvW+whdKWOAX3Emcc+ducIsp hPNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rhjyr4lD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si856020ejx.46.2020.05.06.12.25.03; Wed, 06 May 2020 12:25:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rhjyr4lD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729535AbgEFPka (ORCPT + 99 others); Wed, 6 May 2020 11:40:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728994AbgEFPk3 (ORCPT ); Wed, 6 May 2020 11:40:29 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27EF6C061A0F; Wed, 6 May 2020 08:40:29 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id g4so2881564ljl.2; Wed, 06 May 2020 08:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=0VvaK4qV5Etc72CR3O+s6dMnkCvk9HbAf4bkxXWnjEk=; b=rhjyr4lDLoMgtOYB2r0o+OivmiLZx9dTkjsQDZagRb9Q7LOphEreVu7j948kVIskqU pB00zCfLrigfNDjQPvnSbpEA/3JH+bsvdictzcAByx3TSHu5HT3KKScX9HpYZoqbNRrQ pIgLDvC0dsm8atptTDJKGNXibJCC/ogo956lYPMcAG5wHID8weG0LsxzEImi0VYMPBHQ mM9r4Le4mdnH4VSA57t08E/b/8dRN6yq82Xwll0cEUhf/hWBrGgn7ywNMUTwIYFkN66c Po4MLektX/wUlAOBRPGHIVL+M2z724VA17kk0iDqCb+m30OIJE/yi3wHB3A8pFWyvZNM PGzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0VvaK4qV5Etc72CR3O+s6dMnkCvk9HbAf4bkxXWnjEk=; b=tUXSgALTrehTRxwFxvJ1AChdI0Tqj7OwQtIpcz15sGjhp/oK/udaJHBvWtsHZU0h4u ghRKBKRaLznpMi3NN4du0zVKlNpglNm79JJZ/ZQAcYPS5i2NBPN+tS6ymFPvYqXGPpWY gX7ooIxaiREgrsZ4NsIyn0zzbpXR6WEKH0QWGSCqY8koXO+2pKoASNBsH62SqtbKve4U 0TKQsPQ/WRljarphI5de8hM1inklSljtxhQYgmHApSYyUOfiSKMPSel93dMqUqWXaEhf 4IYmI/W9o9NCjxO9dF8ZccaonCWhpCfLt/Vic+95jP90l0puDByKR30PBS45j7vjIkN4 FciA== X-Gm-Message-State: AGi0PubSUzXHi0yiZQ/vIRpNyzNcbSBNm4RZCzmgn5bQQsshWDbS88HL XSVvvD22M5o/Xw6FKzdphmc= X-Received: by 2002:a2e:6a08:: with SMTP id f8mr5671980ljc.8.1588779627589; Wed, 06 May 2020 08:40:27 -0700 (PDT) Received: from [192.168.2.145] (ppp91-78-208-152.pppoe.mtu-net.ru. [91.78.208.152]) by smtp.googlemail.com with ESMTPSA id m15sm1557297lji.21.2020.05.06.08.40.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 May 2020 08:40:26 -0700 (PDT) Subject: Re: [PATCH] phy: tegra: Use PTR_ERR_OR_ZERO() to simplify code To: Vidya Sagar , Aishwarya Ramakrishnan , Kishon Vijay Abraham I , Thierry Reding , Jonathan Hunter , Lorenzo Pieralisi , linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Julia Lawall References: <20200505150058.17674-1-aishwaryarj100@gmail.com> From: Dmitry Osipenko Message-ID: Date: Wed, 6 May 2020 18:40:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 06.05.2020 14:47, Vidya Sagar пишет: > Thanks for pushing this change. > I'm fine with this change as it is attempting to change only the last > occurrence of the (IS_ERR(...)) + PTR_ERR combination. > But, this code was initially written with PTR_ERR_OR_ZERO() itself but > later changed to use (IS_ERR(...)) + PTR_ERR based on the review comment > from Dmitry Osipenko ( https://lkml.org/lkml/2019/6/20/1457 ) > > Adding Dmitry as well to review the change. > > I'm fine with this change. > Reviewed-by: Vidya Sagar > > On 05-May-20 8:30 PM, Aishwarya Ramakrishnan wrote: >> External email: Use caution opening links or attachments >> >> >> PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR. >> >> Generated by: scripts/coccinelle/api/ptr_ret.cocci >> >> Signed-off-by: Aishwarya Ramakrishnan >> --- >>   drivers/phy/tegra/phy-tegra194-p2u.c | 5 +---- >>   1 file changed, 1 insertion(+), 4 deletions(-) >> >> diff --git a/drivers/phy/tegra/phy-tegra194-p2u.c >> b/drivers/phy/tegra/phy-tegra194-p2u.c >> index 7042bed9feaa..42394d27f4cb 100644 >> --- a/drivers/phy/tegra/phy-tegra194-p2u.c >> +++ b/drivers/phy/tegra/phy-tegra194-p2u.c >> @@ -92,10 +92,7 @@ static int tegra_p2u_probe(struct platform_device >> *pdev) >>          phy_set_drvdata(generic_phy, phy); >> >>          phy_provider = devm_of_phy_provider_register(dev, >> of_phy_simple_xlate); >> -       if (IS_ERR(phy_provider)) >> -               return PTR_ERR(phy_provider); >> - >> -       return 0; >> +       return PTR_ERR_OR_ZERO(phy_provider); >>   } Quite some people think that such a change doesn't bring any benefits, it doesn't help readability of the code, it even makes harder to read the code for a human being. IIRC, there were some requests in the past to remove that cocci rule to stop such auto-generated patches to re-occur over and over again. The PTR_ERR_OR_ZERO is good to use in a cases where it's not returned directly, like this: phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); err = PTR_ERR_OR_ZERO(phy_provider); if (err) return err; return 0;