On 07/29, Viresh Kumar wrote: > With "operating-points-v2" its possible to tell which devices share > OPPs. We already have infrastructure to decode that information. > > This patch adds following APIs: > - of_get_cpus_sharing_opps: Returns cpumask of CPUs sharing OPPs (only > valid with v2 bindings). > - of_cpumask_init_opp_table: Initializes OPPs for all CPUs present in > cpumask. > - of_cpumask_free_opp_table: Frees OPPs for all CPUs present in cpumask. > > - set_cpus_sharing_opps: Sets which CPUs share OPPs (only valid with old > OPP bindings, as this information isn't present in DT). > > Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnier...@samsung.com> > Signed-off-by: Viresh Kumar <viresh.ku...@linaro.org>
Reviewed-by: Stephen Boyd <sb...@codeaurora.org> Some minor nitpicks below: > + > +/* > + * Works only for OPP v2 bindings. > + * > + * cpumask should be already set to mask of cpu_dev->id. > + * Returns -ENOENT if operating-points-v2 bindings aren't supported. > + */ > +int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask) > +{ > + struct device_node *np, *tmp_np; > + struct device *tcpu_dev; > + int cpu, ret = 0; > + > + /* Get OPP descriptor node */ > + np = _of_get_opp_desc_node(cpu_dev); > + if (IS_ERR(np)) { > + dev_dbg(cpu_dev, "%s: Couldn't find opp node: %ld\n", __func__, > + PTR_ERR(np)); > + return -ENOENT; > + } > + > + /* OPPs are shared ? */ > + if (!of_get_property(np, "opp-shared", NULL)) if (!of_property_read_bool(np, "opp-shared")) ? > + goto put_cpu_node; > + > + for_each_possible_cpu(cpu) { > + if (cpu == cpu_dev->id) > + continue; > + > + tcpu_dev = get_cpu_device(cpu); > + if (!tcpu_dev) { > + dev_err(cpu_dev, "%s: failed to get cpu%d device\n", > + __func__, cpu); > + ret = -ENODEV; > + goto put_cpu_node; > + } > + > + /* Get OPP descriptor node */ > + tmp_np = _of_get_opp_desc_node(tcpu_dev); > + if (IS_ERR(tmp_np)) { > + dev_info(tcpu_dev, "%s: Couldn't find opp node: %ld\n", dev_err? > + __func__, PTR_ERR(tmp_np)); > + ret = -EINVAL; Why aren't we returning the PTR_ERR value here? > + goto put_cpu_node; -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/