From mboxrd@z Thu Jan 1 00:00:00 1970 From: Amit Kucheria Subject: Re: [PATCH v7 12/14] cpufreq: Add Kryo CPU scaling driver Date: Wed, 16 May 2018 17:13:44 +0300 Message-ID: References: <1526375616-16904-1-git-send-email-ilialin@codeaurora.org> <1526375616-16904-13-git-send-email-ilialin@codeaurora.org> <20180516141132.aqjif7d5motmmnlo@vireshk-i7> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20180516141132.aqjif7d5motmmnlo@vireshk-i7> Sender: linux-kernel-owner@vger.kernel.org To: Viresh Kumar Cc: Ilia Lin , Michael Turquette , sboyd@kernel.org, Rob Herring , Mark Rutland , "Menon, Nishanth" , lgirdwood@gmail.com, Mark Brown , Andy Gross , David Brown , Catalin Marinas , Will Deacon , "Rafael J. Wysocki" , linux-clk@vger.kernel.org, DTML , LKML , Linux PM list , linux-arm-msm , "open list:ARM/QUALCOMM SUPPORT" , lakml , Rajendra Nayak List-Id: linux-arm-msm@vger.kernel.org On Wed, May 16, 2018 at 5:11 PM, Viresh Kumar wrote: > On 16-05-18, 16:12, Amit Kucheria wrote: >> > + ret = PTR_ERR_OR_ZERO(opp_temp = >> > + dev_pm_opp_set_supported_hw(cpu_dev,&versions,1)); >> > + if (0 > ret) >> >> Any particular reason to prefer this over (ret < 0) that is generally >> used? I've seen it used to avoid the == vs. = typos, but not for other >> comparisons. >> >> Suggest sticking to what is commonly used i.e. ret < 0. >> >> > + goto free_opp; >> > + >> > + cpu_dev = get_cpu_device(GOLD_LEAD); >> >> Error check cpu_dev here? >> >> > + ret = PTR_ERR_OR_ZERO(opp_temp = >> > + dev_pm_opp_set_supported_hw(cpu_dev,&versions,1)); >> > + if (0 > ret) >> > + goto free_opp; > > The goto here is wrong > >> > + >> > + >> > + ret = PTR_ERR_OR_ZERO(platform_device_register_simple("cpufreq-dt", >> > + -1, NULL, 0)); >> > + >> > + if (0 == ret) >> > + return 0; >> > + >> > +free_opp: >> > + dev_pm_opp_put_supported_hw(opp_temp); >> >> This is not needed because dev_pm_opp_set_supported_hw will free >> memory in case of failure. This call in only needed in case of a >> successful get. > > But this is still required for the case where platform device > registration fails. Agreed. The overall error path needs to be re-written with proper check of return values. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752626AbeEPONv (ORCPT ); Wed, 16 May 2018 10:13:51 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:42126 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752510AbeEPONq (ORCPT ); Wed, 16 May 2018 10:13:46 -0400 X-Google-Smtp-Source: AB8JxZrdhfhwievo54ledtYgr/tNx0eGS+MfzmWxcBydM3o4p4urkVP3+LyK2+96lchhOcKEMOL+O4qT/qZmlNGCoT4= MIME-Version: 1.0 In-Reply-To: <20180516141132.aqjif7d5motmmnlo@vireshk-i7> References: <1526375616-16904-1-git-send-email-ilialin@codeaurora.org> <1526375616-16904-13-git-send-email-ilialin@codeaurora.org> <20180516141132.aqjif7d5motmmnlo@vireshk-i7> From: Amit Kucheria Date: Wed, 16 May 2018 17:13:44 +0300 Message-ID: Subject: Re: [PATCH v7 12/14] cpufreq: Add Kryo CPU scaling driver To: Viresh Kumar Cc: Ilia Lin , Michael Turquette , sboyd@kernel.org, Rob Herring , Mark Rutland , "Menon, Nishanth" , lgirdwood@gmail.com, Mark Brown , Andy Gross , David Brown , Catalin Marinas , Will Deacon , "Rafael J. Wysocki" , linux-clk@vger.kernel.org, DTML , LKML , Linux PM list , linux-arm-msm , "open list:ARM/QUALCOMM SUPPORT" , lakml , Rajendra Nayak , Nicolas Dechesne , celster@codeaurora.org, tfinkel@codeaurora.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 16, 2018 at 5:11 PM, Viresh Kumar wrote: > On 16-05-18, 16:12, Amit Kucheria wrote: >> > + ret = PTR_ERR_OR_ZERO(opp_temp = >> > + dev_pm_opp_set_supported_hw(cpu_dev,&versions,1)); >> > + if (0 > ret) >> >> Any particular reason to prefer this over (ret < 0) that is generally >> used? I've seen it used to avoid the == vs. = typos, but not for other >> comparisons. >> >> Suggest sticking to what is commonly used i.e. ret < 0. >> >> > + goto free_opp; >> > + >> > + cpu_dev = get_cpu_device(GOLD_LEAD); >> >> Error check cpu_dev here? >> >> > + ret = PTR_ERR_OR_ZERO(opp_temp = >> > + dev_pm_opp_set_supported_hw(cpu_dev,&versions,1)); >> > + if (0 > ret) >> > + goto free_opp; > > The goto here is wrong > >> > + >> > + >> > + ret = PTR_ERR_OR_ZERO(platform_device_register_simple("cpufreq-dt", >> > + -1, NULL, 0)); >> > + >> > + if (0 == ret) >> > + return 0; >> > + >> > +free_opp: >> > + dev_pm_opp_put_supported_hw(opp_temp); >> >> This is not needed because dev_pm_opp_set_supported_hw will free >> memory in case of failure. This call in only needed in case of a >> successful get. > > But this is still required for the case where platform device > registration fails. Agreed. The overall error path needs to be re-written with proper check of return values. From mboxrd@z Thu Jan 1 00:00:00 1970 From: amit.kucheria@linaro.org (Amit Kucheria) Date: Wed, 16 May 2018 17:13:44 +0300 Subject: [PATCH v7 12/14] cpufreq: Add Kryo CPU scaling driver In-Reply-To: <20180516141132.aqjif7d5motmmnlo@vireshk-i7> References: <1526375616-16904-1-git-send-email-ilialin@codeaurora.org> <1526375616-16904-13-git-send-email-ilialin@codeaurora.org> <20180516141132.aqjif7d5motmmnlo@vireshk-i7> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wed, May 16, 2018 at 5:11 PM, Viresh Kumar wrote: > On 16-05-18, 16:12, Amit Kucheria wrote: >> > + ret = PTR_ERR_OR_ZERO(opp_temp = >> > + dev_pm_opp_set_supported_hw(cpu_dev,&versions,1)); >> > + if (0 > ret) >> >> Any particular reason to prefer this over (ret < 0) that is generally >> used? I've seen it used to avoid the == vs. = typos, but not for other >> comparisons. >> >> Suggest sticking to what is commonly used i.e. ret < 0. >> >> > + goto free_opp; >> > + >> > + cpu_dev = get_cpu_device(GOLD_LEAD); >> >> Error check cpu_dev here? >> >> > + ret = PTR_ERR_OR_ZERO(opp_temp = >> > + dev_pm_opp_set_supported_hw(cpu_dev,&versions,1)); >> > + if (0 > ret) >> > + goto free_opp; > > The goto here is wrong > >> > + >> > + >> > + ret = PTR_ERR_OR_ZERO(platform_device_register_simple("cpufreq-dt", >> > + -1, NULL, 0)); >> > + >> > + if (0 == ret) >> > + return 0; >> > + >> > +free_opp: >> > + dev_pm_opp_put_supported_hw(opp_temp); >> >> This is not needed because dev_pm_opp_set_supported_hw will free >> memory in case of failure. This call in only needed in case of a >> successful get. > > But this is still required for the case where platform device > registration fails. Agreed. The overall error path needs to be re-written with proper check of return values.