回复: pmdomain: Use str_enable_disable-like helpers
From: Changhuang Liang
Date: Tue Jun 10 2025 - 11:36:16 EST
Hi, Mingyin
Thanks for your patch.
> From: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
>
> Replace ternary (condition ? "enable" : "disable") syntax and ternary
> (condition ? "on" : "off") 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: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
[...]
> diff --git a/drivers/pmdomain/starfive/jh71xx-pmu.c
> b/drivers/pmdomain/starfive/jh71xx-pmu.c
> index 74720c09a6e3..0e8fca4e2de9 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;
> }
>
> @@ -198,7 +199,7 @@ static int jh71xx_pmu_set_state(struct
> jh71xx_pmu_dev *pmd, u32 mask, bool on)
>
> if (is_on == on) {
> dev_dbg(pmu->dev, "pm domain [%s] is already %sable
> status.\n",
%sable ==> %s
> - pmd->genpd.name, on ? "en" : "dis");
> + pmd->genpd.name, str_enable_disable(on));
> return 0;
> }
>
Best Regards,
Changhuang