From d5fb75a05deac98570d96a18287cd56ed10417b6 Mon Sep 17 00:00:00 2001 From: Amir Vajid Date: Mon, 16 Dec 2019 12:06:19 -0800 Subject: [PATCH] PM / devfreq: memlat: simplify core-dev table parsing logic In register_common(), there's unnecessary code used to find which device tree node has the core-dev property. Refactor this to reduce complexity. Change-Id: Ib3475272b25e898ad23f9f5a4412d90cd889a356 Signed-off-by: Amir Vajid --- drivers/devfreq/governor_memlat.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/devfreq/governor_memlat.c b/drivers/devfreq/governor_memlat.c index 3194527e06a2..980d74f6fc15 100644 --- a/drivers/devfreq/governor_memlat.c +++ b/drivers/devfreq/governor_memlat.c @@ -437,9 +437,6 @@ static struct core_dev_map *init_core_dev_map(struct device *dev, struct core_dev_map *tbl; int ret; - if (!of_node) - of_node = dev->of_node; - if (!of_find_property(of_node, prop_name, &len)) return NULL; len /= sizeof(data); @@ -477,7 +474,7 @@ static struct memlat_node *register_common(struct device *dev, struct memlat_hwmon *hw) { struct memlat_node *node; - struct device_node *of_child; + struct device_node *of_node = dev->of_node; if (!hw->dev && !hw->of_node) return ERR_PTR(-EINVAL); @@ -489,14 +486,11 @@ static struct memlat_node *register_common(struct device *dev, node->ratio_ceil = 10; node->hw = hw; - if (hw->get_child_of_node) { - of_child = hw->get_child_of_node(dev); - hw->freq_map = init_core_dev_map(dev, of_child, - "qcom,core-dev-table"); - } else { - hw->freq_map = init_core_dev_map(dev, NULL, - "qcom,core-dev-table"); - } + if (hw->get_child_of_node) + of_node = hw->get_child_of_node(dev); + + hw->freq_map = init_core_dev_map(dev, of_node, "qcom,core-dev-table"); + if (!hw->freq_map) { dev_err(dev, "Couldn't find the core-dev freq table!\n"); return ERR_PTR(-EINVAL);