Skip to content

Commit 4ca9c3d

Browse files
mrhpearsonjwrdegoede
authored andcommitted
platform/x86: think-lmi: Enable opcode support on BIOS settings
Whilst reviewing some documentation from the FW team on using WMI on Lenovo system I noticed that we weren't using Opcode support when changing BIOS settings in the thinkLMI driver. We should be doing this to ensure we're future proof as the old non-opcode mechanism has been deprecated. Tested on X1 Carbon G10 and G11. Signed-off-by: Mark Pearson <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hans de Goede <[email protected]>
1 parent c41e012 commit 4ca9c3d

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

drivers/platform/x86/think-lmi.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,33 @@ static ssize_t current_value_store(struct kobject *kobj,
10101010
tlmi_priv.pwd_admin->save_signature);
10111011
if (ret)
10121012
goto out;
1013-
} else { /* Non certiifcate based authentication */
1013+
} else if (tlmi_priv.opcode_support) {
1014+
/*
1015+
* If opcode support is present use that interface.
1016+
* Note - this sets the variable and then the password as separate
1017+
* WMI calls. Function tlmi_save_bios_settings will error if the
1018+
* password is incorrect.
1019+
*/
1020+
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name,
1021+
new_setting);
1022+
if (!set_str) {
1023+
ret = -ENOMEM;
1024+
goto out;
1025+
}
1026+
1027+
ret = tlmi_simple_call(LENOVO_SET_BIOS_SETTINGS_GUID, set_str);
1028+
if (ret)
1029+
goto out;
1030+
1031+
if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) {
1032+
ret = tlmi_opcode_setting("WmiOpcodePasswordAdmin",
1033+
tlmi_priv.pwd_admin->password);
1034+
if (ret)
1035+
goto out;
1036+
}
1037+
1038+
ret = tlmi_save_bios_settings("");
1039+
} else { /* old non-opcode based authentication method (deprecated) */
10141040
if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) {
10151041
auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;",
10161042
tlmi_priv.pwd_admin->password,

0 commit comments

Comments
 (0)