Skip to content

Commit edcef66

Browse files
srestorulf
authored andcommitted
pmdomain: rockchip: reduce indentation in rockchip_pd_power
Rework the logic, so that the function exits early when the power domain state is already correct to reduce code indentation. No functional change intended. Reviewed-by: Heiko Stuebner <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Tested-by: Adrian Larumbe <[email protected]> # On Rock 5B Signed-off-by: Sebastian Reichel <[email protected]> Link: https://lore.kernel.org/r/20250220-rk3588-gpu-pwr-domain-regulator-v6-4-a4f9c24e5b81@kernel.org Signed-off-by: Ulf Hansson <[email protected]>
1 parent 7ab6c93 commit edcef66

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

drivers/pmdomain/rockchip/pm-domains.c

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -592,39 +592,40 @@ static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on)
592592

593593
guard(mutex)(&pmu->mutex);
594594

595-
if (rockchip_pmu_domain_is_on(pd) != power_on) {
596-
ret = clk_bulk_enable(pd->num_clks, pd->clks);
597-
if (ret < 0) {
598-
dev_err(pmu->dev, "failed to enable clocks\n");
599-
return ret;
600-
}
595+
if (rockchip_pmu_domain_is_on(pd) == power_on)
596+
return 0;
601597

602-
rockchip_pmu_ungate_clk(pd, true);
598+
ret = clk_bulk_enable(pd->num_clks, pd->clks);
599+
if (ret < 0) {
600+
dev_err(pmu->dev, "failed to enable clocks\n");
601+
return ret;
602+
}
603603

604-
if (!power_on) {
605-
rockchip_pmu_save_qos(pd);
604+
rockchip_pmu_ungate_clk(pd, true);
606605

607-
/* if powering down, idle request to NIU first */
608-
rockchip_pmu_set_idle_request(pd, true);
609-
}
606+
if (!power_on) {
607+
rockchip_pmu_save_qos(pd);
610608

611-
ret = rockchip_do_pmu_set_power_domain(pd, power_on);
612-
if (ret < 0) {
613-
clk_bulk_disable(pd->num_clks, pd->clks);
614-
return ret;
615-
}
609+
/* if powering down, idle request to NIU first */
610+
rockchip_pmu_set_idle_request(pd, true);
611+
}
616612

617-
if (power_on) {
618-
/* if powering up, leave idle mode */
619-
rockchip_pmu_set_idle_request(pd, false);
613+
ret = rockchip_do_pmu_set_power_domain(pd, power_on);
614+
if (ret < 0) {
615+
clk_bulk_disable(pd->num_clks, pd->clks);
616+
return ret;
617+
}
620618

621-
rockchip_pmu_restore_qos(pd);
622-
}
619+
if (power_on) {
620+
/* if powering up, leave idle mode */
621+
rockchip_pmu_set_idle_request(pd, false);
623622

624-
rockchip_pmu_ungate_clk(pd, false);
625-
clk_bulk_disable(pd->num_clks, pd->clks);
623+
rockchip_pmu_restore_qos(pd);
626624
}
627625

626+
rockchip_pmu_ungate_clk(pd, false);
627+
clk_bulk_disable(pd->num_clks, pd->clks);
628+
628629
return 0;
629630
}
630631

0 commit comments

Comments
 (0)