Message ID | 20230216105140.3938749-1-konrad.dybcio@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | viresh kumar |
Headers | show |
Series | [v2] cpufreq: qcom-hw: Simplify counting frequency domains | expand |
On Thu, Feb 16, 2023 at 11:51:40AM +0100, Konrad Dybcio wrote: > For quite some time, this driver has been performing some quite > low-level DT operations. Simplify that using platform_get_resource. > > Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> Reviewed-by: Bjorn Andersson <andersson@kernel.org> Regards, Bjorn > --- > v1 -> v2: > - remove stray newline near probe return > - s/doing performing/performing/ > > v1: https://lore.kernel.org/linux-arm-msm/20230216102956.3933639-1-konrad.dybcio@linaro.org/T/#u > > drivers/cpufreq/qcom-cpufreq-hw.c | 29 ++++++----------------------- > 1 file changed, 6 insertions(+), 23 deletions(-) > > diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c > index 2f581d2d617d..575a4461c25a 100644 > --- a/drivers/cpufreq/qcom-cpufreq-hw.c > +++ b/drivers/cpufreq/qcom-cpufreq-hw.c > @@ -29,6 +29,8 @@ > > #define GT_IRQ_STATUS BIT(2) > > +#define MAX_FREQ_DOMAINS 3 > + > struct qcom_cpufreq_soc_data { > u32 reg_enable; > u32 reg_domain_state; > @@ -651,10 +653,9 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) > { > struct clk_hw_onecell_data *clk_data; > struct device *dev = &pdev->dev; > - struct device_node *soc_node; > struct device *cpu_dev; > struct clk *clk; > - int ret, i, num_domains, reg_sz; > + int ret, i, num_domains; > > clk = clk_get(dev, "xo"); > if (IS_ERR(clk)) > @@ -681,24 +682,9 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) > if (ret) > return ret; > > - /* Allocate qcom_cpufreq_data based on the available frequency domains in DT */ > - soc_node = of_get_parent(dev->of_node); > - if (!soc_node) > - return -EINVAL; > - > - ret = of_property_read_u32(soc_node, "#address-cells", ®_sz); > - if (ret) > - goto of_exit; > - > - ret = of_property_read_u32(soc_node, "#size-cells", &i); > - if (ret) > - goto of_exit; > - > - reg_sz += i; > - > - num_domains = of_property_count_elems_of_size(dev->of_node, "reg", sizeof(u32) * reg_sz); > - if (num_domains <= 0) > - return num_domains; > + for (num_domains = 0; num_domains < MAX_FREQ_DOMAINS; num_domains++) > + if (!platform_get_resource(pdev, IORESOURCE_MEM, num_domains)) > + break; > > qcom_cpufreq.data = devm_kzalloc(dev, sizeof(struct qcom_cpufreq_data) * num_domains, > GFP_KERNEL); > @@ -762,9 +748,6 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) > else > dev_dbg(dev, "QCOM CPUFreq HW driver initialized\n"); > > -of_exit: > - of_node_put(soc_node); > - > return ret; > } > > -- > 2.39.1 >
On 22-02-23, 19:27, Bjorn Andersson wrote: > On Thu, Feb 16, 2023 at 11:51:40AM +0100, Konrad Dybcio wrote: > > For quite some time, this driver has been performing some quite > > low-level DT operations. Simplify that using platform_get_resource. > > > > Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> > > Reviewed-by: Bjorn Andersson <andersson@kernel.org> Applied. Thanks.
diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 2f581d2d617d..575a4461c25a 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -29,6 +29,8 @@ #define GT_IRQ_STATUS BIT(2) +#define MAX_FREQ_DOMAINS 3 + struct qcom_cpufreq_soc_data { u32 reg_enable; u32 reg_domain_state; @@ -651,10 +653,9 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) { struct clk_hw_onecell_data *clk_data; struct device *dev = &pdev->dev; - struct device_node *soc_node; struct device *cpu_dev; struct clk *clk; - int ret, i, num_domains, reg_sz; + int ret, i, num_domains; clk = clk_get(dev, "xo"); if (IS_ERR(clk)) @@ -681,24 +682,9 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) if (ret) return ret; - /* Allocate qcom_cpufreq_data based on the available frequency domains in DT */ - soc_node = of_get_parent(dev->of_node); - if (!soc_node) - return -EINVAL; - - ret = of_property_read_u32(soc_node, "#address-cells", ®_sz); - if (ret) - goto of_exit; - - ret = of_property_read_u32(soc_node, "#size-cells", &i); - if (ret) - goto of_exit; - - reg_sz += i; - - num_domains = of_property_count_elems_of_size(dev->of_node, "reg", sizeof(u32) * reg_sz); - if (num_domains <= 0) - return num_domains; + for (num_domains = 0; num_domains < MAX_FREQ_DOMAINS; num_domains++) + if (!platform_get_resource(pdev, IORESOURCE_MEM, num_domains)) + break; qcom_cpufreq.data = devm_kzalloc(dev, sizeof(struct qcom_cpufreq_data) * num_domains, GFP_KERNEL); @@ -762,9 +748,6 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) else dev_dbg(dev, "QCOM CPUFreq HW driver initialized\n"); -of_exit: - of_node_put(soc_node); - return ret; }
For quite some time, this driver has been performing some quite low-level DT operations. Simplify that using platform_get_resource. Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> --- v1 -> v2: - remove stray newline near probe return - s/doing performing/performing/ v1: https://lore.kernel.org/linux-arm-msm/20230216102956.3933639-1-konrad.dybcio@linaro.org/T/#u drivers/cpufreq/qcom-cpufreq-hw.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-)