Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powercap: dtpm: Simplify with of_machine_get_match_data()

Replace open-coded getting root OF node, matching against it and getting
the match data with new of_machine_get_match_data() helper.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://patch.msgid.link/20251112-b4-of-match-matchine-data-v2-9-d46b72003fd6@linaro.org
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Rob Herring (Arm)
599ff56e fa622c9e

+1 -15
+1 -15
drivers/powercap/dtpm.c
··· 548 548 */ 549 549 int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table) 550 550 { 551 - const struct of_device_id *match; 552 551 const struct dtpm_node *hierarchy; 553 - struct device_node *np; 554 552 int i, ret; 555 553 556 554 mutex_lock(&dtpm_lock); ··· 565 567 goto out_pct; 566 568 } 567 569 568 - ret = -ENODEV; 569 - np = of_find_node_by_path("/"); 570 - if (!np) 571 - goto out_err; 572 - 573 - match = of_match_node(dtpm_match_table, np); 574 - 575 - of_node_put(np); 576 - 577 - if (!match) 578 - goto out_err; 579 - 580 - hierarchy = match->data; 570 + hierarchy = of_machine_get_match_data(dtpm_match_table); 581 571 if (!hierarchy) { 582 572 ret = -EFAULT; 583 573 goto out_err;