Re: [PATCH v2] x86/platform/uv: Rework NMI "action" modparam handling

From: Andy Shevchenko
Date: Thu Sep 14 2023 - 04:43:28 EST


On Wed, Sep 13, 2023 at 9:01 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
>
> Rework NMI "action" modparam handling:
>
> 1. Replace the uv_nmi_action string with an enum; and
> 2. Use sysfs_match_string() for string parsing in param_set_action()

...

Don't you need to include string.h?

...

> +enum action_t {
> + nmi_act_kdump,
> + nmi_act_dump,
> + nmi_act_ips,
> + nmi_act_kdb,
> + nmi_act_kgdb,
> + nmi_act_health,
> };

> +
> +static_assert(ARRAY_SIZE(actions) == ARRAY_SIZE(actions_desc));

I believe with enum in place you don't need this, just add a terminator to it

enum action_t {
...
nmi_act_max
};

and use as an array size both arrays.

...

> - int i;
> - int n = ARRAY_SIZE(valid_acts);

> + int i, n = ARRAY_SIZE(actions);

Since you are changing them, why not make them unsigned?

...

> - pr_err("UV: Invalid NMI action:%s, valid actions are:\n", arg);
> + pr_err("UV: Invalid NMI action:%s, valid actions are:\n", val);

As mentioned previously the val may or may not have a new line in it.
I dunno about comma removal, but a new line presence can be easily checked.

Either way it's not so critical, hence removing comma. or replacing it
by '-' (dash) may be enough.


--
With Best Regards,
Andy Shevchenko