回复: [PATCH] pmdomain: Use str_enable_disable-like helpers

From: Changhuang Liang
Date: Tue Jan 14 2025 - 21:11:20 EST


Hi, Krzysztof

Thanks for your patch.

> Replace ternary (condition ? "enable" : "disable") syntax with helpers from
> string_choices.h because:
> 1. Simple function call with one argument is easier to read. Ternary
> operator has three arguments and with wrapping might lead to quite
> long code.
> 2. Is slightly shorter thus also easier to read.
> 3. It brings uniformity in the text - same string.
> 4. Allows deduping by the linker, which results in a smaller binary
> file.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>
> ---
> drivers/pmdomain/renesas/rcar-gen4-sysc.c | 3 ++-
> drivers/pmdomain/renesas/rcar-sysc.c | 3 ++-
> drivers/pmdomain/samsung/exynos-pm-domains.c | 6 +++---
> drivers/pmdomain/starfive/jh71xx-pmu.c | 3 ++-
> 4 files changed, 9 insertions(+), 6 deletions(-)

[...]

> diff --git a/drivers/pmdomain/starfive/jh71xx-pmu.c
> b/drivers/pmdomain/starfive/jh71xx-pmu.c
> index 74720c09a6e3..30c29ac9391f 100644
> --- a/drivers/pmdomain/starfive/jh71xx-pmu.c
> +++ b/drivers/pmdomain/starfive/jh71xx-pmu.c
> @@ -12,6 +12,7 @@
> #include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/pm_domain.h>
> +#include <linux/string_choices.h>
> #include <dt-bindings/power/starfive,jh7110-pmu.h>
>
> /* register offset */
> @@ -155,7 +156,7 @@ static int jh7110_pmu_set_state(struct
> jh71xx_pmu_dev *pmd, u32 mask, bool on)
>
> if (ret) {
> dev_err(pmu->dev, "%s: failed to power %s\n",
> - pmd->genpd.name, on ? "on" : "off");
> + pmd->genpd.name, str_on_off(on));
> return -ETIMEDOUT;
> }

In jh71xx-pmu.c jh71xx_pmu_set_state(), maybe you can also change this line:

if (is_on == on) {
dev_dbg(pmu->dev, "pm domain [%s] is already %sable status.\n",
pmd->genpd.name, on ? "en" : "dis");
return 0;
}
====>
if (is_on == on) {
dev_dbg(pmu->dev, "pm domain [%s] is already %s status.\n",
pmd->genpd.name, str_enable_disable(on));
return 0;
}

Best Regards,
Changhuang