Re: [PATCH 04/13] cpufreq: qcom: Refactor the driver to make it easier to extend

From: Viresh Kumar
Date: Wed Jul 10 2019 - 02:30:33 EST


On 05-07-19, 11:57, Niklas Cassel wrote:
> + drv->opp_tables = kcalloc(num_possible_cpus(), sizeof(*drv->opp_tables),
> + GFP_KERNEL);
> + if (!drv->opp_tables) {
> + ret = -ENOMEM;
> + goto free_drv;
> + }
>
> for_each_possible_cpu(cpu) {
> cpu_dev = get_cpu_device(cpu);
> @@ -166,19 +195,23 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
> goto free_opp;
> }
>
> - opp_tables[cpu] = dev_pm_opp_set_supported_hw(cpu_dev,
> - &versions, 1);
> - if (IS_ERR(opp_tables[cpu])) {
> - ret = PTR_ERR(opp_tables[cpu]);
> - dev_err(cpu_dev, "Failed to set supported hardware\n");
> - goto free_opp;
> + if (drv->data->get_version) {

Why depend on get_version here ? The OPP table is already allocated
unconditionally.

> + drv->opp_tables[cpu] =
> + dev_pm_opp_set_supported_hw(cpu_dev,
> + &drv->versions, 1);
> + if (IS_ERR(drv->opp_tables[cpu])) {
> + ret = PTR_ERR(drv->opp_tables[cpu]);
> + dev_err(cpu_dev,
> + "Failed to set supported hardware\n");
> + goto free_opp;
> + }
> }
> }

--
viresh