From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA077C433EF for ; Thu, 16 Sep 2021 01:28:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8FB961186 for ; Thu, 16 Sep 2021 01:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233731AbhIPB3h (ORCPT ); Wed, 15 Sep 2021 21:29:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233688AbhIPB3c (ORCPT ); Wed, 15 Sep 2021 21:29:32 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D221C061574; Wed, 15 Sep 2021 18:28:11 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id x27so11857749lfu.5; Wed, 15 Sep 2021 18:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nn45bUIl96WIFsT4CN3x7DghHPbrAhKFSaIduPWSZkU=; b=D8DU4mSw6cSYFQ8suIyp64R0VVAZh6DQCoxHnANYkUTfVZiEEyVKQ+yqiou/6fQ5Qm vkTu7PInawFreqF8g4x91QuV7ppLmVabWqAguheLpb0FFTDxs5bekaBqMe492Ws3v4LM YYQpIW00z///2b2I9Jca54Q1yhdNCrLD+fPPAV6XCOtA0yBi/2AyuLRE0P+30+6LYjQC 68yzExokhqLpcT/KhCmFV2d9/ZKHpDTswSjQHddq58MjMELZTx2akWj18YzOzAWaUF1G W36Zys7m7RQCoASklp67URZIo7p6eeRtZT8Lv4cxud3KxPDsvC3hIrOQsULYHjDMk4gq jP9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nn45bUIl96WIFsT4CN3x7DghHPbrAhKFSaIduPWSZkU=; b=ActXdSq1jjZ1t7cmI46rmXzIf3Pg1FaXUZNw5uJSqxIzdKPNdEYpyxepT/83BA9x7J Z98z0kzeG8ES0PpKiFW55sWKT+2iNEXoHtJ0a5wFaOWbQLCSiG/rY7anuYseQBTgiIK9 oqwYLBO6UubPujj1aiYXNxznrzPo4aLw6swzwX6UnNWJulvDBr76gt5qdixq0VzfrN1L 7AOUAr/Iik2UaqtxNBjdymHicnwmT+ek7qmZ66Ohye4KEzP5aVdcgsG/qZt1IPKPrlKL TVHtH34F1HWAJntet8v/5jvHii7CF3+ryDyo8XB7VMrE7qGg9jc4atvtsIIsQZvPikgc SW2g== X-Gm-Message-State: AOAM532om5Ked8JxiPGajfvO30HqUFd15bY1Se+viiEh5PjPmBosz6zP Qg2HyDPWnTePh1q5ITU1bjs= X-Google-Smtp-Source: ABdhPJzbUSUXPW9or3AwwwZSR/K3KohU1VLv2sABEALCC/gpyM3zULJdOtF7UOBfYYrMwSl4YhDk7w== X-Received: by 2002:a05:6512:3fa8:: with SMTP id x40mr2051116lfa.536.1631755689417; Wed, 15 Sep 2021 18:28:09 -0700 (PDT) Received: from [192.168.2.145] (94-29-62-67.dynamic.spd-mgts.ru. [94.29.62.67]) by smtp.googlemail.com with ESMTPSA id x192sm121892lff.154.2021.09.15.18.28.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Sep 2021 18:28:08 -0700 (PDT) Subject: Re: [PATCH v1 4/4] PM / devfreq: tegra30: Check whether clk_round_rate() returns zero rate To: Chanwoo Choi Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Thierry Reding , Jonathan Hunter , Viresh Kumar , Nishanth Menon , MyungJoo Ham , Stephen Boyd , Kyungmin Park , Chanwoo Choi References: <20210912184458.17995-1-digetx@gmail.com> <20210912184458.17995-5-digetx@gmail.com> <9fa66405-883a-3653-eb5d-3cd7eee07a0a@gmail.com> From: Dmitry Osipenko Message-ID: <26d90b01-13d5-3bd8-da0a-b9ff61c7845a@gmail.com> Date: Thu, 16 Sep 2021 04:28:07 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 15.09.2021 21:31, Chanwoo Choi пишет: > On 21. 9. 15. 오후 12:51, Chanwoo Choi wrote: >> Hi, >> >> On 21. 9. 13. 오전 3:44, Dmitry Osipenko wrote: >>> EMC clock is always-on and can't be zero. Check whether clk_round_rate() >>> returns zero rate and error out if it does. It can return zero if clock >>> tree isn't initialized properly. >>> >>> Signed-off-by: Dmitry Osipenko >>> --- >>>   drivers/devfreq/tegra30-devfreq.c | 4 ++-- >>>   1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/devfreq/tegra30-devfreq.c >>> b/drivers/devfreq/tegra30-devfreq.c >>> index d83fdc2713ed..65ecf17a36f4 100644 >>> --- a/drivers/devfreq/tegra30-devfreq.c >>> +++ b/drivers/devfreq/tegra30-devfreq.c >>> @@ -891,9 +891,9 @@ static int tegra_devfreq_probe(struct >>> platform_device *pdev) >>>           return err; >>>       rate = clk_round_rate(tegra->emc_clock, ULONG_MAX); >>> -    if (rate < 0) { >>> +    if (rate <= 0) { >>>           dev_err(&pdev->dev, "Failed to round clock rate: %ld\n", >>> rate); >>> -        return rate; >>> +        return rate ?: -EINVAL; > > If rate is 0, It doesn't return and fall-through? even if print the > error message. 'return rate ?: -EINVAL;' style is strange for me > because it doesn't specify the 'return value' when rate is true. It's not clear to me what do you mean by "return and fall-through". It specifies the 'return value' when rate is true. It's a short form of "rate ? rate : -EINVAL". The final returned value will be printed by the driver's core. The value returned by clk_round_rate() is important here since it tells the reason of the error. https://elixir.bootlin.com/linux/v5.15-rc1/source/drivers/base/dd.c#L533