Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp49696pxu; Thu, 3 Dec 2020 19:06:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKt1JqrRfANSMzHGsjdJy8cFNaJqyj3SoTBOgSR61j8qR7OWBoAgdb7gU8/5BGmIWw4rAN X-Received: by 2002:a05:6402:1b1e:: with SMTP id by30mr4365256edb.75.1607051185785; Thu, 03 Dec 2020 19:06:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607051185; cv=none; d=google.com; s=arc-20160816; b=WF536pqCVgOLgNGY27U1JkEaWz79kmNSva9vWBriODPsHlm7D8y19M5nB8RLn0ogiL Q5yUdpTM/7York/NlepHCGgHnc+pfQHfbJqz1b1xzggHsnD9/tbZLhRyHHt2f3ebhkSz qFtDZ803V/hd6SsVqDBmwNvONas3r8bBTg8ABOWl7I6ryeFbbiDsY3xfLImM5xY77oyG jahIFLKAILe+XbcCkUh8MrQyf6mI9dGvjlicE4DM5eEGRwqpyWthzBTbjxJKcPm/GMXo EvXRcImi6zRumTAKoxyX9GsTjZA8Nh6EL7mHZEGkJmHbAE7yUwAIzhUiNI+fAho54heb LYgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject; bh=u/JFn4HzEACG0P8qq31qQu82Ey83jjMSGIPXNaq+XcE=; b=z4SioE16+uCjH0Ruq3qx14BuyWLTgyhwzPYeTdWy2zIho7IT+L/iGVzk15TicusN0p FkLqgXeH/Pa4TOC7bkvFpJBwZbM1xxMPvEgf/WbB5tly7++44W7U1gdGxX6WXwGH+tMq GT2/mGP9whT56QSwjhfxJmvK6faB9CHmDx71CCtiFblqa1i6fWdivZNlnT9zODZVOqWY Qornhkp2y3AnGeCSme4jsVNymSBfaM9hmVYliAOhwfLaH6P4iEFck3waxVn/pE/TjgAL dTHVVBbwyZYjmh5DZqb5b2AtCSi66MnwarJ7HHUL8eG7fg/UGD6Pkg8FcmsBaMrtwlB/ O0nA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si554029ejc.271.2020.12.03.19.06.01; Thu, 03 Dec 2020 19:06:25 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727407AbgLDDC3 (ORCPT + 99 others); Thu, 3 Dec 2020 22:02:29 -0500 Received: from server-x.ipv4.hkg02.ds.network ([27.111.83.178]:57400 "EHLO mail.gtsys.com.hk" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1726634AbgLDDC3 (ORCPT ); Thu, 3 Dec 2020 22:02:29 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.gtsys.com.hk (Postfix) with ESMTP id 6AD952344E93; Fri, 4 Dec 2020 11:01:42 +0800 (HKT) X-Virus-Scanned: Debian amavisd-new at gtsys.com.hk Received: from mail.gtsys.com.hk ([127.0.0.1]) by localhost (mail.gtsys.com.hk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u-cXjOXYxjlA; Fri, 4 Dec 2020 11:01:42 +0800 (HKT) Received: from s01.gtsys.com.hk (unknown [10.128.4.2]) by mail.gtsys.com.hk (Postfix) with ESMTP id 4AEF820001F5; Fri, 4 Dec 2020 11:01:42 +0800 (HKT) Received: from [10.128.2.32] (unknown [124.217.188.227]) by s01.gtsys.com.hk (Postfix) with ESMTPSA id 50918C019FF; Fri, 4 Dec 2020 11:01:41 +0800 (HKT) Subject: Re: [PATCH] phy: rockchip-emmc: emmc_phy_init() always return 0 From: Chris Ruehl To: Doug Anderson Cc: Ulf Hansson , Heiko Stuebner , LKML , Kishon Vijay Abraham I , "open list:ARM/Rockchip SoC..." , Vinod Koul , Linux ARM References: <20201201031015.23314-1-chris.ruehl@gtsys.com.hk> Message-ID: Date: Fri, 4 Dec 2020 11:01:40 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2/12/2020 4:36 pm, Chris Ruehl wrote: > > On 2/12/2020 12:05 am, Doug Anderson wrote: >> Hi, >> >> On Mon, Nov 30, 2020 at 7:10 PM Chris Ruehl wrote: >>> >>> rockchip_emmc_phy_init() return variable is not set with the error value >>> if clk_get() failed. The debug message print 0 on error and the function >>> always return 0. >>> Fix it using PTR_ERR(). >>> >>> Fixes: 52c0624a10cce phy: rockchip-emmc: Set phyctrl_frqsel based on card clock >>> >>> Signed-off-by: Chris Ruehl >>> --- >>>   drivers/phy/rockchip/phy-rockchip-emmc.c | 1 + >>>   1 file changed, 1 insertion(+) >>> >>> diff --git a/drivers/phy/rockchip/phy-rockchip-emmc.c >>> b/drivers/phy/rockchip/phy-rockchip-emmc.c >>> index 48e2d75b1004..75faee5c0d27 100644 >>> --- a/drivers/phy/rockchip/phy-rockchip-emmc.c >>> +++ b/drivers/phy/rockchip/phy-rockchip-emmc.c >>> @@ -253,6 +253,7 @@ static int rockchip_emmc_phy_init(struct phy *phy) >>>           */ >>>          rk_phy->emmcclk = clk_get(&phy->dev, "emmcclk"); >>>          if (IS_ERR(rk_phy->emmcclk)) { >>> +               ret = PTR_ERR(rk_phy->emmcclk); >> >> I'm pretty sure your patch isn't correct and it would break use cases. >> Is it fixing some bug that you're aware of, or you found it via code >> inspection? >> >> Specifically: >> >> * The big comment block in this function says that the clock is >> optional and that we're ignoring errors. >> >> * The printout in this function is "dbg" level, which is an extra >> indication that we aren't concerned with these errors. >> >> Arguably the code could be made better.  If you want to improve it, >> you could check for just the error we expect if the clock isn't >> specified (probably -ENODEV, but you should check) and treat all other >> failures as real errors. >> >> >> -Doug >> > > Hi Doug, >  I reviewed the code while hunting behind an other bug, with hs400 > and yes I saw the comment that they don't care about the problem > if the clk_get() return an error, and set the rk_phy->emmcclk = NULL > regardless, not using the ret variable but define it isn't useful. > > If return a error code break something on the other hand, better it > hit it rather then suppress it in IMHO. > > Let me follow the caller of the function and see how they treat the > err != 0. > > If something is in danger, I will be effected with my rk3399 rollout :) > > Chris > I check my case, the dts properties emmcclk is defined for the rk3399. (checked it I do not have an error, clk_get() works) If clk_get() failed and we propagate error<0 to the phy-core.c which then not increase the phy->init_count, but throw error message that something goes wrong. Someone should explain to me, why we should cover up an error. Chris Otherwise