Skip to content

Commit 35527c6

Browse files
konradybciovireshk
authored andcommitted
cpufreq: qcom-hw: Simplify counting frequency domains
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> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent df97441 commit 35527c6

1 file changed

Lines changed: 6 additions & 23 deletions

File tree

drivers/cpufreq/qcom-cpufreq-hw.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#define GT_IRQ_STATUS BIT(2)
3131

32+
#define MAX_FREQ_DOMAINS 3
33+
3234
struct qcom_cpufreq_soc_data {
3335
u32 reg_enable;
3436
u32 reg_domain_state;
@@ -651,10 +653,9 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev)
651653
{
652654
struct clk_hw_onecell_data *clk_data;
653655
struct device *dev = &pdev->dev;
654-
struct device_node *soc_node;
655656
struct device *cpu_dev;
656657
struct clk *clk;
657-
int ret, i, num_domains, reg_sz;
658+
int ret, i, num_domains;
658659

659660
clk = clk_get(dev, "xo");
660661
if (IS_ERR(clk))
@@ -681,24 +682,9 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev)
681682
if (ret)
682683
return ret;
683684

684-
/* Allocate qcom_cpufreq_data based on the available frequency domains in DT */
685-
soc_node = of_get_parent(dev->of_node);
686-
if (!soc_node)
687-
return -EINVAL;
688-
689-
ret = of_property_read_u32(soc_node, "#address-cells", &reg_sz);
690-
if (ret)
691-
goto of_exit;
692-
693-
ret = of_property_read_u32(soc_node, "#size-cells", &i);
694-
if (ret)
695-
goto of_exit;
696-
697-
reg_sz += i;
698-
699-
num_domains = of_property_count_elems_of_size(dev->of_node, "reg", sizeof(u32) * reg_sz);
700-
if (num_domains <= 0)
701-
return num_domains;
685+
for (num_domains = 0; num_domains < MAX_FREQ_DOMAINS; num_domains++)
686+
if (!platform_get_resource(pdev, IORESOURCE_MEM, num_domains))
687+
break;
702688

703689
qcom_cpufreq.data = devm_kzalloc(dev, sizeof(struct qcom_cpufreq_data) * num_domains,
704690
GFP_KERNEL);
@@ -762,9 +748,6 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev)
762748
else
763749
dev_dbg(dev, "QCOM CPUFreq HW driver initialized\n");
764750

765-
of_exit:
766-
of_node_put(soc_node);
767-
768751
return ret;
769752
}
770753

0 commit comments

Comments
 (0)