Re: [PATCH v2 01/12] reboot: replace __hw_protection_shutdown bool action parameter with an enum
From: Tzung-Bi Shih
Date: Mon Jan 20 2025 - 02:10:46 EST
On Mon, Jan 13, 2025 at 05:25:26PM +0100, Ahmad Fatoum wrote:
> Currently __hw_protection_shutdown() either reboots or shuts down the
> system according to its shutdown argument.
>
> To make the logic easier to follow, both inside __hw_protection_shutdown
> and at caller sites, lets replace the bool parameter with an enum.
>
> This will be extra useful, when in a later commit, a third action is
> added to the enumeration.
>
> No functional change.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
With a minor question,
Reviewed-by: Tzung-Bi Shih <tzungbi@xxxxxxxxxx>
> @@ -1009,10 +1007,10 @@ void __hw_protection_shutdown(const char *reason, int ms_until_forced, bool shut
> * orderly_poweroff failure
> */
> hw_failure_emergency_poweroff(ms_until_forced);
> - if (shutdown)
> - orderly_poweroff(true);
> - else
> + if (action == HWPROT_ACT_REBOOT)
> orderly_reboot();
> + else
> + orderly_poweroff(true);
It probably doesn't really matter. Does it intend to change the branch
order? As s/shutdown/action == HWPROT_ACT_SHUTDOWN/ should be more
intuitive for the hunk to me.