[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180519115441.GK17671@n2100.armlinux.org.uk>
Date: Sat, 19 May 2018 12:54:41 +0100
From: Russell King - ARM Linux <linux@...linux.org.uk>
To: ilialin@...eaurora.org
Cc: 'Viresh Kumar' <viresh.kumar@...aro.org>, mark.rutland@....com,
nm@...com, catalin.marinas@....com, mturquette@...libre.com,
will.deacon@....com, tfinkel@...eaurora.org,
linux-kernel@...r.kernel.org, david.brown@...aro.org,
nicolas.dechesne@...aro.org, linux-clk@...r.kernel.org,
robh@...nel.org, andy.gross@...aro.org, celster@...eaurora.org,
devicetree@...r.kernel.org, linux-pm@...r.kernel.org,
linux-arm-msm@...r.kernel.org, broonie@...nel.org,
linux-soc@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
rnayak@...eaurora.org, sboyd@...nel.org, rjw@...ysocki.net,
lgirdwood@...il.com, amit.kucheria@...aro.org
Subject: Re: [PATCH v8 10/15] cpufreq: Add Kryo CPU scaling driver
On Sat, May 19, 2018 at 02:09:24PM +0300, ilialin@...eaurora.org wrote:
> +static int __init qcom_cpufreq_kryo_driver_init(void)
> +{
> + struct device *cpu_dev_silver, *cpu_dev_gold;
> + struct opp_table *opp_silver, *opp_gold;
> + enum _msm8996_version msm8996_version;
> + struct nvmem_cell *speedbin_nvmem;
> + struct platform_device *pdev;
> + struct device_node *np;
> + u8 *speedbin;
> + u32 versions;
> + size_t len;
> + int ret;
> +
> + cpu_dev_silver = get_cpu_device(SILVER_LEAD);
> + if (IS_ERR_OR_NULL(cpu_dev_silver))
> + return PTR_ERR(cpu_dev_silver);
> +
> + cpu_dev_gold = get_cpu_device(SILVER_LEAD);
> + if (IS_ERR_OR_NULL(cpu_dev_gold))
> + return PTR_ERR(cpu_dev_gold);
> +
> + msm8996_version = qcom_cpufreq_kryo_get_msm_id();
> + if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
> + dev_err(cpu_dev_silver, "Not Snapdragon 820/821!");
> + return -ENODEV;
> + }
> +
> + np = dev_pm_opp_of_get_opp_desc_node(cpu_dev_silver);
> + if (IS_ERR_OR_NULL(np))
> + return PTR_ERR(np);
This function (qcom_cpufreq_kryo_driver_init) returns zero on success.
You are checking "np" here for being an error pointer, or NULL.
What value do you think PTR_ERR() returns in the case of PTR_ERR(NULL)?
IS_ERR_OR_NULL() is considered by some (me included) as being _very_
harmful because programmers generally fail to look at linux/err.h and
consider what it means when used as above.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
Powered by blists - more mailing lists