Re: [PATCH v10 05/14] platform/x86: alienware-wmi: Refactor hdmi, amplifier, deepslp methods

From: Andy Shevchenko
Date: Tue Feb 11 2025 - 11:38:41 EST


On Fri, Feb 07, 2025 at 10:46:01AM -0500, Kurt Borja wrote:
> Refactor show/store methods for hdmi, amplifier, deepslp sysfs groups to
> use alienware_wmi_command() instead of alienware_wmax_command() which
> uses deprecated WMI methods.

...

> + pr_err("alienware-wmi: unknown HDMI cable status: %d\n", ret);

Rather introduce pr_fmt() and drop all these prefixes.

> + if (!ret) {

Traditional patter is to check for errors:

if (ret) {
...do error handling...
}

> if (out_data == 1)
> return sysfs_emit(buf, "[input] gpu unknown\n");

> else if (out_data == 2)

Redundant 'else'.

> return sysfs_emit(buf, "input [gpu] unknown\n");
> }
> - pr_err("alienware-wmi: unknown HDMI source status: %u\n", status);
> +
> + pr_err("alienware-wmi: unknown HDMI source status: %u\n", ret);
> return sysfs_emit(buf, "input gpu [unknown]\n");


...

> if (strcmp(buf, "gpu\n") == 0)

Wow! This should be fixed to use sysfs_streq()

...

> + pr_err("alienware-wmi: HDMI toggle failed: results: %u\n", ret);

pr_fmt()

...

> + pr_err("alienware-wmi: unknown amplifier cable status: %d\n", ret);

Ditto.

Also note, if you have a struct device available, use the respective dev_*()
macros instead.

...

> if (strcmp(buf, "disabled\n") == 0)

sysfs_streq() / sysfs_match_string() — whatever suits better.

--
With Best Regards,
Andy Shevchenko