Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/x86: thinkpad_acpi: Get privacy-screen / lcdshadow ACPI handles only once

Get the privacy-screen / lcdshadow ACPI handles once and cache them,
instead of retrieving them every time we need them.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Mark Pearson <markpearson@lenovo.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211005202322.700909-8-hdegoede@redhat.com

+8 -10
+8 -10
drivers/platform/x86/thinkpad_acpi.c
··· 9819 9819 * LCD Shadow subdriver, for the Lenovo PrivacyGuard feature 9820 9820 */ 9821 9821 9822 + static acpi_handle lcdshadow_get_handle; 9823 + static acpi_handle lcdshadow_set_handle; 9822 9824 static int lcdshadow_state; 9823 9825 9824 9826 static int lcdshadow_on_off(bool state) 9825 9827 { 9826 - acpi_handle set_shadow_handle; 9827 9828 int output; 9828 9829 9829 - if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "SSSS", &set_shadow_handle))) { 9830 - pr_warn("Thinkpad ACPI has no %s interface.\n", "SSSS"); 9831 - return -EIO; 9832 - } 9833 - 9834 - if (!acpi_evalf(set_shadow_handle, &output, NULL, "dd", (int)state)) 9830 + if (!acpi_evalf(lcdshadow_set_handle, &output, NULL, "dd", (int)state)) 9835 9831 return -EIO; 9836 9832 9837 9833 lcdshadow_state = state; ··· 9845 9849 9846 9850 static int tpacpi_lcdshadow_init(struct ibm_init_struct *iibm) 9847 9851 { 9848 - acpi_handle get_shadow_handle; 9852 + acpi_status status1, status2; 9849 9853 int output; 9850 9854 9851 - if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "GSSS", &get_shadow_handle))) { 9855 + status1 = acpi_get_handle(hkey_handle, "GSSS", &lcdshadow_get_handle); 9856 + status2 = acpi_get_handle(hkey_handle, "SSSS", &lcdshadow_set_handle); 9857 + if (ACPI_FAILURE(status1) || ACPI_FAILURE(status2)) { 9852 9858 lcdshadow_state = -ENODEV; 9853 9859 return 0; 9854 9860 } 9855 9861 9856 - if (!acpi_evalf(get_shadow_handle, &output, NULL, "dd", 0)) { 9862 + if (!acpi_evalf(lcdshadow_get_handle, &output, NULL, "dd", 0)) { 9857 9863 lcdshadow_state = -EIO; 9858 9864 return -EIO; 9859 9865 }